google_blogger3/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 /// Manage your Blogger account
17 Full,
18
19 /// View your Blogger account
20 Readonly,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::Full => "https://www.googleapis.com/auth/blogger",
27 Scope::Readonly => "https://www.googleapis.com/auth/blogger.readonly",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Readonly
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Blogger related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_blogger3 as blogger3;
53/// use blogger3::{Result, Error};
54/// # async fn dox() {
55/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66/// .with_native_roots()
67/// .unwrap()
68/// .https_only()
69/// .enable_http2()
70/// .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74/// secret,
75/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76/// yup_oauth2::client::CustomHyperClientBuilder::from(
77/// hyper_util::client::legacy::Client::builder(executor).build(connector),
78/// ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82/// hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85/// hyper_rustls::HttpsConnectorBuilder::new()
86/// .with_native_roots()
87/// .unwrap()
88/// .https_or_http()
89/// .enable_http2()
90/// .build()
91/// );
92/// let mut hub = Blogger::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.posts().list("blogId")
97/// .view("gubergren")
98/// .add_status("rebum.")
99/// .start_date("est")
100/// .sort_option("ipsum")
101/// .page_token("ipsum")
102/// .order_by("est")
103/// .max_results(39)
104/// .labels("ea")
105/// .fetch_images(false)
106/// .fetch_bodies(true)
107/// .end_date("eos")
108/// .doit().await;
109///
110/// match result {
111/// Err(e) => match e {
112/// // The Error enum provides details about what exactly happened.
113/// // You can also just use its `Debug`, `Display` or `Error` traits
114/// Error::HttpError(_)
115/// |Error::Io(_)
116/// |Error::MissingAPIKey
117/// |Error::MissingToken(_)
118/// |Error::Cancelled
119/// |Error::UploadSizeLimitExceeded(_, _)
120/// |Error::Failure(_)
121/// |Error::BadRequest(_)
122/// |Error::FieldClash(_)
123/// |Error::JsonDecodeError(_, _) => println!("{}", e),
124/// },
125/// Ok(res) => println!("Success: {:?}", res),
126/// }
127/// # }
128/// ```
129#[derive(Clone)]
130pub struct Blogger<C> {
131 pub client: common::Client<C>,
132 pub auth: Box<dyn common::GetToken>,
133 _user_agent: String,
134 _base_url: String,
135 _root_url: String,
136}
137
138impl<C> common::Hub for Blogger<C> {}
139
140impl<'a, C> Blogger<C> {
141 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Blogger<C> {
142 Blogger {
143 client,
144 auth: Box::new(auth),
145 _user_agent: "google-api-rust-client/7.0.0".to_string(),
146 _base_url: "https://blogger.googleapis.com/".to_string(),
147 _root_url: "https://blogger.googleapis.com/".to_string(),
148 }
149 }
150
151 pub fn blog_user_infos(&'a self) -> BlogUserInfoMethods<'a, C> {
152 BlogUserInfoMethods { hub: self }
153 }
154 pub fn blogs(&'a self) -> BlogMethods<'a, C> {
155 BlogMethods { hub: self }
156 }
157 pub fn comments(&'a self) -> CommentMethods<'a, C> {
158 CommentMethods { hub: self }
159 }
160 pub fn page_views(&'a self) -> PageViewMethods<'a, C> {
161 PageViewMethods { hub: self }
162 }
163 pub fn pages(&'a self) -> PageMethods<'a, C> {
164 PageMethods { hub: self }
165 }
166 pub fn post_user_infos(&'a self) -> PostUserInfoMethods<'a, C> {
167 PostUserInfoMethods { hub: self }
168 }
169 pub fn posts(&'a self) -> PostMethods<'a, C> {
170 PostMethods { hub: self }
171 }
172 pub fn users(&'a self) -> UserMethods<'a, C> {
173 UserMethods { hub: self }
174 }
175
176 /// Set the user-agent header field to use in all requests to the server.
177 /// It defaults to `google-api-rust-client/7.0.0`.
178 ///
179 /// Returns the previously set user-agent.
180 pub fn user_agent(&mut self, agent_name: String) -> String {
181 std::mem::replace(&mut self._user_agent, agent_name)
182 }
183
184 /// Set the base url to use in all requests to the server.
185 /// It defaults to `https://blogger.googleapis.com/`.
186 ///
187 /// Returns the previously set base url.
188 pub fn base_url(&mut self, new_base_url: String) -> String {
189 std::mem::replace(&mut self._base_url, new_base_url)
190 }
191
192 /// Set the root url to use in all requests to the server.
193 /// It defaults to `https://blogger.googleapis.com/`.
194 ///
195 /// Returns the previously set root url.
196 pub fn root_url(&mut self, new_root_url: String) -> String {
197 std::mem::replace(&mut self._root_url, new_root_url)
198 }
199}
200
201// ############
202// SCHEMAS ###
203// ##########
204/// There is no detailed description.
205///
206/// # Activities
207///
208/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
209/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
210///
211/// * [get blogs](BlogGetCall) (response)
212/// * [get by url blogs](BlogGetByUrlCall) (response)
213/// * [list by user blogs](BlogListByUserCall) (none)
214#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
215#[serde_with::serde_as]
216#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
217pub struct Blog {
218 /// The JSON custom meta-data for the Blog.
219 #[serde(rename = "customMetaData")]
220 pub custom_meta_data: Option<String>,
221 /// The description of this blog. This is displayed underneath the title.
222 pub description: Option<String>,
223 /// The identifier for this resource.
224 pub id: Option<String>,
225 /// The kind of this entry. Always blogger#blog.
226 pub kind: Option<String>,
227 /// The locale this Blog is set to.
228 pub locale: Option<BlogLocale>,
229 /// The name of this blog. This is displayed as the title.
230 pub name: Option<String>,
231 /// The container of pages in this blog.
232 pub pages: Option<BlogPages>,
233 /// The container of posts in this blog.
234 pub posts: Option<BlogPosts>,
235 /// RFC 3339 date-time when this blog was published.
236 pub published: Option<String>,
237 /// The API REST URL to fetch this resource from.
238 #[serde(rename = "selfLink")]
239 pub self_link: Option<String>,
240 /// The status of the blog.
241 pub status: Option<String>,
242 /// RFC 3339 date-time when this blog was last updated.
243 pub updated: Option<String>,
244 /// The URL where this blog is published.
245 pub url: Option<String>,
246}
247
248impl common::Resource for Blog {}
249impl common::ResponseResult for Blog {}
250
251/// There is no detailed description.
252///
253/// # Activities
254///
255/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
256/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
257///
258/// * [list by user blogs](BlogListByUserCall) (response)
259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
260#[serde_with::serde_as]
261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
262pub struct BlogList {
263 /// Admin level list of blog per-user information.
264 #[serde(rename = "blogUserInfos")]
265 pub blog_user_infos: Option<Vec<BlogUserInfo>>,
266 /// The list of Blogs this user has Authorship or Admin rights over.
267 pub items: Option<Vec<Blog>>,
268 /// The kind of this entity. Always blogger#blogList.
269 pub kind: Option<String>,
270}
271
272impl common::ResponseResult for BlogList {}
273
274/// There is no detailed description.
275///
276/// This type is not used in any activity, and only used as *part* of another schema.
277///
278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
279#[serde_with::serde_as]
280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
281pub struct BlogPerUserInfo {
282 /// ID of the Blog resource.
283 #[serde(rename = "blogId")]
284 pub blog_id: Option<String>,
285 /// True if the user has Admin level access to the blog.
286 #[serde(rename = "hasAdminAccess")]
287 pub has_admin_access: Option<bool>,
288 /// The kind of this entity. Always blogger#blogPerUserInfo.
289 pub kind: Option<String>,
290 /// The Photo Album Key for the user when adding photos to the blog.
291 #[serde(rename = "photosAlbumKey")]
292 pub photos_album_key: Option<String>,
293 /// Access permissions that the user has for the blog (ADMIN, AUTHOR, or READER).
294 pub role: Option<String>,
295 /// ID of the User.
296 #[serde(rename = "userId")]
297 pub user_id: Option<String>,
298}
299
300impl common::Part for BlogPerUserInfo {}
301
302/// There is no detailed description.
303///
304/// # Activities
305///
306/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
307/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
308///
309/// * [get blog user infos](BlogUserInfoGetCall) (response)
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct BlogUserInfo {
314 /// The Blog resource.
315 pub blog: Option<Blog>,
316 /// Information about a User for the Blog.
317 pub blog_user_info: Option<BlogPerUserInfo>,
318 /// The kind of this entity. Always blogger#blogUserInfo.
319 pub kind: Option<String>,
320}
321
322impl common::Resource for BlogUserInfo {}
323impl common::ResponseResult for BlogUserInfo {}
324
325/// There is no detailed description.
326///
327/// # Activities
328///
329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
331///
332/// * [approve comments](CommentApproveCall) (response)
333/// * [delete comments](CommentDeleteCall) (none)
334/// * [get comments](CommentGetCall) (response)
335/// * [list comments](CommentListCall) (none)
336/// * [list by blog comments](CommentListByBlogCall) (none)
337/// * [mark as spam comments](CommentMarkAsSpamCall) (response)
338/// * [remove content comments](CommentRemoveContentCall) (response)
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct Comment {
343 /// The author of this Comment.
344 pub author: Option<CommentAuthor>,
345 /// Data about the blog containing this comment.
346 pub blog: Option<CommentBlog>,
347 /// The actual content of the comment. May include HTML markup.
348 pub content: Option<String>,
349 /// The identifier for this resource.
350 pub id: Option<String>,
351 /// Data about the comment this is in reply to.
352 #[serde(rename = "inReplyTo")]
353 pub in_reply_to: Option<CommentInReplyTo>,
354 /// The kind of this entry. Always blogger#comment.
355 pub kind: Option<String>,
356 /// Data about the post containing this comment.
357 pub post: Option<CommentPost>,
358 /// RFC 3339 date-time when this comment was published.
359 pub published: Option<String>,
360 /// The API REST URL to fetch this resource from.
361 #[serde(rename = "selfLink")]
362 pub self_link: Option<String>,
363 /// The status of the comment (only populated for admin users).
364 pub status: Option<String>,
365 /// RFC 3339 date-time when this comment was last updated.
366 pub updated: Option<String>,
367}
368
369impl common::Resource for Comment {}
370impl common::ResponseResult for Comment {}
371
372/// There is no detailed description.
373///
374/// # Activities
375///
376/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
377/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
378///
379/// * [list comments](CommentListCall) (response)
380/// * [list by blog comments](CommentListByBlogCall) (response)
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct CommentList {
385 /// Etag of the response.
386 pub etag: Option<String>,
387 /// The List of Comments for a Post.
388 pub items: Option<Vec<Comment>>,
389 /// The kind of this entry. Always blogger#commentList.
390 pub kind: Option<String>,
391 /// Pagination token to fetch the next page, if one exists.
392 #[serde(rename = "nextPageToken")]
393 pub next_page_token: Option<String>,
394 /// Pagination token to fetch the previous page, if one exists.
395 #[serde(rename = "prevPageToken")]
396 pub prev_page_token: Option<String>,
397}
398
399impl common::ResponseResult for CommentList {}
400
401/// There is no detailed description.
402///
403/// # Activities
404///
405/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
406/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
407///
408/// * [delete pages](PageDeleteCall) (none)
409/// * [get pages](PageGetCall) (response)
410/// * [insert pages](PageInsertCall) (request|response)
411/// * [list pages](PageListCall) (none)
412/// * [patch pages](PagePatchCall) (request|response)
413/// * [publish pages](PagePublishCall) (response)
414/// * [revert pages](PageRevertCall) (response)
415/// * [update pages](PageUpdateCall) (request|response)
416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
417#[serde_with::serde_as]
418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
419pub struct Page {
420 /// The author of this Page.
421 pub author: Option<PageAuthor>,
422 /// Data about the blog containing this Page.
423 pub blog: Option<PageBlog>,
424 /// The body content of this Page, in HTML.
425 pub content: Option<String>,
426 /// Etag of the resource.
427 pub etag: Option<String>,
428 /// The identifier for this resource.
429 pub id: Option<String>,
430 /// The kind of this entity. Always blogger#page.
431 pub kind: Option<String>,
432 /// RFC 3339 date-time when this Page was published.
433 pub published: Option<String>,
434 /// The API REST URL to fetch this resource from.
435 #[serde(rename = "selfLink")]
436 pub self_link: Option<String>,
437 /// The status of the page for admin resources (either LIVE or DRAFT).
438 pub status: Option<String>,
439 /// The title of this entity. This is the name displayed in the Admin user interface.
440 pub title: Option<String>,
441 /// RFC 3339 date-time when this Page was trashed.
442 pub trashed: Option<String>,
443 /// RFC 3339 date-time when this Page was last updated.
444 pub updated: Option<String>,
445 /// The URL that this Page is displayed at.
446 pub url: Option<String>,
447}
448
449impl common::RequestValue for Page {}
450impl common::Resource for Page {}
451impl common::ResponseResult for Page {}
452
453/// There is no detailed description.
454///
455/// # Activities
456///
457/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
458/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
459///
460/// * [list pages](PageListCall) (response)
461#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
462#[serde_with::serde_as]
463#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
464pub struct PageList {
465 /// Etag of the response.
466 pub etag: Option<String>,
467 /// The list of Pages for a Blog.
468 pub items: Option<Vec<Page>>,
469 /// The kind of this entity. Always blogger#pageList.
470 pub kind: Option<String>,
471 /// Pagination token to fetch the next page, if one exists.
472 #[serde(rename = "nextPageToken")]
473 pub next_page_token: Option<String>,
474}
475
476impl common::ResponseResult for PageList {}
477
478/// There is no detailed description.
479///
480/// # Activities
481///
482/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
483/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
484///
485/// * [get page views](PageViewGetCall) (response)
486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
487#[serde_with::serde_as]
488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
489pub struct Pageviews {
490 /// Blog Id.
491 #[serde(rename = "blogId")]
492 pub blog_id: Option<String>,
493 /// The container of posts in this blog.
494 pub counts: Option<Vec<PageviewsCounts>>,
495 /// The kind of this entry. Always blogger#page_views.
496 pub kind: Option<String>,
497}
498
499impl common::ResponseResult for Pageviews {}
500
501/// There is no detailed description.
502///
503/// # Activities
504///
505/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
506/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
507///
508/// * [delete posts](PostDeleteCall) (none)
509/// * [get posts](PostGetCall) (response)
510/// * [get by path posts](PostGetByPathCall) (response)
511/// * [insert posts](PostInsertCall) (request|response)
512/// * [list posts](PostListCall) (none)
513/// * [patch posts](PostPatchCall) (request|response)
514/// * [publish posts](PostPublishCall) (response)
515/// * [revert posts](PostRevertCall) (response)
516/// * [search posts](PostSearchCall) (none)
517/// * [update posts](PostUpdateCall) (request|response)
518#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
519#[serde_with::serde_as]
520#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
521pub struct Post {
522 /// The author of this Post.
523 pub author: Option<PostAuthor>,
524 /// Data about the blog containing this Post.
525 pub blog: Option<PostBlog>,
526 /// The content of the Post. May contain HTML markup.
527 pub content: Option<String>,
528 /// The JSON meta-data for the Post.
529 #[serde(rename = "customMetaData")]
530 pub custom_meta_data: Option<String>,
531 /// Etag of the resource.
532 pub etag: Option<String>,
533 /// The identifier of this Post.
534 pub id: Option<String>,
535 /// Display image for the Post.
536 pub images: Option<Vec<PostImages>>,
537 /// The kind of this entity. Always blogger#post.
538 pub kind: Option<String>,
539 /// The list of labels this Post was tagged with.
540 pub labels: Option<Vec<String>>,
541 /// The location for geotagged posts.
542 pub location: Option<PostLocation>,
543 /// RFC 3339 date-time when this Post was published.
544 pub published: Option<String>,
545 /// Comment control and display setting for readers of this post.
546 #[serde(rename = "readerComments")]
547 pub reader_comments: Option<String>,
548 /// The container of comments on this Post.
549 pub replies: Option<PostReplies>,
550 /// The API REST URL to fetch this resource from.
551 #[serde(rename = "selfLink")]
552 pub self_link: Option<String>,
553 /// Status of the post. Only set for admin-level requests.
554 pub status: Option<String>,
555 /// The title of the Post.
556 pub title: Option<String>,
557 /// The title link URL, similar to atom's related link.
558 #[serde(rename = "titleLink")]
559 pub title_link: Option<String>,
560 /// RFC 3339 date-time when this Post was last trashed.
561 pub trashed: Option<String>,
562 /// RFC 3339 date-time when this Post was last updated.
563 pub updated: Option<String>,
564 /// The URL where this Post is displayed.
565 pub url: Option<String>,
566}
567
568impl common::RequestValue for Post {}
569impl common::Resource for Post {}
570impl common::ResponseResult for Post {}
571
572/// There is no detailed description.
573///
574/// # Activities
575///
576/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
577/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
578///
579/// * [list posts](PostListCall) (response)
580/// * [search posts](PostSearchCall) (response)
581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
582#[serde_with::serde_as]
583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
584pub struct PostList {
585 /// Etag of the response.
586 pub etag: Option<String>,
587 /// The list of Posts for this Blog.
588 pub items: Option<Vec<Post>>,
589 /// The kind of this entity. Always blogger#postList.
590 pub kind: Option<String>,
591 /// Pagination token to fetch the next page, if one exists.
592 #[serde(rename = "nextPageToken")]
593 pub next_page_token: Option<String>,
594 /// Pagination token to fetch the previous page, if one exists.
595 #[serde(rename = "prevPageToken")]
596 pub prev_page_token: Option<String>,
597}
598
599impl common::ResponseResult for PostList {}
600
601/// There is no detailed description.
602///
603/// This type is not used in any activity, and only used as *part* of another schema.
604///
605#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
606#[serde_with::serde_as]
607#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
608pub struct PostPerUserInfo {
609 /// ID of the Blog that the post resource belongs to.
610 #[serde(rename = "blogId")]
611 pub blog_id: Option<String>,
612 /// True if the user has Author level access to the post.
613 #[serde(rename = "hasEditAccess")]
614 pub has_edit_access: Option<bool>,
615 /// The kind of this entity. Always blogger#postPerUserInfo.
616 pub kind: Option<String>,
617 /// ID of the Post resource.
618 #[serde(rename = "postId")]
619 pub post_id: Option<String>,
620 /// ID of the User.
621 #[serde(rename = "userId")]
622 pub user_id: Option<String>,
623}
624
625impl common::Part for PostPerUserInfo {}
626
627/// There is no detailed description.
628///
629/// # Activities
630///
631/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
632/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
633///
634/// * [get post user infos](PostUserInfoGetCall) (response)
635/// * [list post user infos](PostUserInfoListCall) (none)
636#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
637#[serde_with::serde_as]
638#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
639pub struct PostUserInfo {
640 /// The kind of this entity. Always blogger#postUserInfo.
641 pub kind: Option<String>,
642 /// The Post resource.
643 pub post: Option<Post>,
644 /// Information about a User for the Post.
645 pub post_user_info: Option<PostPerUserInfo>,
646}
647
648impl common::Resource for PostUserInfo {}
649impl common::ResponseResult for PostUserInfo {}
650
651/// There is no detailed description.
652///
653/// # Activities
654///
655/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
656/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
657///
658/// * [list post user infos](PostUserInfoListCall) (response)
659#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
660#[serde_with::serde_as]
661#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
662pub struct PostUserInfosList {
663 /// The list of Posts with User information for the post, for this Blog.
664 pub items: Option<Vec<PostUserInfo>>,
665 /// The kind of this entity. Always blogger#postList.
666 pub kind: Option<String>,
667 /// Pagination token to fetch the next page, if one exists.
668 #[serde(rename = "nextPageToken")]
669 pub next_page_token: Option<String>,
670}
671
672impl common::ResponseResult for PostUserInfosList {}
673
674/// There is no detailed description.
675///
676/// # Activities
677///
678/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
679/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
680///
681/// * [get users](UserGetCall) (response)
682#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
683#[serde_with::serde_as]
684#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
685pub struct User {
686 /// Profile summary information.
687 pub about: Option<String>,
688 /// The container of blogs for this user.
689 pub blogs: Option<UserBlogs>,
690 /// The timestamp of when this profile was created, in seconds since epoch.
691 pub created: Option<String>,
692 /// The display name.
693 #[serde(rename = "displayName")]
694 pub display_name: Option<String>,
695 /// The identifier for this User.
696 pub id: Option<String>,
697 /// The kind of this entity. Always blogger#user.
698 pub kind: Option<String>,
699 /// This user's locale
700 pub locale: Option<UserLocale>,
701 /// The API REST URL to fetch this resource from.
702 #[serde(rename = "selfLink")]
703 pub self_link: Option<String>,
704 /// The user's profile page.
705 pub url: Option<String>,
706}
707
708impl common::Resource for User {}
709impl common::ResponseResult for User {}
710
711/// The locale this Blog is set to.
712///
713/// This type is not used in any activity, and only used as *part* of another schema.
714///
715#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
716#[serde_with::serde_as]
717#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
718pub struct BlogLocale {
719 /// The country this blog's locale is set to.
720 pub country: Option<String>,
721 /// The language this blog is authored in.
722 pub language: Option<String>,
723 /// The language variant this blog is authored in.
724 pub variant: Option<String>,
725}
726
727impl common::NestedType for BlogLocale {}
728impl common::Part for BlogLocale {}
729
730/// The container of pages in this blog.
731///
732/// This type is not used in any activity, and only used as *part* of another schema.
733///
734#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
735#[serde_with::serde_as]
736#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
737pub struct BlogPages {
738 /// The URL of the container for pages in this blog.
739 #[serde(rename = "selfLink")]
740 pub self_link: Option<String>,
741 /// The count of pages in this blog.
742 #[serde(rename = "totalItems")]
743 pub total_items: Option<i32>,
744}
745
746impl common::NestedType for BlogPages {}
747impl common::Part for BlogPages {}
748
749/// The container of posts in this blog.
750///
751/// This type is not used in any activity, and only used as *part* of another schema.
752///
753#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
754#[serde_with::serde_as]
755#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
756pub struct BlogPosts {
757 /// The List of Posts for this Blog.
758 pub items: Option<Vec<Post>>,
759 /// The URL of the container for posts in this blog.
760 #[serde(rename = "selfLink")]
761 pub self_link: Option<String>,
762 /// The count of posts in this blog.
763 #[serde(rename = "totalItems")]
764 pub total_items: Option<i32>,
765}
766
767impl common::NestedType for BlogPosts {}
768impl common::Part for BlogPosts {}
769
770/// The author of this Comment.
771///
772/// This type is not used in any activity, and only used as *part* of another schema.
773///
774#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
775#[serde_with::serde_as]
776#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
777pub struct CommentAuthor {
778 /// The display name.
779 #[serde(rename = "displayName")]
780 pub display_name: Option<String>,
781 /// The identifier of the creator.
782 pub id: Option<String>,
783 /// The creator's avatar.
784 pub image: Option<CommentAuthorImage>,
785 /// The URL of the creator's Profile page.
786 pub url: Option<String>,
787}
788
789impl common::NestedType for CommentAuthor {}
790impl common::Part for CommentAuthor {}
791
792/// The creator's avatar.
793///
794/// This type is not used in any activity, and only used as *part* of another schema.
795///
796#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
797#[serde_with::serde_as]
798#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
799pub struct CommentAuthorImage {
800 /// The creator's avatar URL.
801 pub url: Option<String>,
802}
803
804impl common::NestedType for CommentAuthorImage {}
805impl common::Part for CommentAuthorImage {}
806
807/// Data about the blog containing this comment.
808///
809/// This type is not used in any activity, and only used as *part* of another schema.
810///
811#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
812#[serde_with::serde_as]
813#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
814pub struct CommentBlog {
815 /// The identifier of the blog containing this comment.
816 pub id: Option<String>,
817}
818
819impl common::NestedType for CommentBlog {}
820impl common::Part for CommentBlog {}
821
822/// Data about the comment this is in reply to.
823///
824/// This type is not used in any activity, and only used as *part* of another schema.
825///
826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
827#[serde_with::serde_as]
828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
829pub struct CommentInReplyTo {
830 /// The identified of the parent of this comment.
831 pub id: Option<String>,
832}
833
834impl common::NestedType for CommentInReplyTo {}
835impl common::Part for CommentInReplyTo {}
836
837/// Data about the post containing this comment.
838///
839/// This type is not used in any activity, and only used as *part* of another schema.
840///
841#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
842#[serde_with::serde_as]
843#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
844pub struct CommentPost {
845 /// The identifier of the post containing this comment.
846 pub id: Option<String>,
847}
848
849impl common::NestedType for CommentPost {}
850impl common::Part for CommentPost {}
851
852/// The author of this Page.
853///
854/// This type is not used in any activity, and only used as *part* of another schema.
855///
856#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
857#[serde_with::serde_as]
858#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
859pub struct PageAuthor {
860 /// The display name.
861 #[serde(rename = "displayName")]
862 pub display_name: Option<String>,
863 /// The identifier of the creator.
864 pub id: Option<String>,
865 /// The creator's avatar.
866 pub image: Option<PageAuthorImage>,
867 /// The URL of the creator's Profile page.
868 pub url: Option<String>,
869}
870
871impl common::NestedType for PageAuthor {}
872impl common::Part for PageAuthor {}
873
874/// The creator's avatar.
875///
876/// This type is not used in any activity, and only used as *part* of another schema.
877///
878#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
879#[serde_with::serde_as]
880#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
881pub struct PageAuthorImage {
882 /// The creator's avatar URL.
883 pub url: Option<String>,
884}
885
886impl common::NestedType for PageAuthorImage {}
887impl common::Part for PageAuthorImage {}
888
889/// Data about the blog containing this Page.
890///
891/// This type is not used in any activity, and only used as *part* of another schema.
892///
893#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
894#[serde_with::serde_as]
895#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
896pub struct PageBlog {
897 /// The identifier of the blog containing this page.
898 pub id: Option<String>,
899}
900
901impl common::NestedType for PageBlog {}
902impl common::Part for PageBlog {}
903
904/// The container of posts in this blog.
905///
906/// This type is not used in any activity, and only used as *part* of another schema.
907///
908#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
909#[serde_with::serde_as]
910#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
911pub struct PageviewsCounts {
912 /// Count of page views for the given time range.
913 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
914 pub count: Option<i64>,
915 /// Time range the given count applies to.
916 #[serde(rename = "timeRange")]
917 pub time_range: Option<String>,
918}
919
920impl common::NestedType for PageviewsCounts {}
921impl common::Part for PageviewsCounts {}
922
923/// The author of this Post.
924///
925/// This type is not used in any activity, and only used as *part* of another schema.
926///
927#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
928#[serde_with::serde_as]
929#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
930pub struct PostAuthor {
931 /// The display name.
932 #[serde(rename = "displayName")]
933 pub display_name: Option<String>,
934 /// The identifier of the creator.
935 pub id: Option<String>,
936 /// The creator's avatar.
937 pub image: Option<PostAuthorImage>,
938 /// The URL of the creator's Profile page.
939 pub url: Option<String>,
940}
941
942impl common::NestedType for PostAuthor {}
943impl common::Part for PostAuthor {}
944
945/// The creator's avatar.
946///
947/// This type is not used in any activity, and only used as *part* of another schema.
948///
949#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
950#[serde_with::serde_as]
951#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
952pub struct PostAuthorImage {
953 /// The creator's avatar URL.
954 pub url: Option<String>,
955}
956
957impl common::NestedType for PostAuthorImage {}
958impl common::Part for PostAuthorImage {}
959
960/// Data about the blog containing this Post.
961///
962/// This type is not used in any activity, and only used as *part* of another schema.
963///
964#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
965#[serde_with::serde_as]
966#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
967pub struct PostBlog {
968 /// The identifier of the Blog that contains this Post.
969 pub id: Option<String>,
970}
971
972impl common::NestedType for PostBlog {}
973impl common::Part for PostBlog {}
974
975/// Display image for the Post.
976///
977/// This type is not used in any activity, and only used as *part* of another schema.
978///
979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
980#[serde_with::serde_as]
981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
982pub struct PostImages {
983 /// no description provided
984 pub url: Option<String>,
985}
986
987impl common::NestedType for PostImages {}
988impl common::Part for PostImages {}
989
990/// The location for geotagged posts.
991///
992/// This type is not used in any activity, and only used as *part* of another schema.
993///
994#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
995#[serde_with::serde_as]
996#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
997pub struct PostLocation {
998 /// Location's latitude.
999 pub lat: Option<f64>,
1000 /// Location's longitude.
1001 pub lng: Option<f64>,
1002 /// Location name.
1003 pub name: Option<String>,
1004 /// Location's viewport span. Can be used when rendering a map preview.
1005 pub span: Option<String>,
1006}
1007
1008impl common::NestedType for PostLocation {}
1009impl common::Part for PostLocation {}
1010
1011/// The container of comments on this Post.
1012///
1013/// This type is not used in any activity, and only used as *part* of another schema.
1014///
1015#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1016#[serde_with::serde_as]
1017#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1018pub struct PostReplies {
1019 /// The List of Comments for this Post.
1020 pub items: Option<Vec<Comment>>,
1021 /// The URL of the comments on this post.
1022 #[serde(rename = "selfLink")]
1023 pub self_link: Option<String>,
1024 /// The count of comments on this post.
1025 #[serde(rename = "totalItems")]
1026 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1027 pub total_items: Option<i64>,
1028}
1029
1030impl common::NestedType for PostReplies {}
1031impl common::Part for PostReplies {}
1032
1033/// The container of blogs for this user.
1034///
1035/// This type is not used in any activity, and only used as *part* of another schema.
1036///
1037#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1038#[serde_with::serde_as]
1039#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1040pub struct UserBlogs {
1041 /// The URL of the Blogs for this user.
1042 #[serde(rename = "selfLink")]
1043 pub self_link: Option<String>,
1044}
1045
1046impl common::NestedType for UserBlogs {}
1047impl common::Part for UserBlogs {}
1048
1049/// This user's locale
1050///
1051/// This type is not used in any activity, and only used as *part* of another schema.
1052///
1053#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1054#[serde_with::serde_as]
1055#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1056pub struct UserLocale {
1057 /// The country this blog's locale is set to.
1058 pub country: Option<String>,
1059 /// The language this blog is authored in.
1060 pub language: Option<String>,
1061 /// The language variant this blog is authored in.
1062 pub variant: Option<String>,
1063}
1064
1065impl common::NestedType for UserLocale {}
1066impl common::Part for UserLocale {}
1067
1068// ###################
1069// MethodBuilders ###
1070// #################
1071
1072/// A builder providing access to all methods supported on *blogUserInfo* resources.
1073/// It is not used directly, but through the [`Blogger`] hub.
1074///
1075/// # Example
1076///
1077/// Instantiate a resource builder
1078///
1079/// ```test_harness,no_run
1080/// extern crate hyper;
1081/// extern crate hyper_rustls;
1082/// extern crate google_blogger3 as blogger3;
1083///
1084/// # async fn dox() {
1085/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1086///
1087/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1088/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1089/// .with_native_roots()
1090/// .unwrap()
1091/// .https_only()
1092/// .enable_http2()
1093/// .build();
1094///
1095/// let executor = hyper_util::rt::TokioExecutor::new();
1096/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1097/// secret,
1098/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1099/// yup_oauth2::client::CustomHyperClientBuilder::from(
1100/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1101/// ),
1102/// ).build().await.unwrap();
1103///
1104/// let client = hyper_util::client::legacy::Client::builder(
1105/// hyper_util::rt::TokioExecutor::new()
1106/// )
1107/// .build(
1108/// hyper_rustls::HttpsConnectorBuilder::new()
1109/// .with_native_roots()
1110/// .unwrap()
1111/// .https_or_http()
1112/// .enable_http2()
1113/// .build()
1114/// );
1115/// let mut hub = Blogger::new(client, auth);
1116/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1117/// // like `get(...)`
1118/// // to build up your call.
1119/// let rb = hub.blog_user_infos();
1120/// # }
1121/// ```
1122pub struct BlogUserInfoMethods<'a, C>
1123where
1124 C: 'a,
1125{
1126 hub: &'a Blogger<C>,
1127}
1128
1129impl<'a, C> common::MethodsBuilder for BlogUserInfoMethods<'a, C> {}
1130
1131impl<'a, C> BlogUserInfoMethods<'a, C> {
1132 /// Create a builder to help you perform the following task:
1133 ///
1134 /// Gets one blog and user info pair by blog id and user id.
1135 ///
1136 /// # Arguments
1137 ///
1138 /// * `userId` - No description provided.
1139 /// * `blogId` - No description provided.
1140 pub fn get(&self, user_id: &str, blog_id: &str) -> BlogUserInfoGetCall<'a, C> {
1141 BlogUserInfoGetCall {
1142 hub: self.hub,
1143 _user_id: user_id.to_string(),
1144 _blog_id: blog_id.to_string(),
1145 _max_posts: Default::default(),
1146 _delegate: Default::default(),
1147 _additional_params: Default::default(),
1148 _scopes: Default::default(),
1149 }
1150 }
1151}
1152
1153/// A builder providing access to all methods supported on *blog* resources.
1154/// It is not used directly, but through the [`Blogger`] hub.
1155///
1156/// # Example
1157///
1158/// Instantiate a resource builder
1159///
1160/// ```test_harness,no_run
1161/// extern crate hyper;
1162/// extern crate hyper_rustls;
1163/// extern crate google_blogger3 as blogger3;
1164///
1165/// # async fn dox() {
1166/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1167///
1168/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1169/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1170/// .with_native_roots()
1171/// .unwrap()
1172/// .https_only()
1173/// .enable_http2()
1174/// .build();
1175///
1176/// let executor = hyper_util::rt::TokioExecutor::new();
1177/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1178/// secret,
1179/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1180/// yup_oauth2::client::CustomHyperClientBuilder::from(
1181/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1182/// ),
1183/// ).build().await.unwrap();
1184///
1185/// let client = hyper_util::client::legacy::Client::builder(
1186/// hyper_util::rt::TokioExecutor::new()
1187/// )
1188/// .build(
1189/// hyper_rustls::HttpsConnectorBuilder::new()
1190/// .with_native_roots()
1191/// .unwrap()
1192/// .https_or_http()
1193/// .enable_http2()
1194/// .build()
1195/// );
1196/// let mut hub = Blogger::new(client, auth);
1197/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1198/// // like `get(...)`, `get_by_url(...)` and `list_by_user(...)`
1199/// // to build up your call.
1200/// let rb = hub.blogs();
1201/// # }
1202/// ```
1203pub struct BlogMethods<'a, C>
1204where
1205 C: 'a,
1206{
1207 hub: &'a Blogger<C>,
1208}
1209
1210impl<'a, C> common::MethodsBuilder for BlogMethods<'a, C> {}
1211
1212impl<'a, C> BlogMethods<'a, C> {
1213 /// Create a builder to help you perform the following task:
1214 ///
1215 /// Gets a blog by id.
1216 ///
1217 /// # Arguments
1218 ///
1219 /// * `blogId` - No description provided.
1220 pub fn get(&self, blog_id: &str) -> BlogGetCall<'a, C> {
1221 BlogGetCall {
1222 hub: self.hub,
1223 _blog_id: blog_id.to_string(),
1224 _view: Default::default(),
1225 _max_posts: Default::default(),
1226 _delegate: Default::default(),
1227 _additional_params: Default::default(),
1228 _scopes: Default::default(),
1229 }
1230 }
1231
1232 /// Create a builder to help you perform the following task:
1233 ///
1234 /// Gets a blog by url.
1235 ///
1236 /// # Arguments
1237 ///
1238 /// * `url` - No description provided.
1239 pub fn get_by_url(&self, url: &str) -> BlogGetByUrlCall<'a, C> {
1240 BlogGetByUrlCall {
1241 hub: self.hub,
1242 _url: url.to_string(),
1243 _view: Default::default(),
1244 _delegate: Default::default(),
1245 _additional_params: Default::default(),
1246 _scopes: Default::default(),
1247 }
1248 }
1249
1250 /// Create a builder to help you perform the following task:
1251 ///
1252 /// Lists blogs by user.
1253 ///
1254 /// # Arguments
1255 ///
1256 /// * `userId` - No description provided.
1257 pub fn list_by_user(&self, user_id: &str) -> BlogListByUserCall<'a, C> {
1258 BlogListByUserCall {
1259 hub: self.hub,
1260 _user_id: user_id.to_string(),
1261 _view: Default::default(),
1262 _status: Default::default(),
1263 _role: Default::default(),
1264 _fetch_user_info: Default::default(),
1265 _delegate: Default::default(),
1266 _additional_params: Default::default(),
1267 _scopes: Default::default(),
1268 }
1269 }
1270}
1271
1272/// A builder providing access to all methods supported on *comment* resources.
1273/// It is not used directly, but through the [`Blogger`] hub.
1274///
1275/// # Example
1276///
1277/// Instantiate a resource builder
1278///
1279/// ```test_harness,no_run
1280/// extern crate hyper;
1281/// extern crate hyper_rustls;
1282/// extern crate google_blogger3 as blogger3;
1283///
1284/// # async fn dox() {
1285/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1286///
1287/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1288/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1289/// .with_native_roots()
1290/// .unwrap()
1291/// .https_only()
1292/// .enable_http2()
1293/// .build();
1294///
1295/// let executor = hyper_util::rt::TokioExecutor::new();
1296/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1297/// secret,
1298/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1299/// yup_oauth2::client::CustomHyperClientBuilder::from(
1300/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1301/// ),
1302/// ).build().await.unwrap();
1303///
1304/// let client = hyper_util::client::legacy::Client::builder(
1305/// hyper_util::rt::TokioExecutor::new()
1306/// )
1307/// .build(
1308/// hyper_rustls::HttpsConnectorBuilder::new()
1309/// .with_native_roots()
1310/// .unwrap()
1311/// .https_or_http()
1312/// .enable_http2()
1313/// .build()
1314/// );
1315/// let mut hub = Blogger::new(client, auth);
1316/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1317/// // like `approve(...)`, `delete(...)`, `get(...)`, `list(...)`, `list_by_blog(...)`, `mark_as_spam(...)` and `remove_content(...)`
1318/// // to build up your call.
1319/// let rb = hub.comments();
1320/// # }
1321/// ```
1322pub struct CommentMethods<'a, C>
1323where
1324 C: 'a,
1325{
1326 hub: &'a Blogger<C>,
1327}
1328
1329impl<'a, C> common::MethodsBuilder for CommentMethods<'a, C> {}
1330
1331impl<'a, C> CommentMethods<'a, C> {
1332 /// Create a builder to help you perform the following task:
1333 ///
1334 /// Marks a comment as not spam by blog id, post id and comment id.
1335 ///
1336 /// # Arguments
1337 ///
1338 /// * `blogId` - No description provided.
1339 /// * `postId` - No description provided.
1340 /// * `commentId` - No description provided.
1341 pub fn approve(
1342 &self,
1343 blog_id: &str,
1344 post_id: &str,
1345 comment_id: &str,
1346 ) -> CommentApproveCall<'a, C> {
1347 CommentApproveCall {
1348 hub: self.hub,
1349 _blog_id: blog_id.to_string(),
1350 _post_id: post_id.to_string(),
1351 _comment_id: comment_id.to_string(),
1352 _delegate: Default::default(),
1353 _additional_params: Default::default(),
1354 _scopes: Default::default(),
1355 }
1356 }
1357
1358 /// Create a builder to help you perform the following task:
1359 ///
1360 /// Deletes a comment by blog id, post id and comment id.
1361 ///
1362 /// # Arguments
1363 ///
1364 /// * `blogId` - No description provided.
1365 /// * `postId` - No description provided.
1366 /// * `commentId` - No description provided.
1367 pub fn delete(
1368 &self,
1369 blog_id: &str,
1370 post_id: &str,
1371 comment_id: &str,
1372 ) -> CommentDeleteCall<'a, C> {
1373 CommentDeleteCall {
1374 hub: self.hub,
1375 _blog_id: blog_id.to_string(),
1376 _post_id: post_id.to_string(),
1377 _comment_id: comment_id.to_string(),
1378 _delegate: Default::default(),
1379 _additional_params: Default::default(),
1380 _scopes: Default::default(),
1381 }
1382 }
1383
1384 /// Create a builder to help you perform the following task:
1385 ///
1386 /// Gets a comment by id.
1387 ///
1388 /// # Arguments
1389 ///
1390 /// * `blogId` - No description provided.
1391 /// * `postId` - No description provided.
1392 /// * `commentId` - No description provided.
1393 pub fn get(&self, blog_id: &str, post_id: &str, comment_id: &str) -> CommentGetCall<'a, C> {
1394 CommentGetCall {
1395 hub: self.hub,
1396 _blog_id: blog_id.to_string(),
1397 _post_id: post_id.to_string(),
1398 _comment_id: comment_id.to_string(),
1399 _view: Default::default(),
1400 _delegate: Default::default(),
1401 _additional_params: Default::default(),
1402 _scopes: Default::default(),
1403 }
1404 }
1405
1406 /// Create a builder to help you perform the following task:
1407 ///
1408 /// Lists comments.
1409 ///
1410 /// # Arguments
1411 ///
1412 /// * `blogId` - No description provided.
1413 /// * `postId` - No description provided.
1414 pub fn list(&self, blog_id: &str, post_id: &str) -> CommentListCall<'a, C> {
1415 CommentListCall {
1416 hub: self.hub,
1417 _blog_id: blog_id.to_string(),
1418 _post_id: post_id.to_string(),
1419 _view: Default::default(),
1420 _status: Default::default(),
1421 _start_date: Default::default(),
1422 _page_token: Default::default(),
1423 _max_results: Default::default(),
1424 _fetch_bodies: Default::default(),
1425 _end_date: Default::default(),
1426 _delegate: Default::default(),
1427 _additional_params: Default::default(),
1428 _scopes: Default::default(),
1429 }
1430 }
1431
1432 /// Create a builder to help you perform the following task:
1433 ///
1434 /// Lists comments by blog.
1435 ///
1436 /// # Arguments
1437 ///
1438 /// * `blogId` - No description provided.
1439 pub fn list_by_blog(&self, blog_id: &str) -> CommentListByBlogCall<'a, C> {
1440 CommentListByBlogCall {
1441 hub: self.hub,
1442 _blog_id: blog_id.to_string(),
1443 _status: Default::default(),
1444 _start_date: Default::default(),
1445 _page_token: Default::default(),
1446 _max_results: Default::default(),
1447 _fetch_bodies: Default::default(),
1448 _end_date: Default::default(),
1449 _delegate: Default::default(),
1450 _additional_params: Default::default(),
1451 _scopes: Default::default(),
1452 }
1453 }
1454
1455 /// Create a builder to help you perform the following task:
1456 ///
1457 /// Marks a comment as spam by blog id, post id and comment id.
1458 ///
1459 /// # Arguments
1460 ///
1461 /// * `blogId` - No description provided.
1462 /// * `postId` - No description provided.
1463 /// * `commentId` - No description provided.
1464 pub fn mark_as_spam(
1465 &self,
1466 blog_id: &str,
1467 post_id: &str,
1468 comment_id: &str,
1469 ) -> CommentMarkAsSpamCall<'a, C> {
1470 CommentMarkAsSpamCall {
1471 hub: self.hub,
1472 _blog_id: blog_id.to_string(),
1473 _post_id: post_id.to_string(),
1474 _comment_id: comment_id.to_string(),
1475 _delegate: Default::default(),
1476 _additional_params: Default::default(),
1477 _scopes: Default::default(),
1478 }
1479 }
1480
1481 /// Create a builder to help you perform the following task:
1482 ///
1483 /// Removes the content of a comment by blog id, post id and comment id.
1484 ///
1485 /// # Arguments
1486 ///
1487 /// * `blogId` - No description provided.
1488 /// * `postId` - No description provided.
1489 /// * `commentId` - No description provided.
1490 pub fn remove_content(
1491 &self,
1492 blog_id: &str,
1493 post_id: &str,
1494 comment_id: &str,
1495 ) -> CommentRemoveContentCall<'a, C> {
1496 CommentRemoveContentCall {
1497 hub: self.hub,
1498 _blog_id: blog_id.to_string(),
1499 _post_id: post_id.to_string(),
1500 _comment_id: comment_id.to_string(),
1501 _delegate: Default::default(),
1502 _additional_params: Default::default(),
1503 _scopes: Default::default(),
1504 }
1505 }
1506}
1507
1508/// A builder providing access to all methods supported on *pageView* resources.
1509/// It is not used directly, but through the [`Blogger`] hub.
1510///
1511/// # Example
1512///
1513/// Instantiate a resource builder
1514///
1515/// ```test_harness,no_run
1516/// extern crate hyper;
1517/// extern crate hyper_rustls;
1518/// extern crate google_blogger3 as blogger3;
1519///
1520/// # async fn dox() {
1521/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1522///
1523/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1524/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1525/// .with_native_roots()
1526/// .unwrap()
1527/// .https_only()
1528/// .enable_http2()
1529/// .build();
1530///
1531/// let executor = hyper_util::rt::TokioExecutor::new();
1532/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1533/// secret,
1534/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1535/// yup_oauth2::client::CustomHyperClientBuilder::from(
1536/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1537/// ),
1538/// ).build().await.unwrap();
1539///
1540/// let client = hyper_util::client::legacy::Client::builder(
1541/// hyper_util::rt::TokioExecutor::new()
1542/// )
1543/// .build(
1544/// hyper_rustls::HttpsConnectorBuilder::new()
1545/// .with_native_roots()
1546/// .unwrap()
1547/// .https_or_http()
1548/// .enable_http2()
1549/// .build()
1550/// );
1551/// let mut hub = Blogger::new(client, auth);
1552/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1553/// // like `get(...)`
1554/// // to build up your call.
1555/// let rb = hub.page_views();
1556/// # }
1557/// ```
1558pub struct PageViewMethods<'a, C>
1559where
1560 C: 'a,
1561{
1562 hub: &'a Blogger<C>,
1563}
1564
1565impl<'a, C> common::MethodsBuilder for PageViewMethods<'a, C> {}
1566
1567impl<'a, C> PageViewMethods<'a, C> {
1568 /// Create a builder to help you perform the following task:
1569 ///
1570 /// Gets page views by blog id.
1571 ///
1572 /// # Arguments
1573 ///
1574 /// * `blogId` - No description provided.
1575 pub fn get(&self, blog_id: &str) -> PageViewGetCall<'a, C> {
1576 PageViewGetCall {
1577 hub: self.hub,
1578 _blog_id: blog_id.to_string(),
1579 _range: Default::default(),
1580 _delegate: Default::default(),
1581 _additional_params: Default::default(),
1582 _scopes: Default::default(),
1583 }
1584 }
1585}
1586
1587/// A builder providing access to all methods supported on *page* resources.
1588/// It is not used directly, but through the [`Blogger`] hub.
1589///
1590/// # Example
1591///
1592/// Instantiate a resource builder
1593///
1594/// ```test_harness,no_run
1595/// extern crate hyper;
1596/// extern crate hyper_rustls;
1597/// extern crate google_blogger3 as blogger3;
1598///
1599/// # async fn dox() {
1600/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1601///
1602/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1603/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1604/// .with_native_roots()
1605/// .unwrap()
1606/// .https_only()
1607/// .enable_http2()
1608/// .build();
1609///
1610/// let executor = hyper_util::rt::TokioExecutor::new();
1611/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1612/// secret,
1613/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1614/// yup_oauth2::client::CustomHyperClientBuilder::from(
1615/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1616/// ),
1617/// ).build().await.unwrap();
1618///
1619/// let client = hyper_util::client::legacy::Client::builder(
1620/// hyper_util::rt::TokioExecutor::new()
1621/// )
1622/// .build(
1623/// hyper_rustls::HttpsConnectorBuilder::new()
1624/// .with_native_roots()
1625/// .unwrap()
1626/// .https_or_http()
1627/// .enable_http2()
1628/// .build()
1629/// );
1630/// let mut hub = Blogger::new(client, auth);
1631/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1632/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `publish(...)`, `revert(...)` and `update(...)`
1633/// // to build up your call.
1634/// let rb = hub.pages();
1635/// # }
1636/// ```
1637pub struct PageMethods<'a, C>
1638where
1639 C: 'a,
1640{
1641 hub: &'a Blogger<C>,
1642}
1643
1644impl<'a, C> common::MethodsBuilder for PageMethods<'a, C> {}
1645
1646impl<'a, C> PageMethods<'a, C> {
1647 /// Create a builder to help you perform the following task:
1648 ///
1649 /// Deletes a page by blog id and page id.
1650 ///
1651 /// # Arguments
1652 ///
1653 /// * `blogId` - No description provided.
1654 /// * `pageId` - No description provided.
1655 pub fn delete(&self, blog_id: &str, page_id: &str) -> PageDeleteCall<'a, C> {
1656 PageDeleteCall {
1657 hub: self.hub,
1658 _blog_id: blog_id.to_string(),
1659 _page_id: page_id.to_string(),
1660 _use_trash: Default::default(),
1661 _delegate: Default::default(),
1662 _additional_params: Default::default(),
1663 _scopes: Default::default(),
1664 }
1665 }
1666
1667 /// Create a builder to help you perform the following task:
1668 ///
1669 /// Gets a page by blog id and page id.
1670 ///
1671 /// # Arguments
1672 ///
1673 /// * `blogId` - No description provided.
1674 /// * `pageId` - No description provided.
1675 pub fn get(&self, blog_id: &str, page_id: &str) -> PageGetCall<'a, C> {
1676 PageGetCall {
1677 hub: self.hub,
1678 _blog_id: blog_id.to_string(),
1679 _page_id: page_id.to_string(),
1680 _view: Default::default(),
1681 _delegate: Default::default(),
1682 _additional_params: Default::default(),
1683 _scopes: Default::default(),
1684 }
1685 }
1686
1687 /// Create a builder to help you perform the following task:
1688 ///
1689 /// Inserts a page.
1690 ///
1691 /// # Arguments
1692 ///
1693 /// * `request` - No description provided.
1694 /// * `blogId` - No description provided.
1695 pub fn insert(&self, request: Page, blog_id: &str) -> PageInsertCall<'a, C> {
1696 PageInsertCall {
1697 hub: self.hub,
1698 _request: request,
1699 _blog_id: blog_id.to_string(),
1700 _is_draft: Default::default(),
1701 _delegate: Default::default(),
1702 _additional_params: Default::default(),
1703 _scopes: Default::default(),
1704 }
1705 }
1706
1707 /// Create a builder to help you perform the following task:
1708 ///
1709 /// Lists pages.
1710 ///
1711 /// # Arguments
1712 ///
1713 /// * `blogId` - No description provided.
1714 pub fn list(&self, blog_id: &str) -> PageListCall<'a, C> {
1715 PageListCall {
1716 hub: self.hub,
1717 _blog_id: blog_id.to_string(),
1718 _view: Default::default(),
1719 _status: Default::default(),
1720 _page_token: Default::default(),
1721 _max_results: Default::default(),
1722 _fetch_bodies: Default::default(),
1723 _delegate: Default::default(),
1724 _additional_params: Default::default(),
1725 _scopes: Default::default(),
1726 }
1727 }
1728
1729 /// Create a builder to help you perform the following task:
1730 ///
1731 /// Patches a page.
1732 ///
1733 /// # Arguments
1734 ///
1735 /// * `request` - No description provided.
1736 /// * `blogId` - No description provided.
1737 /// * `pageId` - No description provided.
1738 pub fn patch(&self, request: Page, blog_id: &str, page_id: &str) -> PagePatchCall<'a, C> {
1739 PagePatchCall {
1740 hub: self.hub,
1741 _request: request,
1742 _blog_id: blog_id.to_string(),
1743 _page_id: page_id.to_string(),
1744 _revert: Default::default(),
1745 _publish: Default::default(),
1746 _delegate: Default::default(),
1747 _additional_params: Default::default(),
1748 _scopes: Default::default(),
1749 }
1750 }
1751
1752 /// Create a builder to help you perform the following task:
1753 ///
1754 /// Publishes a page.
1755 ///
1756 /// # Arguments
1757 ///
1758 /// * `blogId` - No description provided.
1759 /// * `pageId` - No description provided.
1760 pub fn publish(&self, blog_id: &str, page_id: &str) -> PagePublishCall<'a, C> {
1761 PagePublishCall {
1762 hub: self.hub,
1763 _blog_id: blog_id.to_string(),
1764 _page_id: page_id.to_string(),
1765 _delegate: Default::default(),
1766 _additional_params: Default::default(),
1767 _scopes: Default::default(),
1768 }
1769 }
1770
1771 /// Create a builder to help you perform the following task:
1772 ///
1773 /// Reverts a published or scheduled page to draft state.
1774 ///
1775 /// # Arguments
1776 ///
1777 /// * `blogId` - No description provided.
1778 /// * `pageId` - No description provided.
1779 pub fn revert(&self, blog_id: &str, page_id: &str) -> PageRevertCall<'a, C> {
1780 PageRevertCall {
1781 hub: self.hub,
1782 _blog_id: blog_id.to_string(),
1783 _page_id: page_id.to_string(),
1784 _delegate: Default::default(),
1785 _additional_params: Default::default(),
1786 _scopes: Default::default(),
1787 }
1788 }
1789
1790 /// Create a builder to help you perform the following task:
1791 ///
1792 /// Updates a page by blog id and page id.
1793 ///
1794 /// # Arguments
1795 ///
1796 /// * `request` - No description provided.
1797 /// * `blogId` - No description provided.
1798 /// * `pageId` - No description provided.
1799 pub fn update(&self, request: Page, blog_id: &str, page_id: &str) -> PageUpdateCall<'a, C> {
1800 PageUpdateCall {
1801 hub: self.hub,
1802 _request: request,
1803 _blog_id: blog_id.to_string(),
1804 _page_id: page_id.to_string(),
1805 _revert: Default::default(),
1806 _publish: Default::default(),
1807 _delegate: Default::default(),
1808 _additional_params: Default::default(),
1809 _scopes: Default::default(),
1810 }
1811 }
1812}
1813
1814/// A builder providing access to all methods supported on *postUserInfo* resources.
1815/// It is not used directly, but through the [`Blogger`] hub.
1816///
1817/// # Example
1818///
1819/// Instantiate a resource builder
1820///
1821/// ```test_harness,no_run
1822/// extern crate hyper;
1823/// extern crate hyper_rustls;
1824/// extern crate google_blogger3 as blogger3;
1825///
1826/// # async fn dox() {
1827/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1828///
1829/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1830/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1831/// .with_native_roots()
1832/// .unwrap()
1833/// .https_only()
1834/// .enable_http2()
1835/// .build();
1836///
1837/// let executor = hyper_util::rt::TokioExecutor::new();
1838/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1839/// secret,
1840/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1841/// yup_oauth2::client::CustomHyperClientBuilder::from(
1842/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1843/// ),
1844/// ).build().await.unwrap();
1845///
1846/// let client = hyper_util::client::legacy::Client::builder(
1847/// hyper_util::rt::TokioExecutor::new()
1848/// )
1849/// .build(
1850/// hyper_rustls::HttpsConnectorBuilder::new()
1851/// .with_native_roots()
1852/// .unwrap()
1853/// .https_or_http()
1854/// .enable_http2()
1855/// .build()
1856/// );
1857/// let mut hub = Blogger::new(client, auth);
1858/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1859/// // like `get(...)` and `list(...)`
1860/// // to build up your call.
1861/// let rb = hub.post_user_infos();
1862/// # }
1863/// ```
1864pub struct PostUserInfoMethods<'a, C>
1865where
1866 C: 'a,
1867{
1868 hub: &'a Blogger<C>,
1869}
1870
1871impl<'a, C> common::MethodsBuilder for PostUserInfoMethods<'a, C> {}
1872
1873impl<'a, C> PostUserInfoMethods<'a, C> {
1874 /// Create a builder to help you perform the following task:
1875 ///
1876 /// Gets one post and user info pair, by post_id and user_id.
1877 ///
1878 /// # Arguments
1879 ///
1880 /// * `userId` - No description provided.
1881 /// * `blogId` - No description provided.
1882 /// * `postId` - No description provided.
1883 pub fn get(&self, user_id: &str, blog_id: &str, post_id: &str) -> PostUserInfoGetCall<'a, C> {
1884 PostUserInfoGetCall {
1885 hub: self.hub,
1886 _user_id: user_id.to_string(),
1887 _blog_id: blog_id.to_string(),
1888 _post_id: post_id.to_string(),
1889 _max_comments: Default::default(),
1890 _delegate: Default::default(),
1891 _additional_params: Default::default(),
1892 _scopes: Default::default(),
1893 }
1894 }
1895
1896 /// Create a builder to help you perform the following task:
1897 ///
1898 /// Lists post and user info pairs.
1899 ///
1900 /// # Arguments
1901 ///
1902 /// * `userId` - No description provided.
1903 /// * `blogId` - No description provided.
1904 pub fn list(&self, user_id: &str, blog_id: &str) -> PostUserInfoListCall<'a, C> {
1905 PostUserInfoListCall {
1906 hub: self.hub,
1907 _user_id: user_id.to_string(),
1908 _blog_id: blog_id.to_string(),
1909 _view: Default::default(),
1910 _status: Default::default(),
1911 _start_date: Default::default(),
1912 _page_token: Default::default(),
1913 _order_by: Default::default(),
1914 _max_results: Default::default(),
1915 _labels: Default::default(),
1916 _fetch_bodies: Default::default(),
1917 _end_date: Default::default(),
1918 _delegate: Default::default(),
1919 _additional_params: Default::default(),
1920 _scopes: Default::default(),
1921 }
1922 }
1923}
1924
1925/// A builder providing access to all methods supported on *post* resources.
1926/// It is not used directly, but through the [`Blogger`] hub.
1927///
1928/// # Example
1929///
1930/// Instantiate a resource builder
1931///
1932/// ```test_harness,no_run
1933/// extern crate hyper;
1934/// extern crate hyper_rustls;
1935/// extern crate google_blogger3 as blogger3;
1936///
1937/// # async fn dox() {
1938/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1939///
1940/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1941/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1942/// .with_native_roots()
1943/// .unwrap()
1944/// .https_only()
1945/// .enable_http2()
1946/// .build();
1947///
1948/// let executor = hyper_util::rt::TokioExecutor::new();
1949/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1950/// secret,
1951/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1952/// yup_oauth2::client::CustomHyperClientBuilder::from(
1953/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1954/// ),
1955/// ).build().await.unwrap();
1956///
1957/// let client = hyper_util::client::legacy::Client::builder(
1958/// hyper_util::rt::TokioExecutor::new()
1959/// )
1960/// .build(
1961/// hyper_rustls::HttpsConnectorBuilder::new()
1962/// .with_native_roots()
1963/// .unwrap()
1964/// .https_or_http()
1965/// .enable_http2()
1966/// .build()
1967/// );
1968/// let mut hub = Blogger::new(client, auth);
1969/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1970/// // like `delete(...)`, `get(...)`, `get_by_path(...)`, `insert(...)`, `list(...)`, `patch(...)`, `publish(...)`, `revert(...)`, `search(...)` and `update(...)`
1971/// // to build up your call.
1972/// let rb = hub.posts();
1973/// # }
1974/// ```
1975pub struct PostMethods<'a, C>
1976where
1977 C: 'a,
1978{
1979 hub: &'a Blogger<C>,
1980}
1981
1982impl<'a, C> common::MethodsBuilder for PostMethods<'a, C> {}
1983
1984impl<'a, C> PostMethods<'a, C> {
1985 /// Create a builder to help you perform the following task:
1986 ///
1987 /// Deletes a post by blog id and post id.
1988 ///
1989 /// # Arguments
1990 ///
1991 /// * `blogId` - No description provided.
1992 /// * `postId` - No description provided.
1993 pub fn delete(&self, blog_id: &str, post_id: &str) -> PostDeleteCall<'a, C> {
1994 PostDeleteCall {
1995 hub: self.hub,
1996 _blog_id: blog_id.to_string(),
1997 _post_id: post_id.to_string(),
1998 _use_trash: Default::default(),
1999 _delegate: Default::default(),
2000 _additional_params: Default::default(),
2001 _scopes: Default::default(),
2002 }
2003 }
2004
2005 /// Create a builder to help you perform the following task:
2006 ///
2007 /// Gets a post by blog id and post id
2008 ///
2009 /// # Arguments
2010 ///
2011 /// * `blogId` - No description provided.
2012 /// * `postId` - No description provided.
2013 pub fn get(&self, blog_id: &str, post_id: &str) -> PostGetCall<'a, C> {
2014 PostGetCall {
2015 hub: self.hub,
2016 _blog_id: blog_id.to_string(),
2017 _post_id: post_id.to_string(),
2018 _view: Default::default(),
2019 _max_comments: Default::default(),
2020 _fetch_images: Default::default(),
2021 _fetch_body: Default::default(),
2022 _delegate: Default::default(),
2023 _additional_params: Default::default(),
2024 _scopes: Default::default(),
2025 }
2026 }
2027
2028 /// Create a builder to help you perform the following task:
2029 ///
2030 /// Gets a post by path.
2031 ///
2032 /// # Arguments
2033 ///
2034 /// * `blogId` - No description provided.
2035 /// * `path` - No description provided.
2036 pub fn get_by_path(&self, blog_id: &str, path: &str) -> PostGetByPathCall<'a, C> {
2037 PostGetByPathCall {
2038 hub: self.hub,
2039 _blog_id: blog_id.to_string(),
2040 _path: path.to_string(),
2041 _view: Default::default(),
2042 _max_comments: Default::default(),
2043 _delegate: Default::default(),
2044 _additional_params: Default::default(),
2045 _scopes: Default::default(),
2046 }
2047 }
2048
2049 /// Create a builder to help you perform the following task:
2050 ///
2051 /// Inserts a post.
2052 ///
2053 /// # Arguments
2054 ///
2055 /// * `request` - No description provided.
2056 /// * `blogId` - No description provided.
2057 pub fn insert(&self, request: Post, blog_id: &str) -> PostInsertCall<'a, C> {
2058 PostInsertCall {
2059 hub: self.hub,
2060 _request: request,
2061 _blog_id: blog_id.to_string(),
2062 _is_draft: Default::default(),
2063 _fetch_images: Default::default(),
2064 _fetch_body: Default::default(),
2065 _delegate: Default::default(),
2066 _additional_params: Default::default(),
2067 _scopes: Default::default(),
2068 }
2069 }
2070
2071 /// Create a builder to help you perform the following task:
2072 ///
2073 /// Lists posts.
2074 ///
2075 /// # Arguments
2076 ///
2077 /// * `blogId` - No description provided.
2078 pub fn list(&self, blog_id: &str) -> PostListCall<'a, C> {
2079 PostListCall {
2080 hub: self.hub,
2081 _blog_id: blog_id.to_string(),
2082 _view: Default::default(),
2083 _status: Default::default(),
2084 _start_date: Default::default(),
2085 _sort_option: Default::default(),
2086 _page_token: Default::default(),
2087 _order_by: Default::default(),
2088 _max_results: Default::default(),
2089 _labels: Default::default(),
2090 _fetch_images: Default::default(),
2091 _fetch_bodies: Default::default(),
2092 _end_date: Default::default(),
2093 _delegate: Default::default(),
2094 _additional_params: Default::default(),
2095 _scopes: Default::default(),
2096 }
2097 }
2098
2099 /// Create a builder to help you perform the following task:
2100 ///
2101 /// Patches a post.
2102 ///
2103 /// # Arguments
2104 ///
2105 /// * `request` - No description provided.
2106 /// * `blogId` - No description provided.
2107 /// * `postId` - No description provided.
2108 pub fn patch(&self, request: Post, blog_id: &str, post_id: &str) -> PostPatchCall<'a, C> {
2109 PostPatchCall {
2110 hub: self.hub,
2111 _request: request,
2112 _blog_id: blog_id.to_string(),
2113 _post_id: post_id.to_string(),
2114 _revert: Default::default(),
2115 _publish: Default::default(),
2116 _max_comments: Default::default(),
2117 _fetch_images: Default::default(),
2118 _fetch_body: Default::default(),
2119 _delegate: Default::default(),
2120 _additional_params: Default::default(),
2121 _scopes: Default::default(),
2122 }
2123 }
2124
2125 /// Create a builder to help you perform the following task:
2126 ///
2127 /// Publishes a post.
2128 ///
2129 /// # Arguments
2130 ///
2131 /// * `blogId` - No description provided.
2132 /// * `postId` - No description provided.
2133 pub fn publish(&self, blog_id: &str, post_id: &str) -> PostPublishCall<'a, C> {
2134 PostPublishCall {
2135 hub: self.hub,
2136 _blog_id: blog_id.to_string(),
2137 _post_id: post_id.to_string(),
2138 _publish_date: Default::default(),
2139 _delegate: Default::default(),
2140 _additional_params: Default::default(),
2141 _scopes: Default::default(),
2142 }
2143 }
2144
2145 /// Create a builder to help you perform the following task:
2146 ///
2147 /// Reverts a published or scheduled post to draft state.
2148 ///
2149 /// # Arguments
2150 ///
2151 /// * `blogId` - No description provided.
2152 /// * `postId` - No description provided.
2153 pub fn revert(&self, blog_id: &str, post_id: &str) -> PostRevertCall<'a, C> {
2154 PostRevertCall {
2155 hub: self.hub,
2156 _blog_id: blog_id.to_string(),
2157 _post_id: post_id.to_string(),
2158 _delegate: Default::default(),
2159 _additional_params: Default::default(),
2160 _scopes: Default::default(),
2161 }
2162 }
2163
2164 /// Create a builder to help you perform the following task:
2165 ///
2166 /// Searches for posts matching given query terms in the specified blog.
2167 ///
2168 /// # Arguments
2169 ///
2170 /// * `blogId` - No description provided.
2171 /// * `q` - No description provided.
2172 pub fn search(&self, blog_id: &str, q: &str) -> PostSearchCall<'a, C> {
2173 PostSearchCall {
2174 hub: self.hub,
2175 _blog_id: blog_id.to_string(),
2176 _q: q.to_string(),
2177 _order_by: Default::default(),
2178 _fetch_bodies: Default::default(),
2179 _delegate: Default::default(),
2180 _additional_params: Default::default(),
2181 _scopes: Default::default(),
2182 }
2183 }
2184
2185 /// Create a builder to help you perform the following task:
2186 ///
2187 /// Updates a post by blog id and post id.
2188 ///
2189 /// # Arguments
2190 ///
2191 /// * `request` - No description provided.
2192 /// * `blogId` - No description provided.
2193 /// * `postId` - No description provided.
2194 pub fn update(&self, request: Post, blog_id: &str, post_id: &str) -> PostUpdateCall<'a, C> {
2195 PostUpdateCall {
2196 hub: self.hub,
2197 _request: request,
2198 _blog_id: blog_id.to_string(),
2199 _post_id: post_id.to_string(),
2200 _revert: Default::default(),
2201 _publish: Default::default(),
2202 _max_comments: Default::default(),
2203 _fetch_images: Default::default(),
2204 _fetch_body: Default::default(),
2205 _delegate: Default::default(),
2206 _additional_params: Default::default(),
2207 _scopes: Default::default(),
2208 }
2209 }
2210}
2211
2212/// A builder providing access to all methods supported on *user* resources.
2213/// It is not used directly, but through the [`Blogger`] hub.
2214///
2215/// # Example
2216///
2217/// Instantiate a resource builder
2218///
2219/// ```test_harness,no_run
2220/// extern crate hyper;
2221/// extern crate hyper_rustls;
2222/// extern crate google_blogger3 as blogger3;
2223///
2224/// # async fn dox() {
2225/// use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2226///
2227/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2228/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2229/// .with_native_roots()
2230/// .unwrap()
2231/// .https_only()
2232/// .enable_http2()
2233/// .build();
2234///
2235/// let executor = hyper_util::rt::TokioExecutor::new();
2236/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2237/// secret,
2238/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2239/// yup_oauth2::client::CustomHyperClientBuilder::from(
2240/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2241/// ),
2242/// ).build().await.unwrap();
2243///
2244/// let client = hyper_util::client::legacy::Client::builder(
2245/// hyper_util::rt::TokioExecutor::new()
2246/// )
2247/// .build(
2248/// hyper_rustls::HttpsConnectorBuilder::new()
2249/// .with_native_roots()
2250/// .unwrap()
2251/// .https_or_http()
2252/// .enable_http2()
2253/// .build()
2254/// );
2255/// let mut hub = Blogger::new(client, auth);
2256/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2257/// // like `get(...)`
2258/// // to build up your call.
2259/// let rb = hub.users();
2260/// # }
2261/// ```
2262pub struct UserMethods<'a, C>
2263where
2264 C: 'a,
2265{
2266 hub: &'a Blogger<C>,
2267}
2268
2269impl<'a, C> common::MethodsBuilder for UserMethods<'a, C> {}
2270
2271impl<'a, C> UserMethods<'a, C> {
2272 /// Create a builder to help you perform the following task:
2273 ///
2274 /// Gets one user by user_id.
2275 ///
2276 /// # Arguments
2277 ///
2278 /// * `userId` - No description provided.
2279 pub fn get(&self, user_id: &str) -> UserGetCall<'a, C> {
2280 UserGetCall {
2281 hub: self.hub,
2282 _user_id: user_id.to_string(),
2283 _delegate: Default::default(),
2284 _additional_params: Default::default(),
2285 _scopes: Default::default(),
2286 }
2287 }
2288}
2289
2290// ###################
2291// CallBuilders ###
2292// #################
2293
2294/// Gets one blog and user info pair by blog id and user id.
2295///
2296/// A builder for the *get* method supported by a *blogUserInfo* resource.
2297/// It is not used directly, but through a [`BlogUserInfoMethods`] instance.
2298///
2299/// # Example
2300///
2301/// Instantiate a resource method builder
2302///
2303/// ```test_harness,no_run
2304/// # extern crate hyper;
2305/// # extern crate hyper_rustls;
2306/// # extern crate google_blogger3 as blogger3;
2307/// # async fn dox() {
2308/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2309///
2310/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2311/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2312/// # .with_native_roots()
2313/// # .unwrap()
2314/// # .https_only()
2315/// # .enable_http2()
2316/// # .build();
2317///
2318/// # let executor = hyper_util::rt::TokioExecutor::new();
2319/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2320/// # secret,
2321/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2322/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2323/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2324/// # ),
2325/// # ).build().await.unwrap();
2326///
2327/// # let client = hyper_util::client::legacy::Client::builder(
2328/// # hyper_util::rt::TokioExecutor::new()
2329/// # )
2330/// # .build(
2331/// # hyper_rustls::HttpsConnectorBuilder::new()
2332/// # .with_native_roots()
2333/// # .unwrap()
2334/// # .https_or_http()
2335/// # .enable_http2()
2336/// # .build()
2337/// # );
2338/// # let mut hub = Blogger::new(client, auth);
2339/// // You can configure optional parameters by calling the respective setters at will, and
2340/// // execute the final call using `doit()`.
2341/// // Values shown here are possibly random and not representative !
2342/// let result = hub.blog_user_infos().get("userId", "blogId")
2343/// .max_posts(31)
2344/// .doit().await;
2345/// # }
2346/// ```
2347pub struct BlogUserInfoGetCall<'a, C>
2348where
2349 C: 'a,
2350{
2351 hub: &'a Blogger<C>,
2352 _user_id: String,
2353 _blog_id: String,
2354 _max_posts: Option<u32>,
2355 _delegate: Option<&'a mut dyn common::Delegate>,
2356 _additional_params: HashMap<String, String>,
2357 _scopes: BTreeSet<String>,
2358}
2359
2360impl<'a, C> common::CallBuilder for BlogUserInfoGetCall<'a, C> {}
2361
2362impl<'a, C> BlogUserInfoGetCall<'a, C>
2363where
2364 C: common::Connector,
2365{
2366 /// Perform the operation you have build so far.
2367 pub async fn doit(mut self) -> common::Result<(common::Response, BlogUserInfo)> {
2368 use std::borrow::Cow;
2369 use std::io::{Read, Seek};
2370
2371 use common::{url::Params, ToParts};
2372 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2373
2374 let mut dd = common::DefaultDelegate;
2375 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2376 dlg.begin(common::MethodInfo {
2377 id: "blogger.blogUserInfos.get",
2378 http_method: hyper::Method::GET,
2379 });
2380
2381 for &field in ["alt", "userId", "blogId", "maxPosts"].iter() {
2382 if self._additional_params.contains_key(field) {
2383 dlg.finished(false);
2384 return Err(common::Error::FieldClash(field));
2385 }
2386 }
2387
2388 let mut params = Params::with_capacity(5 + self._additional_params.len());
2389 params.push("userId", self._user_id);
2390 params.push("blogId", self._blog_id);
2391 if let Some(value) = self._max_posts.as_ref() {
2392 params.push("maxPosts", value.to_string());
2393 }
2394
2395 params.extend(self._additional_params.iter());
2396
2397 params.push("alt", "json");
2398 let mut url = self.hub._base_url.clone() + "v3/users/{userId}/blogs/{blogId}";
2399 if self._scopes.is_empty() {
2400 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2401 }
2402
2403 #[allow(clippy::single_element_loop)]
2404 for &(find_this, param_name) in [("{userId}", "userId"), ("{blogId}", "blogId")].iter() {
2405 url = params.uri_replacement(url, param_name, find_this, false);
2406 }
2407 {
2408 let to_remove = ["blogId", "userId"];
2409 params.remove_params(&to_remove);
2410 }
2411
2412 let url = params.parse_with_url(&url);
2413
2414 loop {
2415 let token = match self
2416 .hub
2417 .auth
2418 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2419 .await
2420 {
2421 Ok(token) => token,
2422 Err(e) => match dlg.token(e) {
2423 Ok(token) => token,
2424 Err(e) => {
2425 dlg.finished(false);
2426 return Err(common::Error::MissingToken(e));
2427 }
2428 },
2429 };
2430 let mut req_result = {
2431 let client = &self.hub.client;
2432 dlg.pre_request();
2433 let mut req_builder = hyper::Request::builder()
2434 .method(hyper::Method::GET)
2435 .uri(url.as_str())
2436 .header(USER_AGENT, self.hub._user_agent.clone());
2437
2438 if let Some(token) = token.as_ref() {
2439 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2440 }
2441
2442 let request = req_builder
2443 .header(CONTENT_LENGTH, 0_u64)
2444 .body(common::to_body::<String>(None));
2445
2446 client.request(request.unwrap()).await
2447 };
2448
2449 match req_result {
2450 Err(err) => {
2451 if let common::Retry::After(d) = dlg.http_error(&err) {
2452 sleep(d).await;
2453 continue;
2454 }
2455 dlg.finished(false);
2456 return Err(common::Error::HttpError(err));
2457 }
2458 Ok(res) => {
2459 let (mut parts, body) = res.into_parts();
2460 let mut body = common::Body::new(body);
2461 if !parts.status.is_success() {
2462 let bytes = common::to_bytes(body).await.unwrap_or_default();
2463 let error = serde_json::from_str(&common::to_string(&bytes));
2464 let response = common::to_response(parts, bytes.into());
2465
2466 if let common::Retry::After(d) =
2467 dlg.http_failure(&response, error.as_ref().ok())
2468 {
2469 sleep(d).await;
2470 continue;
2471 }
2472
2473 dlg.finished(false);
2474
2475 return Err(match error {
2476 Ok(value) => common::Error::BadRequest(value),
2477 _ => common::Error::Failure(response),
2478 });
2479 }
2480 let response = {
2481 let bytes = common::to_bytes(body).await.unwrap_or_default();
2482 let encoded = common::to_string(&bytes);
2483 match serde_json::from_str(&encoded) {
2484 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2485 Err(error) => {
2486 dlg.response_json_decode_error(&encoded, &error);
2487 return Err(common::Error::JsonDecodeError(
2488 encoded.to_string(),
2489 error,
2490 ));
2491 }
2492 }
2493 };
2494
2495 dlg.finished(true);
2496 return Ok(response);
2497 }
2498 }
2499 }
2500 }
2501
2502 ///
2503 /// Sets the *user id* path property to the given value.
2504 ///
2505 /// Even though the property as already been set when instantiating this call,
2506 /// we provide this method for API completeness.
2507 pub fn user_id(mut self, new_value: &str) -> BlogUserInfoGetCall<'a, C> {
2508 self._user_id = new_value.to_string();
2509 self
2510 }
2511 ///
2512 /// Sets the *blog id* path property to the given value.
2513 ///
2514 /// Even though the property as already been set when instantiating this call,
2515 /// we provide this method for API completeness.
2516 pub fn blog_id(mut self, new_value: &str) -> BlogUserInfoGetCall<'a, C> {
2517 self._blog_id = new_value.to_string();
2518 self
2519 }
2520 ///
2521 /// Sets the *max posts* query property to the given value.
2522 pub fn max_posts(mut self, new_value: u32) -> BlogUserInfoGetCall<'a, C> {
2523 self._max_posts = Some(new_value);
2524 self
2525 }
2526 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2527 /// while executing the actual API request.
2528 ///
2529 /// ````text
2530 /// It should be used to handle progress information, and to implement a certain level of resilience.
2531 /// ````
2532 ///
2533 /// Sets the *delegate* property to the given value.
2534 pub fn delegate(
2535 mut self,
2536 new_value: &'a mut dyn common::Delegate,
2537 ) -> BlogUserInfoGetCall<'a, C> {
2538 self._delegate = Some(new_value);
2539 self
2540 }
2541
2542 /// Set any additional parameter of the query string used in the request.
2543 /// It should be used to set parameters which are not yet available through their own
2544 /// setters.
2545 ///
2546 /// Please note that this method must not be used to set any of the known parameters
2547 /// which have their own setter method. If done anyway, the request will fail.
2548 ///
2549 /// # Additional Parameters
2550 ///
2551 /// * *$.xgafv* (query-string) - V1 error format.
2552 /// * *access_token* (query-string) - OAuth access token.
2553 /// * *alt* (query-string) - Data format for response.
2554 /// * *callback* (query-string) - JSONP
2555 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2556 /// * *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.
2557 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2558 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2559 /// * *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.
2560 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2561 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2562 pub fn param<T>(mut self, name: T, value: T) -> BlogUserInfoGetCall<'a, C>
2563 where
2564 T: AsRef<str>,
2565 {
2566 self._additional_params
2567 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2568 self
2569 }
2570
2571 /// Identifies the authorization scope for the method you are building.
2572 ///
2573 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2574 /// [`Scope::Readonly`].
2575 ///
2576 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2577 /// tokens for more than one scope.
2578 ///
2579 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2580 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2581 /// sufficient, a read-write scope will do as well.
2582 pub fn add_scope<St>(mut self, scope: St) -> BlogUserInfoGetCall<'a, C>
2583 where
2584 St: AsRef<str>,
2585 {
2586 self._scopes.insert(String::from(scope.as_ref()));
2587 self
2588 }
2589 /// Identifies the authorization scope(s) for the method you are building.
2590 ///
2591 /// See [`Self::add_scope()`] for details.
2592 pub fn add_scopes<I, St>(mut self, scopes: I) -> BlogUserInfoGetCall<'a, C>
2593 where
2594 I: IntoIterator<Item = St>,
2595 St: AsRef<str>,
2596 {
2597 self._scopes
2598 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2599 self
2600 }
2601
2602 /// Removes all scopes, and no default scope will be used either.
2603 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2604 /// for details).
2605 pub fn clear_scopes(mut self) -> BlogUserInfoGetCall<'a, C> {
2606 self._scopes.clear();
2607 self
2608 }
2609}
2610
2611/// Gets a blog by id.
2612///
2613/// A builder for the *get* method supported by a *blog* resource.
2614/// It is not used directly, but through a [`BlogMethods`] instance.
2615///
2616/// # Example
2617///
2618/// Instantiate a resource method builder
2619///
2620/// ```test_harness,no_run
2621/// # extern crate hyper;
2622/// # extern crate hyper_rustls;
2623/// # extern crate google_blogger3 as blogger3;
2624/// # async fn dox() {
2625/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2626///
2627/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2628/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2629/// # .with_native_roots()
2630/// # .unwrap()
2631/// # .https_only()
2632/// # .enable_http2()
2633/// # .build();
2634///
2635/// # let executor = hyper_util::rt::TokioExecutor::new();
2636/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2637/// # secret,
2638/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2639/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2640/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2641/// # ),
2642/// # ).build().await.unwrap();
2643///
2644/// # let client = hyper_util::client::legacy::Client::builder(
2645/// # hyper_util::rt::TokioExecutor::new()
2646/// # )
2647/// # .build(
2648/// # hyper_rustls::HttpsConnectorBuilder::new()
2649/// # .with_native_roots()
2650/// # .unwrap()
2651/// # .https_or_http()
2652/// # .enable_http2()
2653/// # .build()
2654/// # );
2655/// # let mut hub = Blogger::new(client, auth);
2656/// // You can configure optional parameters by calling the respective setters at will, and
2657/// // execute the final call using `doit()`.
2658/// // Values shown here are possibly random and not representative !
2659/// let result = hub.blogs().get("blogId")
2660/// .view("no")
2661/// .max_posts(86)
2662/// .doit().await;
2663/// # }
2664/// ```
2665pub struct BlogGetCall<'a, C>
2666where
2667 C: 'a,
2668{
2669 hub: &'a Blogger<C>,
2670 _blog_id: String,
2671 _view: Option<String>,
2672 _max_posts: Option<u32>,
2673 _delegate: Option<&'a mut dyn common::Delegate>,
2674 _additional_params: HashMap<String, String>,
2675 _scopes: BTreeSet<String>,
2676}
2677
2678impl<'a, C> common::CallBuilder for BlogGetCall<'a, C> {}
2679
2680impl<'a, C> BlogGetCall<'a, C>
2681where
2682 C: common::Connector,
2683{
2684 /// Perform the operation you have build so far.
2685 pub async fn doit(mut self) -> common::Result<(common::Response, Blog)> {
2686 use std::borrow::Cow;
2687 use std::io::{Read, Seek};
2688
2689 use common::{url::Params, ToParts};
2690 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2691
2692 let mut dd = common::DefaultDelegate;
2693 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2694 dlg.begin(common::MethodInfo {
2695 id: "blogger.blogs.get",
2696 http_method: hyper::Method::GET,
2697 });
2698
2699 for &field in ["alt", "blogId", "view", "maxPosts"].iter() {
2700 if self._additional_params.contains_key(field) {
2701 dlg.finished(false);
2702 return Err(common::Error::FieldClash(field));
2703 }
2704 }
2705
2706 let mut params = Params::with_capacity(5 + self._additional_params.len());
2707 params.push("blogId", self._blog_id);
2708 if let Some(value) = self._view.as_ref() {
2709 params.push("view", value);
2710 }
2711 if let Some(value) = self._max_posts.as_ref() {
2712 params.push("maxPosts", value.to_string());
2713 }
2714
2715 params.extend(self._additional_params.iter());
2716
2717 params.push("alt", "json");
2718 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}";
2719 if self._scopes.is_empty() {
2720 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2721 }
2722
2723 #[allow(clippy::single_element_loop)]
2724 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
2725 url = params.uri_replacement(url, param_name, find_this, false);
2726 }
2727 {
2728 let to_remove = ["blogId"];
2729 params.remove_params(&to_remove);
2730 }
2731
2732 let url = params.parse_with_url(&url);
2733
2734 loop {
2735 let token = match self
2736 .hub
2737 .auth
2738 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2739 .await
2740 {
2741 Ok(token) => token,
2742 Err(e) => match dlg.token(e) {
2743 Ok(token) => token,
2744 Err(e) => {
2745 dlg.finished(false);
2746 return Err(common::Error::MissingToken(e));
2747 }
2748 },
2749 };
2750 let mut req_result = {
2751 let client = &self.hub.client;
2752 dlg.pre_request();
2753 let mut req_builder = hyper::Request::builder()
2754 .method(hyper::Method::GET)
2755 .uri(url.as_str())
2756 .header(USER_AGENT, self.hub._user_agent.clone());
2757
2758 if let Some(token) = token.as_ref() {
2759 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2760 }
2761
2762 let request = req_builder
2763 .header(CONTENT_LENGTH, 0_u64)
2764 .body(common::to_body::<String>(None));
2765
2766 client.request(request.unwrap()).await
2767 };
2768
2769 match req_result {
2770 Err(err) => {
2771 if let common::Retry::After(d) = dlg.http_error(&err) {
2772 sleep(d).await;
2773 continue;
2774 }
2775 dlg.finished(false);
2776 return Err(common::Error::HttpError(err));
2777 }
2778 Ok(res) => {
2779 let (mut parts, body) = res.into_parts();
2780 let mut body = common::Body::new(body);
2781 if !parts.status.is_success() {
2782 let bytes = common::to_bytes(body).await.unwrap_or_default();
2783 let error = serde_json::from_str(&common::to_string(&bytes));
2784 let response = common::to_response(parts, bytes.into());
2785
2786 if let common::Retry::After(d) =
2787 dlg.http_failure(&response, error.as_ref().ok())
2788 {
2789 sleep(d).await;
2790 continue;
2791 }
2792
2793 dlg.finished(false);
2794
2795 return Err(match error {
2796 Ok(value) => common::Error::BadRequest(value),
2797 _ => common::Error::Failure(response),
2798 });
2799 }
2800 let response = {
2801 let bytes = common::to_bytes(body).await.unwrap_or_default();
2802 let encoded = common::to_string(&bytes);
2803 match serde_json::from_str(&encoded) {
2804 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2805 Err(error) => {
2806 dlg.response_json_decode_error(&encoded, &error);
2807 return Err(common::Error::JsonDecodeError(
2808 encoded.to_string(),
2809 error,
2810 ));
2811 }
2812 }
2813 };
2814
2815 dlg.finished(true);
2816 return Ok(response);
2817 }
2818 }
2819 }
2820 }
2821
2822 ///
2823 /// Sets the *blog id* path property to the given value.
2824 ///
2825 /// Even though the property as already been set when instantiating this call,
2826 /// we provide this method for API completeness.
2827 pub fn blog_id(mut self, new_value: &str) -> BlogGetCall<'a, C> {
2828 self._blog_id = new_value.to_string();
2829 self
2830 }
2831 ///
2832 /// Sets the *view* query property to the given value.
2833 pub fn view(mut self, new_value: &str) -> BlogGetCall<'a, C> {
2834 self._view = Some(new_value.to_string());
2835 self
2836 }
2837 ///
2838 /// Sets the *max posts* query property to the given value.
2839 pub fn max_posts(mut self, new_value: u32) -> BlogGetCall<'a, C> {
2840 self._max_posts = Some(new_value);
2841 self
2842 }
2843 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2844 /// while executing the actual API request.
2845 ///
2846 /// ````text
2847 /// It should be used to handle progress information, and to implement a certain level of resilience.
2848 /// ````
2849 ///
2850 /// Sets the *delegate* property to the given value.
2851 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BlogGetCall<'a, C> {
2852 self._delegate = Some(new_value);
2853 self
2854 }
2855
2856 /// Set any additional parameter of the query string used in the request.
2857 /// It should be used to set parameters which are not yet available through their own
2858 /// setters.
2859 ///
2860 /// Please note that this method must not be used to set any of the known parameters
2861 /// which have their own setter method. If done anyway, the request will fail.
2862 ///
2863 /// # Additional Parameters
2864 ///
2865 /// * *$.xgafv* (query-string) - V1 error format.
2866 /// * *access_token* (query-string) - OAuth access token.
2867 /// * *alt* (query-string) - Data format for response.
2868 /// * *callback* (query-string) - JSONP
2869 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2870 /// * *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.
2871 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2872 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2873 /// * *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.
2874 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2875 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2876 pub fn param<T>(mut self, name: T, value: T) -> BlogGetCall<'a, C>
2877 where
2878 T: AsRef<str>,
2879 {
2880 self._additional_params
2881 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2882 self
2883 }
2884
2885 /// Identifies the authorization scope for the method you are building.
2886 ///
2887 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2888 /// [`Scope::Readonly`].
2889 ///
2890 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2891 /// tokens for more than one scope.
2892 ///
2893 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2894 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2895 /// sufficient, a read-write scope will do as well.
2896 pub fn add_scope<St>(mut self, scope: St) -> BlogGetCall<'a, C>
2897 where
2898 St: AsRef<str>,
2899 {
2900 self._scopes.insert(String::from(scope.as_ref()));
2901 self
2902 }
2903 /// Identifies the authorization scope(s) for the method you are building.
2904 ///
2905 /// See [`Self::add_scope()`] for details.
2906 pub fn add_scopes<I, St>(mut self, scopes: I) -> BlogGetCall<'a, C>
2907 where
2908 I: IntoIterator<Item = St>,
2909 St: AsRef<str>,
2910 {
2911 self._scopes
2912 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2913 self
2914 }
2915
2916 /// Removes all scopes, and no default scope will be used either.
2917 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2918 /// for details).
2919 pub fn clear_scopes(mut self) -> BlogGetCall<'a, C> {
2920 self._scopes.clear();
2921 self
2922 }
2923}
2924
2925/// Gets a blog by url.
2926///
2927/// A builder for the *getByUrl* method supported by a *blog* resource.
2928/// It is not used directly, but through a [`BlogMethods`] instance.
2929///
2930/// # Example
2931///
2932/// Instantiate a resource method builder
2933///
2934/// ```test_harness,no_run
2935/// # extern crate hyper;
2936/// # extern crate hyper_rustls;
2937/// # extern crate google_blogger3 as blogger3;
2938/// # async fn dox() {
2939/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2940///
2941/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2942/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2943/// # .with_native_roots()
2944/// # .unwrap()
2945/// # .https_only()
2946/// # .enable_http2()
2947/// # .build();
2948///
2949/// # let executor = hyper_util::rt::TokioExecutor::new();
2950/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2951/// # secret,
2952/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2953/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2954/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2955/// # ),
2956/// # ).build().await.unwrap();
2957///
2958/// # let client = hyper_util::client::legacy::Client::builder(
2959/// # hyper_util::rt::TokioExecutor::new()
2960/// # )
2961/// # .build(
2962/// # hyper_rustls::HttpsConnectorBuilder::new()
2963/// # .with_native_roots()
2964/// # .unwrap()
2965/// # .https_or_http()
2966/// # .enable_http2()
2967/// # .build()
2968/// # );
2969/// # let mut hub = Blogger::new(client, auth);
2970/// // You can configure optional parameters by calling the respective setters at will, and
2971/// // execute the final call using `doit()`.
2972/// // Values shown here are possibly random and not representative !
2973/// let result = hub.blogs().get_by_url("url")
2974/// .view("et")
2975/// .doit().await;
2976/// # }
2977/// ```
2978pub struct BlogGetByUrlCall<'a, C>
2979where
2980 C: 'a,
2981{
2982 hub: &'a Blogger<C>,
2983 _url: String,
2984 _view: Option<String>,
2985 _delegate: Option<&'a mut dyn common::Delegate>,
2986 _additional_params: HashMap<String, String>,
2987 _scopes: BTreeSet<String>,
2988}
2989
2990impl<'a, C> common::CallBuilder for BlogGetByUrlCall<'a, C> {}
2991
2992impl<'a, C> BlogGetByUrlCall<'a, C>
2993where
2994 C: common::Connector,
2995{
2996 /// Perform the operation you have build so far.
2997 pub async fn doit(mut self) -> common::Result<(common::Response, Blog)> {
2998 use std::borrow::Cow;
2999 use std::io::{Read, Seek};
3000
3001 use common::{url::Params, ToParts};
3002 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3003
3004 let mut dd = common::DefaultDelegate;
3005 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3006 dlg.begin(common::MethodInfo {
3007 id: "blogger.blogs.getByUrl",
3008 http_method: hyper::Method::GET,
3009 });
3010
3011 for &field in ["alt", "url", "view"].iter() {
3012 if self._additional_params.contains_key(field) {
3013 dlg.finished(false);
3014 return Err(common::Error::FieldClash(field));
3015 }
3016 }
3017
3018 let mut params = Params::with_capacity(4 + self._additional_params.len());
3019 params.push("url", self._url);
3020 if let Some(value) = self._view.as_ref() {
3021 params.push("view", value);
3022 }
3023
3024 params.extend(self._additional_params.iter());
3025
3026 params.push("alt", "json");
3027 let mut url = self.hub._base_url.clone() + "v3/blogs/byurl";
3028 if self._scopes.is_empty() {
3029 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3030 }
3031
3032 let url = params.parse_with_url(&url);
3033
3034 loop {
3035 let token = match self
3036 .hub
3037 .auth
3038 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3039 .await
3040 {
3041 Ok(token) => token,
3042 Err(e) => match dlg.token(e) {
3043 Ok(token) => token,
3044 Err(e) => {
3045 dlg.finished(false);
3046 return Err(common::Error::MissingToken(e));
3047 }
3048 },
3049 };
3050 let mut req_result = {
3051 let client = &self.hub.client;
3052 dlg.pre_request();
3053 let mut req_builder = hyper::Request::builder()
3054 .method(hyper::Method::GET)
3055 .uri(url.as_str())
3056 .header(USER_AGENT, self.hub._user_agent.clone());
3057
3058 if let Some(token) = token.as_ref() {
3059 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3060 }
3061
3062 let request = req_builder
3063 .header(CONTENT_LENGTH, 0_u64)
3064 .body(common::to_body::<String>(None));
3065
3066 client.request(request.unwrap()).await
3067 };
3068
3069 match req_result {
3070 Err(err) => {
3071 if let common::Retry::After(d) = dlg.http_error(&err) {
3072 sleep(d).await;
3073 continue;
3074 }
3075 dlg.finished(false);
3076 return Err(common::Error::HttpError(err));
3077 }
3078 Ok(res) => {
3079 let (mut parts, body) = res.into_parts();
3080 let mut body = common::Body::new(body);
3081 if !parts.status.is_success() {
3082 let bytes = common::to_bytes(body).await.unwrap_or_default();
3083 let error = serde_json::from_str(&common::to_string(&bytes));
3084 let response = common::to_response(parts, bytes.into());
3085
3086 if let common::Retry::After(d) =
3087 dlg.http_failure(&response, error.as_ref().ok())
3088 {
3089 sleep(d).await;
3090 continue;
3091 }
3092
3093 dlg.finished(false);
3094
3095 return Err(match error {
3096 Ok(value) => common::Error::BadRequest(value),
3097 _ => common::Error::Failure(response),
3098 });
3099 }
3100 let response = {
3101 let bytes = common::to_bytes(body).await.unwrap_or_default();
3102 let encoded = common::to_string(&bytes);
3103 match serde_json::from_str(&encoded) {
3104 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3105 Err(error) => {
3106 dlg.response_json_decode_error(&encoded, &error);
3107 return Err(common::Error::JsonDecodeError(
3108 encoded.to_string(),
3109 error,
3110 ));
3111 }
3112 }
3113 };
3114
3115 dlg.finished(true);
3116 return Ok(response);
3117 }
3118 }
3119 }
3120 }
3121
3122 ///
3123 /// Sets the *url* query property to the given value.
3124 ///
3125 /// Even though the property as already been set when instantiating this call,
3126 /// we provide this method for API completeness.
3127 pub fn url(mut self, new_value: &str) -> BlogGetByUrlCall<'a, C> {
3128 self._url = new_value.to_string();
3129 self
3130 }
3131 ///
3132 /// Sets the *view* query property to the given value.
3133 pub fn view(mut self, new_value: &str) -> BlogGetByUrlCall<'a, C> {
3134 self._view = Some(new_value.to_string());
3135 self
3136 }
3137 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3138 /// while executing the actual API request.
3139 ///
3140 /// ````text
3141 /// It should be used to handle progress information, and to implement a certain level of resilience.
3142 /// ````
3143 ///
3144 /// Sets the *delegate* property to the given value.
3145 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BlogGetByUrlCall<'a, C> {
3146 self._delegate = Some(new_value);
3147 self
3148 }
3149
3150 /// Set any additional parameter of the query string used in the request.
3151 /// It should be used to set parameters which are not yet available through their own
3152 /// setters.
3153 ///
3154 /// Please note that this method must not be used to set any of the known parameters
3155 /// which have their own setter method. If done anyway, the request will fail.
3156 ///
3157 /// # Additional Parameters
3158 ///
3159 /// * *$.xgafv* (query-string) - V1 error format.
3160 /// * *access_token* (query-string) - OAuth access token.
3161 /// * *alt* (query-string) - Data format for response.
3162 /// * *callback* (query-string) - JSONP
3163 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3164 /// * *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.
3165 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3166 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3167 /// * *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.
3168 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3169 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3170 pub fn param<T>(mut self, name: T, value: T) -> BlogGetByUrlCall<'a, C>
3171 where
3172 T: AsRef<str>,
3173 {
3174 self._additional_params
3175 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3176 self
3177 }
3178
3179 /// Identifies the authorization scope for the method you are building.
3180 ///
3181 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3182 /// [`Scope::Readonly`].
3183 ///
3184 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3185 /// tokens for more than one scope.
3186 ///
3187 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3188 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3189 /// sufficient, a read-write scope will do as well.
3190 pub fn add_scope<St>(mut self, scope: St) -> BlogGetByUrlCall<'a, C>
3191 where
3192 St: AsRef<str>,
3193 {
3194 self._scopes.insert(String::from(scope.as_ref()));
3195 self
3196 }
3197 /// Identifies the authorization scope(s) for the method you are building.
3198 ///
3199 /// See [`Self::add_scope()`] for details.
3200 pub fn add_scopes<I, St>(mut self, scopes: I) -> BlogGetByUrlCall<'a, C>
3201 where
3202 I: IntoIterator<Item = St>,
3203 St: AsRef<str>,
3204 {
3205 self._scopes
3206 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3207 self
3208 }
3209
3210 /// Removes all scopes, and no default scope will be used either.
3211 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3212 /// for details).
3213 pub fn clear_scopes(mut self) -> BlogGetByUrlCall<'a, C> {
3214 self._scopes.clear();
3215 self
3216 }
3217}
3218
3219/// Lists blogs by user.
3220///
3221/// A builder for the *listByUser* method supported by a *blog* resource.
3222/// It is not used directly, but through a [`BlogMethods`] instance.
3223///
3224/// # Example
3225///
3226/// Instantiate a resource method builder
3227///
3228/// ```test_harness,no_run
3229/// # extern crate hyper;
3230/// # extern crate hyper_rustls;
3231/// # extern crate google_blogger3 as blogger3;
3232/// # async fn dox() {
3233/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3234///
3235/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3236/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3237/// # .with_native_roots()
3238/// # .unwrap()
3239/// # .https_only()
3240/// # .enable_http2()
3241/// # .build();
3242///
3243/// # let executor = hyper_util::rt::TokioExecutor::new();
3244/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3245/// # secret,
3246/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3247/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3248/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3249/// # ),
3250/// # ).build().await.unwrap();
3251///
3252/// # let client = hyper_util::client::legacy::Client::builder(
3253/// # hyper_util::rt::TokioExecutor::new()
3254/// # )
3255/// # .build(
3256/// # hyper_rustls::HttpsConnectorBuilder::new()
3257/// # .with_native_roots()
3258/// # .unwrap()
3259/// # .https_or_http()
3260/// # .enable_http2()
3261/// # .build()
3262/// # );
3263/// # let mut hub = Blogger::new(client, auth);
3264/// // You can configure optional parameters by calling the respective setters at will, and
3265/// // execute the final call using `doit()`.
3266/// // Values shown here are possibly random and not representative !
3267/// let result = hub.blogs().list_by_user("userId")
3268/// .view("et")
3269/// .add_status("et")
3270/// .add_role("vero")
3271/// .fetch_user_info(false)
3272/// .doit().await;
3273/// # }
3274/// ```
3275pub struct BlogListByUserCall<'a, C>
3276where
3277 C: 'a,
3278{
3279 hub: &'a Blogger<C>,
3280 _user_id: String,
3281 _view: Option<String>,
3282 _status: Vec<String>,
3283 _role: Vec<String>,
3284 _fetch_user_info: Option<bool>,
3285 _delegate: Option<&'a mut dyn common::Delegate>,
3286 _additional_params: HashMap<String, String>,
3287 _scopes: BTreeSet<String>,
3288}
3289
3290impl<'a, C> common::CallBuilder for BlogListByUserCall<'a, C> {}
3291
3292impl<'a, C> BlogListByUserCall<'a, C>
3293where
3294 C: common::Connector,
3295{
3296 /// Perform the operation you have build so far.
3297 pub async fn doit(mut self) -> common::Result<(common::Response, BlogList)> {
3298 use std::borrow::Cow;
3299 use std::io::{Read, Seek};
3300
3301 use common::{url::Params, ToParts};
3302 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3303
3304 let mut dd = common::DefaultDelegate;
3305 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3306 dlg.begin(common::MethodInfo {
3307 id: "blogger.blogs.listByUser",
3308 http_method: hyper::Method::GET,
3309 });
3310
3311 for &field in ["alt", "userId", "view", "status", "role", "fetchUserInfo"].iter() {
3312 if self._additional_params.contains_key(field) {
3313 dlg.finished(false);
3314 return Err(common::Error::FieldClash(field));
3315 }
3316 }
3317
3318 let mut params = Params::with_capacity(7 + self._additional_params.len());
3319 params.push("userId", self._user_id);
3320 if let Some(value) = self._view.as_ref() {
3321 params.push("view", value);
3322 }
3323 if !self._status.is_empty() {
3324 for f in self._status.iter() {
3325 params.push("status", f);
3326 }
3327 }
3328 if !self._role.is_empty() {
3329 for f in self._role.iter() {
3330 params.push("role", f);
3331 }
3332 }
3333 if let Some(value) = self._fetch_user_info.as_ref() {
3334 params.push("fetchUserInfo", value.to_string());
3335 }
3336
3337 params.extend(self._additional_params.iter());
3338
3339 params.push("alt", "json");
3340 let mut url = self.hub._base_url.clone() + "v3/users/{userId}/blogs";
3341 if self._scopes.is_empty() {
3342 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3343 }
3344
3345 #[allow(clippy::single_element_loop)]
3346 for &(find_this, param_name) in [("{userId}", "userId")].iter() {
3347 url = params.uri_replacement(url, param_name, find_this, false);
3348 }
3349 {
3350 let to_remove = ["userId"];
3351 params.remove_params(&to_remove);
3352 }
3353
3354 let url = params.parse_with_url(&url);
3355
3356 loop {
3357 let token = match self
3358 .hub
3359 .auth
3360 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3361 .await
3362 {
3363 Ok(token) => token,
3364 Err(e) => match dlg.token(e) {
3365 Ok(token) => token,
3366 Err(e) => {
3367 dlg.finished(false);
3368 return Err(common::Error::MissingToken(e));
3369 }
3370 },
3371 };
3372 let mut req_result = {
3373 let client = &self.hub.client;
3374 dlg.pre_request();
3375 let mut req_builder = hyper::Request::builder()
3376 .method(hyper::Method::GET)
3377 .uri(url.as_str())
3378 .header(USER_AGENT, self.hub._user_agent.clone());
3379
3380 if let Some(token) = token.as_ref() {
3381 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3382 }
3383
3384 let request = req_builder
3385 .header(CONTENT_LENGTH, 0_u64)
3386 .body(common::to_body::<String>(None));
3387
3388 client.request(request.unwrap()).await
3389 };
3390
3391 match req_result {
3392 Err(err) => {
3393 if let common::Retry::After(d) = dlg.http_error(&err) {
3394 sleep(d).await;
3395 continue;
3396 }
3397 dlg.finished(false);
3398 return Err(common::Error::HttpError(err));
3399 }
3400 Ok(res) => {
3401 let (mut parts, body) = res.into_parts();
3402 let mut body = common::Body::new(body);
3403 if !parts.status.is_success() {
3404 let bytes = common::to_bytes(body).await.unwrap_or_default();
3405 let error = serde_json::from_str(&common::to_string(&bytes));
3406 let response = common::to_response(parts, bytes.into());
3407
3408 if let common::Retry::After(d) =
3409 dlg.http_failure(&response, error.as_ref().ok())
3410 {
3411 sleep(d).await;
3412 continue;
3413 }
3414
3415 dlg.finished(false);
3416
3417 return Err(match error {
3418 Ok(value) => common::Error::BadRequest(value),
3419 _ => common::Error::Failure(response),
3420 });
3421 }
3422 let response = {
3423 let bytes = common::to_bytes(body).await.unwrap_or_default();
3424 let encoded = common::to_string(&bytes);
3425 match serde_json::from_str(&encoded) {
3426 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3427 Err(error) => {
3428 dlg.response_json_decode_error(&encoded, &error);
3429 return Err(common::Error::JsonDecodeError(
3430 encoded.to_string(),
3431 error,
3432 ));
3433 }
3434 }
3435 };
3436
3437 dlg.finished(true);
3438 return Ok(response);
3439 }
3440 }
3441 }
3442 }
3443
3444 ///
3445 /// Sets the *user id* path property to the given value.
3446 ///
3447 /// Even though the property as already been set when instantiating this call,
3448 /// we provide this method for API completeness.
3449 pub fn user_id(mut self, new_value: &str) -> BlogListByUserCall<'a, C> {
3450 self._user_id = new_value.to_string();
3451 self
3452 }
3453 ///
3454 /// Sets the *view* query property to the given value.
3455 pub fn view(mut self, new_value: &str) -> BlogListByUserCall<'a, C> {
3456 self._view = Some(new_value.to_string());
3457 self
3458 }
3459 /// Default value of status is LIVE.
3460 ///
3461 /// Append the given value to the *status* query property.
3462 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3463 pub fn add_status(mut self, new_value: &str) -> BlogListByUserCall<'a, C> {
3464 self._status.push(new_value.to_string());
3465 self
3466 }
3467 ///
3468 /// Append the given value to the *role* query property.
3469 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3470 pub fn add_role(mut self, new_value: &str) -> BlogListByUserCall<'a, C> {
3471 self._role.push(new_value.to_string());
3472 self
3473 }
3474 ///
3475 /// Sets the *fetch user info* query property to the given value.
3476 pub fn fetch_user_info(mut self, new_value: bool) -> BlogListByUserCall<'a, C> {
3477 self._fetch_user_info = Some(new_value);
3478 self
3479 }
3480 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3481 /// while executing the actual API request.
3482 ///
3483 /// ````text
3484 /// It should be used to handle progress information, and to implement a certain level of resilience.
3485 /// ````
3486 ///
3487 /// Sets the *delegate* property to the given value.
3488 pub fn delegate(
3489 mut self,
3490 new_value: &'a mut dyn common::Delegate,
3491 ) -> BlogListByUserCall<'a, C> {
3492 self._delegate = Some(new_value);
3493 self
3494 }
3495
3496 /// Set any additional parameter of the query string used in the request.
3497 /// It should be used to set parameters which are not yet available through their own
3498 /// setters.
3499 ///
3500 /// Please note that this method must not be used to set any of the known parameters
3501 /// which have their own setter method. If done anyway, the request will fail.
3502 ///
3503 /// # Additional Parameters
3504 ///
3505 /// * *$.xgafv* (query-string) - V1 error format.
3506 /// * *access_token* (query-string) - OAuth access token.
3507 /// * *alt* (query-string) - Data format for response.
3508 /// * *callback* (query-string) - JSONP
3509 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3510 /// * *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.
3511 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3512 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3513 /// * *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.
3514 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3515 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3516 pub fn param<T>(mut self, name: T, value: T) -> BlogListByUserCall<'a, C>
3517 where
3518 T: AsRef<str>,
3519 {
3520 self._additional_params
3521 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3522 self
3523 }
3524
3525 /// Identifies the authorization scope for the method you are building.
3526 ///
3527 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3528 /// [`Scope::Readonly`].
3529 ///
3530 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3531 /// tokens for more than one scope.
3532 ///
3533 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3534 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3535 /// sufficient, a read-write scope will do as well.
3536 pub fn add_scope<St>(mut self, scope: St) -> BlogListByUserCall<'a, C>
3537 where
3538 St: AsRef<str>,
3539 {
3540 self._scopes.insert(String::from(scope.as_ref()));
3541 self
3542 }
3543 /// Identifies the authorization scope(s) for the method you are building.
3544 ///
3545 /// See [`Self::add_scope()`] for details.
3546 pub fn add_scopes<I, St>(mut self, scopes: I) -> BlogListByUserCall<'a, C>
3547 where
3548 I: IntoIterator<Item = St>,
3549 St: AsRef<str>,
3550 {
3551 self._scopes
3552 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3553 self
3554 }
3555
3556 /// Removes all scopes, and no default scope will be used either.
3557 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3558 /// for details).
3559 pub fn clear_scopes(mut self) -> BlogListByUserCall<'a, C> {
3560 self._scopes.clear();
3561 self
3562 }
3563}
3564
3565/// Marks a comment as not spam by blog id, post id and comment id.
3566///
3567/// A builder for the *approve* method supported by a *comment* resource.
3568/// It is not used directly, but through a [`CommentMethods`] instance.
3569///
3570/// # Example
3571///
3572/// Instantiate a resource method builder
3573///
3574/// ```test_harness,no_run
3575/// # extern crate hyper;
3576/// # extern crate hyper_rustls;
3577/// # extern crate google_blogger3 as blogger3;
3578/// # async fn dox() {
3579/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3580///
3581/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3582/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3583/// # .with_native_roots()
3584/// # .unwrap()
3585/// # .https_only()
3586/// # .enable_http2()
3587/// # .build();
3588///
3589/// # let executor = hyper_util::rt::TokioExecutor::new();
3590/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3591/// # secret,
3592/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3593/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3594/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3595/// # ),
3596/// # ).build().await.unwrap();
3597///
3598/// # let client = hyper_util::client::legacy::Client::builder(
3599/// # hyper_util::rt::TokioExecutor::new()
3600/// # )
3601/// # .build(
3602/// # hyper_rustls::HttpsConnectorBuilder::new()
3603/// # .with_native_roots()
3604/// # .unwrap()
3605/// # .https_or_http()
3606/// # .enable_http2()
3607/// # .build()
3608/// # );
3609/// # let mut hub = Blogger::new(client, auth);
3610/// // You can configure optional parameters by calling the respective setters at will, and
3611/// // execute the final call using `doit()`.
3612/// // Values shown here are possibly random and not representative !
3613/// let result = hub.comments().approve("blogId", "postId", "commentId")
3614/// .doit().await;
3615/// # }
3616/// ```
3617pub struct CommentApproveCall<'a, C>
3618where
3619 C: 'a,
3620{
3621 hub: &'a Blogger<C>,
3622 _blog_id: String,
3623 _post_id: String,
3624 _comment_id: String,
3625 _delegate: Option<&'a mut dyn common::Delegate>,
3626 _additional_params: HashMap<String, String>,
3627 _scopes: BTreeSet<String>,
3628}
3629
3630impl<'a, C> common::CallBuilder for CommentApproveCall<'a, C> {}
3631
3632impl<'a, C> CommentApproveCall<'a, C>
3633where
3634 C: common::Connector,
3635{
3636 /// Perform the operation you have build so far.
3637 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
3638 use std::borrow::Cow;
3639 use std::io::{Read, Seek};
3640
3641 use common::{url::Params, ToParts};
3642 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3643
3644 let mut dd = common::DefaultDelegate;
3645 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3646 dlg.begin(common::MethodInfo {
3647 id: "blogger.comments.approve",
3648 http_method: hyper::Method::POST,
3649 });
3650
3651 for &field in ["alt", "blogId", "postId", "commentId"].iter() {
3652 if self._additional_params.contains_key(field) {
3653 dlg.finished(false);
3654 return Err(common::Error::FieldClash(field));
3655 }
3656 }
3657
3658 let mut params = Params::with_capacity(5 + self._additional_params.len());
3659 params.push("blogId", self._blog_id);
3660 params.push("postId", self._post_id);
3661 params.push("commentId", self._comment_id);
3662
3663 params.extend(self._additional_params.iter());
3664
3665 params.push("alt", "json");
3666 let mut url = self.hub._base_url.clone()
3667 + "v3/blogs/{blogId}/posts/{postId}/comments/{commentId}/approve";
3668 if self._scopes.is_empty() {
3669 self._scopes.insert(Scope::Full.as_ref().to_string());
3670 }
3671
3672 #[allow(clippy::single_element_loop)]
3673 for &(find_this, param_name) in [
3674 ("{blogId}", "blogId"),
3675 ("{postId}", "postId"),
3676 ("{commentId}", "commentId"),
3677 ]
3678 .iter()
3679 {
3680 url = params.uri_replacement(url, param_name, find_this, false);
3681 }
3682 {
3683 let to_remove = ["commentId", "postId", "blogId"];
3684 params.remove_params(&to_remove);
3685 }
3686
3687 let url = params.parse_with_url(&url);
3688
3689 loop {
3690 let token = match self
3691 .hub
3692 .auth
3693 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3694 .await
3695 {
3696 Ok(token) => token,
3697 Err(e) => match dlg.token(e) {
3698 Ok(token) => token,
3699 Err(e) => {
3700 dlg.finished(false);
3701 return Err(common::Error::MissingToken(e));
3702 }
3703 },
3704 };
3705 let mut req_result = {
3706 let client = &self.hub.client;
3707 dlg.pre_request();
3708 let mut req_builder = hyper::Request::builder()
3709 .method(hyper::Method::POST)
3710 .uri(url.as_str())
3711 .header(USER_AGENT, self.hub._user_agent.clone());
3712
3713 if let Some(token) = token.as_ref() {
3714 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3715 }
3716
3717 let request = req_builder
3718 .header(CONTENT_LENGTH, 0_u64)
3719 .body(common::to_body::<String>(None));
3720
3721 client.request(request.unwrap()).await
3722 };
3723
3724 match req_result {
3725 Err(err) => {
3726 if let common::Retry::After(d) = dlg.http_error(&err) {
3727 sleep(d).await;
3728 continue;
3729 }
3730 dlg.finished(false);
3731 return Err(common::Error::HttpError(err));
3732 }
3733 Ok(res) => {
3734 let (mut parts, body) = res.into_parts();
3735 let mut body = common::Body::new(body);
3736 if !parts.status.is_success() {
3737 let bytes = common::to_bytes(body).await.unwrap_or_default();
3738 let error = serde_json::from_str(&common::to_string(&bytes));
3739 let response = common::to_response(parts, bytes.into());
3740
3741 if let common::Retry::After(d) =
3742 dlg.http_failure(&response, error.as_ref().ok())
3743 {
3744 sleep(d).await;
3745 continue;
3746 }
3747
3748 dlg.finished(false);
3749
3750 return Err(match error {
3751 Ok(value) => common::Error::BadRequest(value),
3752 _ => common::Error::Failure(response),
3753 });
3754 }
3755 let response = {
3756 let bytes = common::to_bytes(body).await.unwrap_or_default();
3757 let encoded = common::to_string(&bytes);
3758 match serde_json::from_str(&encoded) {
3759 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3760 Err(error) => {
3761 dlg.response_json_decode_error(&encoded, &error);
3762 return Err(common::Error::JsonDecodeError(
3763 encoded.to_string(),
3764 error,
3765 ));
3766 }
3767 }
3768 };
3769
3770 dlg.finished(true);
3771 return Ok(response);
3772 }
3773 }
3774 }
3775 }
3776
3777 ///
3778 /// Sets the *blog id* path property to the given value.
3779 ///
3780 /// Even though the property as already been set when instantiating this call,
3781 /// we provide this method for API completeness.
3782 pub fn blog_id(mut self, new_value: &str) -> CommentApproveCall<'a, C> {
3783 self._blog_id = new_value.to_string();
3784 self
3785 }
3786 ///
3787 /// Sets the *post id* path property to the given value.
3788 ///
3789 /// Even though the property as already been set when instantiating this call,
3790 /// we provide this method for API completeness.
3791 pub fn post_id(mut self, new_value: &str) -> CommentApproveCall<'a, C> {
3792 self._post_id = new_value.to_string();
3793 self
3794 }
3795 ///
3796 /// Sets the *comment id* path property to the given value.
3797 ///
3798 /// Even though the property as already been set when instantiating this call,
3799 /// we provide this method for API completeness.
3800 pub fn comment_id(mut self, new_value: &str) -> CommentApproveCall<'a, C> {
3801 self._comment_id = new_value.to_string();
3802 self
3803 }
3804 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3805 /// while executing the actual API request.
3806 ///
3807 /// ````text
3808 /// It should be used to handle progress information, and to implement a certain level of resilience.
3809 /// ````
3810 ///
3811 /// Sets the *delegate* property to the given value.
3812 pub fn delegate(
3813 mut self,
3814 new_value: &'a mut dyn common::Delegate,
3815 ) -> CommentApproveCall<'a, C> {
3816 self._delegate = Some(new_value);
3817 self
3818 }
3819
3820 /// Set any additional parameter of the query string used in the request.
3821 /// It should be used to set parameters which are not yet available through their own
3822 /// setters.
3823 ///
3824 /// Please note that this method must not be used to set any of the known parameters
3825 /// which have their own setter method. If done anyway, the request will fail.
3826 ///
3827 /// # Additional Parameters
3828 ///
3829 /// * *$.xgafv* (query-string) - V1 error format.
3830 /// * *access_token* (query-string) - OAuth access token.
3831 /// * *alt* (query-string) - Data format for response.
3832 /// * *callback* (query-string) - JSONP
3833 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3834 /// * *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.
3835 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3836 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3837 /// * *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.
3838 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3839 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3840 pub fn param<T>(mut self, name: T, value: T) -> CommentApproveCall<'a, C>
3841 where
3842 T: AsRef<str>,
3843 {
3844 self._additional_params
3845 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3846 self
3847 }
3848
3849 /// Identifies the authorization scope for the method you are building.
3850 ///
3851 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3852 /// [`Scope::Full`].
3853 ///
3854 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3855 /// tokens for more than one scope.
3856 ///
3857 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3858 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3859 /// sufficient, a read-write scope will do as well.
3860 pub fn add_scope<St>(mut self, scope: St) -> CommentApproveCall<'a, C>
3861 where
3862 St: AsRef<str>,
3863 {
3864 self._scopes.insert(String::from(scope.as_ref()));
3865 self
3866 }
3867 /// Identifies the authorization scope(s) for the method you are building.
3868 ///
3869 /// See [`Self::add_scope()`] for details.
3870 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentApproveCall<'a, C>
3871 where
3872 I: IntoIterator<Item = St>,
3873 St: AsRef<str>,
3874 {
3875 self._scopes
3876 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3877 self
3878 }
3879
3880 /// Removes all scopes, and no default scope will be used either.
3881 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3882 /// for details).
3883 pub fn clear_scopes(mut self) -> CommentApproveCall<'a, C> {
3884 self._scopes.clear();
3885 self
3886 }
3887}
3888
3889/// Deletes a comment by blog id, post id and comment id.
3890///
3891/// A builder for the *delete* method supported by a *comment* resource.
3892/// It is not used directly, but through a [`CommentMethods`] instance.
3893///
3894/// # Example
3895///
3896/// Instantiate a resource method builder
3897///
3898/// ```test_harness,no_run
3899/// # extern crate hyper;
3900/// # extern crate hyper_rustls;
3901/// # extern crate google_blogger3 as blogger3;
3902/// # async fn dox() {
3903/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3904///
3905/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3906/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3907/// # .with_native_roots()
3908/// # .unwrap()
3909/// # .https_only()
3910/// # .enable_http2()
3911/// # .build();
3912///
3913/// # let executor = hyper_util::rt::TokioExecutor::new();
3914/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3915/// # secret,
3916/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3917/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3918/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3919/// # ),
3920/// # ).build().await.unwrap();
3921///
3922/// # let client = hyper_util::client::legacy::Client::builder(
3923/// # hyper_util::rt::TokioExecutor::new()
3924/// # )
3925/// # .build(
3926/// # hyper_rustls::HttpsConnectorBuilder::new()
3927/// # .with_native_roots()
3928/// # .unwrap()
3929/// # .https_or_http()
3930/// # .enable_http2()
3931/// # .build()
3932/// # );
3933/// # let mut hub = Blogger::new(client, auth);
3934/// // You can configure optional parameters by calling the respective setters at will, and
3935/// // execute the final call using `doit()`.
3936/// // Values shown here are possibly random and not representative !
3937/// let result = hub.comments().delete("blogId", "postId", "commentId")
3938/// .doit().await;
3939/// # }
3940/// ```
3941pub struct CommentDeleteCall<'a, C>
3942where
3943 C: 'a,
3944{
3945 hub: &'a Blogger<C>,
3946 _blog_id: String,
3947 _post_id: String,
3948 _comment_id: String,
3949 _delegate: Option<&'a mut dyn common::Delegate>,
3950 _additional_params: HashMap<String, String>,
3951 _scopes: BTreeSet<String>,
3952}
3953
3954impl<'a, C> common::CallBuilder for CommentDeleteCall<'a, C> {}
3955
3956impl<'a, C> CommentDeleteCall<'a, C>
3957where
3958 C: common::Connector,
3959{
3960 /// Perform the operation you have build so far.
3961 pub async fn doit(mut self) -> common::Result<common::Response> {
3962 use std::borrow::Cow;
3963 use std::io::{Read, Seek};
3964
3965 use common::{url::Params, ToParts};
3966 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3967
3968 let mut dd = common::DefaultDelegate;
3969 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3970 dlg.begin(common::MethodInfo {
3971 id: "blogger.comments.delete",
3972 http_method: hyper::Method::DELETE,
3973 });
3974
3975 for &field in ["blogId", "postId", "commentId"].iter() {
3976 if self._additional_params.contains_key(field) {
3977 dlg.finished(false);
3978 return Err(common::Error::FieldClash(field));
3979 }
3980 }
3981
3982 let mut params = Params::with_capacity(4 + self._additional_params.len());
3983 params.push("blogId", self._blog_id);
3984 params.push("postId", self._post_id);
3985 params.push("commentId", self._comment_id);
3986
3987 params.extend(self._additional_params.iter());
3988
3989 let mut url =
3990 self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}/comments/{commentId}";
3991 if self._scopes.is_empty() {
3992 self._scopes.insert(Scope::Full.as_ref().to_string());
3993 }
3994
3995 #[allow(clippy::single_element_loop)]
3996 for &(find_this, param_name) in [
3997 ("{blogId}", "blogId"),
3998 ("{postId}", "postId"),
3999 ("{commentId}", "commentId"),
4000 ]
4001 .iter()
4002 {
4003 url = params.uri_replacement(url, param_name, find_this, false);
4004 }
4005 {
4006 let to_remove = ["commentId", "postId", "blogId"];
4007 params.remove_params(&to_remove);
4008 }
4009
4010 let url = params.parse_with_url(&url);
4011
4012 loop {
4013 let token = match self
4014 .hub
4015 .auth
4016 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4017 .await
4018 {
4019 Ok(token) => token,
4020 Err(e) => match dlg.token(e) {
4021 Ok(token) => token,
4022 Err(e) => {
4023 dlg.finished(false);
4024 return Err(common::Error::MissingToken(e));
4025 }
4026 },
4027 };
4028 let mut req_result = {
4029 let client = &self.hub.client;
4030 dlg.pre_request();
4031 let mut req_builder = hyper::Request::builder()
4032 .method(hyper::Method::DELETE)
4033 .uri(url.as_str())
4034 .header(USER_AGENT, self.hub._user_agent.clone());
4035
4036 if let Some(token) = token.as_ref() {
4037 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4038 }
4039
4040 let request = req_builder
4041 .header(CONTENT_LENGTH, 0_u64)
4042 .body(common::to_body::<String>(None));
4043
4044 client.request(request.unwrap()).await
4045 };
4046
4047 match req_result {
4048 Err(err) => {
4049 if let common::Retry::After(d) = dlg.http_error(&err) {
4050 sleep(d).await;
4051 continue;
4052 }
4053 dlg.finished(false);
4054 return Err(common::Error::HttpError(err));
4055 }
4056 Ok(res) => {
4057 let (mut parts, body) = res.into_parts();
4058 let mut body = common::Body::new(body);
4059 if !parts.status.is_success() {
4060 let bytes = common::to_bytes(body).await.unwrap_or_default();
4061 let error = serde_json::from_str(&common::to_string(&bytes));
4062 let response = common::to_response(parts, bytes.into());
4063
4064 if let common::Retry::After(d) =
4065 dlg.http_failure(&response, error.as_ref().ok())
4066 {
4067 sleep(d).await;
4068 continue;
4069 }
4070
4071 dlg.finished(false);
4072
4073 return Err(match error {
4074 Ok(value) => common::Error::BadRequest(value),
4075 _ => common::Error::Failure(response),
4076 });
4077 }
4078 let response = common::Response::from_parts(parts, body);
4079
4080 dlg.finished(true);
4081 return Ok(response);
4082 }
4083 }
4084 }
4085 }
4086
4087 ///
4088 /// Sets the *blog id* path property to the given value.
4089 ///
4090 /// Even though the property as already been set when instantiating this call,
4091 /// we provide this method for API completeness.
4092 pub fn blog_id(mut self, new_value: &str) -> CommentDeleteCall<'a, C> {
4093 self._blog_id = new_value.to_string();
4094 self
4095 }
4096 ///
4097 /// Sets the *post id* path property to the given value.
4098 ///
4099 /// Even though the property as already been set when instantiating this call,
4100 /// we provide this method for API completeness.
4101 pub fn post_id(mut self, new_value: &str) -> CommentDeleteCall<'a, C> {
4102 self._post_id = new_value.to_string();
4103 self
4104 }
4105 ///
4106 /// Sets the *comment id* path property to the given value.
4107 ///
4108 /// Even though the property as already been set when instantiating this call,
4109 /// we provide this method for API completeness.
4110 pub fn comment_id(mut self, new_value: &str) -> CommentDeleteCall<'a, C> {
4111 self._comment_id = new_value.to_string();
4112 self
4113 }
4114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4115 /// while executing the actual API request.
4116 ///
4117 /// ````text
4118 /// It should be used to handle progress information, and to implement a certain level of resilience.
4119 /// ````
4120 ///
4121 /// Sets the *delegate* property to the given value.
4122 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentDeleteCall<'a, C> {
4123 self._delegate = Some(new_value);
4124 self
4125 }
4126
4127 /// Set any additional parameter of the query string used in the request.
4128 /// It should be used to set parameters which are not yet available through their own
4129 /// setters.
4130 ///
4131 /// Please note that this method must not be used to set any of the known parameters
4132 /// which have their own setter method. If done anyway, the request will fail.
4133 ///
4134 /// # Additional Parameters
4135 ///
4136 /// * *$.xgafv* (query-string) - V1 error format.
4137 /// * *access_token* (query-string) - OAuth access token.
4138 /// * *alt* (query-string) - Data format for response.
4139 /// * *callback* (query-string) - JSONP
4140 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4141 /// * *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.
4142 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4143 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4144 /// * *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.
4145 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4146 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4147 pub fn param<T>(mut self, name: T, value: T) -> CommentDeleteCall<'a, C>
4148 where
4149 T: AsRef<str>,
4150 {
4151 self._additional_params
4152 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4153 self
4154 }
4155
4156 /// Identifies the authorization scope for the method you are building.
4157 ///
4158 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4159 /// [`Scope::Full`].
4160 ///
4161 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4162 /// tokens for more than one scope.
4163 ///
4164 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4165 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4166 /// sufficient, a read-write scope will do as well.
4167 pub fn add_scope<St>(mut self, scope: St) -> CommentDeleteCall<'a, C>
4168 where
4169 St: AsRef<str>,
4170 {
4171 self._scopes.insert(String::from(scope.as_ref()));
4172 self
4173 }
4174 /// Identifies the authorization scope(s) for the method you are building.
4175 ///
4176 /// See [`Self::add_scope()`] for details.
4177 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentDeleteCall<'a, C>
4178 where
4179 I: IntoIterator<Item = St>,
4180 St: AsRef<str>,
4181 {
4182 self._scopes
4183 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4184 self
4185 }
4186
4187 /// Removes all scopes, and no default scope will be used either.
4188 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4189 /// for details).
4190 pub fn clear_scopes(mut self) -> CommentDeleteCall<'a, C> {
4191 self._scopes.clear();
4192 self
4193 }
4194}
4195
4196/// Gets a comment by id.
4197///
4198/// A builder for the *get* method supported by a *comment* resource.
4199/// It is not used directly, but through a [`CommentMethods`] instance.
4200///
4201/// # Example
4202///
4203/// Instantiate a resource method builder
4204///
4205/// ```test_harness,no_run
4206/// # extern crate hyper;
4207/// # extern crate hyper_rustls;
4208/// # extern crate google_blogger3 as blogger3;
4209/// # async fn dox() {
4210/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4211///
4212/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4213/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4214/// # .with_native_roots()
4215/// # .unwrap()
4216/// # .https_only()
4217/// # .enable_http2()
4218/// # .build();
4219///
4220/// # let executor = hyper_util::rt::TokioExecutor::new();
4221/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4222/// # secret,
4223/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4224/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4225/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4226/// # ),
4227/// # ).build().await.unwrap();
4228///
4229/// # let client = hyper_util::client::legacy::Client::builder(
4230/// # hyper_util::rt::TokioExecutor::new()
4231/// # )
4232/// # .build(
4233/// # hyper_rustls::HttpsConnectorBuilder::new()
4234/// # .with_native_roots()
4235/// # .unwrap()
4236/// # .https_or_http()
4237/// # .enable_http2()
4238/// # .build()
4239/// # );
4240/// # let mut hub = Blogger::new(client, auth);
4241/// // You can configure optional parameters by calling the respective setters at will, and
4242/// // execute the final call using `doit()`.
4243/// // Values shown here are possibly random and not representative !
4244/// let result = hub.comments().get("blogId", "postId", "commentId")
4245/// .view("et")
4246/// .doit().await;
4247/// # }
4248/// ```
4249pub struct CommentGetCall<'a, C>
4250where
4251 C: 'a,
4252{
4253 hub: &'a Blogger<C>,
4254 _blog_id: String,
4255 _post_id: String,
4256 _comment_id: String,
4257 _view: Option<String>,
4258 _delegate: Option<&'a mut dyn common::Delegate>,
4259 _additional_params: HashMap<String, String>,
4260 _scopes: BTreeSet<String>,
4261}
4262
4263impl<'a, C> common::CallBuilder for CommentGetCall<'a, C> {}
4264
4265impl<'a, C> CommentGetCall<'a, C>
4266where
4267 C: common::Connector,
4268{
4269 /// Perform the operation you have build so far.
4270 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
4271 use std::borrow::Cow;
4272 use std::io::{Read, Seek};
4273
4274 use common::{url::Params, ToParts};
4275 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4276
4277 let mut dd = common::DefaultDelegate;
4278 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4279 dlg.begin(common::MethodInfo {
4280 id: "blogger.comments.get",
4281 http_method: hyper::Method::GET,
4282 });
4283
4284 for &field in ["alt", "blogId", "postId", "commentId", "view"].iter() {
4285 if self._additional_params.contains_key(field) {
4286 dlg.finished(false);
4287 return Err(common::Error::FieldClash(field));
4288 }
4289 }
4290
4291 let mut params = Params::with_capacity(6 + self._additional_params.len());
4292 params.push("blogId", self._blog_id);
4293 params.push("postId", self._post_id);
4294 params.push("commentId", self._comment_id);
4295 if let Some(value) = self._view.as_ref() {
4296 params.push("view", value);
4297 }
4298
4299 params.extend(self._additional_params.iter());
4300
4301 params.push("alt", "json");
4302 let mut url =
4303 self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}/comments/{commentId}";
4304 if self._scopes.is_empty() {
4305 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4306 }
4307
4308 #[allow(clippy::single_element_loop)]
4309 for &(find_this, param_name) in [
4310 ("{blogId}", "blogId"),
4311 ("{postId}", "postId"),
4312 ("{commentId}", "commentId"),
4313 ]
4314 .iter()
4315 {
4316 url = params.uri_replacement(url, param_name, find_this, false);
4317 }
4318 {
4319 let to_remove = ["commentId", "postId", "blogId"];
4320 params.remove_params(&to_remove);
4321 }
4322
4323 let url = params.parse_with_url(&url);
4324
4325 loop {
4326 let token = match self
4327 .hub
4328 .auth
4329 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4330 .await
4331 {
4332 Ok(token) => token,
4333 Err(e) => match dlg.token(e) {
4334 Ok(token) => token,
4335 Err(e) => {
4336 dlg.finished(false);
4337 return Err(common::Error::MissingToken(e));
4338 }
4339 },
4340 };
4341 let mut req_result = {
4342 let client = &self.hub.client;
4343 dlg.pre_request();
4344 let mut req_builder = hyper::Request::builder()
4345 .method(hyper::Method::GET)
4346 .uri(url.as_str())
4347 .header(USER_AGENT, self.hub._user_agent.clone());
4348
4349 if let Some(token) = token.as_ref() {
4350 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4351 }
4352
4353 let request = req_builder
4354 .header(CONTENT_LENGTH, 0_u64)
4355 .body(common::to_body::<String>(None));
4356
4357 client.request(request.unwrap()).await
4358 };
4359
4360 match req_result {
4361 Err(err) => {
4362 if let common::Retry::After(d) = dlg.http_error(&err) {
4363 sleep(d).await;
4364 continue;
4365 }
4366 dlg.finished(false);
4367 return Err(common::Error::HttpError(err));
4368 }
4369 Ok(res) => {
4370 let (mut parts, body) = res.into_parts();
4371 let mut body = common::Body::new(body);
4372 if !parts.status.is_success() {
4373 let bytes = common::to_bytes(body).await.unwrap_or_default();
4374 let error = serde_json::from_str(&common::to_string(&bytes));
4375 let response = common::to_response(parts, bytes.into());
4376
4377 if let common::Retry::After(d) =
4378 dlg.http_failure(&response, error.as_ref().ok())
4379 {
4380 sleep(d).await;
4381 continue;
4382 }
4383
4384 dlg.finished(false);
4385
4386 return Err(match error {
4387 Ok(value) => common::Error::BadRequest(value),
4388 _ => common::Error::Failure(response),
4389 });
4390 }
4391 let response = {
4392 let bytes = common::to_bytes(body).await.unwrap_or_default();
4393 let encoded = common::to_string(&bytes);
4394 match serde_json::from_str(&encoded) {
4395 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4396 Err(error) => {
4397 dlg.response_json_decode_error(&encoded, &error);
4398 return Err(common::Error::JsonDecodeError(
4399 encoded.to_string(),
4400 error,
4401 ));
4402 }
4403 }
4404 };
4405
4406 dlg.finished(true);
4407 return Ok(response);
4408 }
4409 }
4410 }
4411 }
4412
4413 ///
4414 /// Sets the *blog id* path property to the given value.
4415 ///
4416 /// Even though the property as already been set when instantiating this call,
4417 /// we provide this method for API completeness.
4418 pub fn blog_id(mut self, new_value: &str) -> CommentGetCall<'a, C> {
4419 self._blog_id = new_value.to_string();
4420 self
4421 }
4422 ///
4423 /// Sets the *post id* path property to the given value.
4424 ///
4425 /// Even though the property as already been set when instantiating this call,
4426 /// we provide this method for API completeness.
4427 pub fn post_id(mut self, new_value: &str) -> CommentGetCall<'a, C> {
4428 self._post_id = new_value.to_string();
4429 self
4430 }
4431 ///
4432 /// Sets the *comment id* path property to the given value.
4433 ///
4434 /// Even though the property as already been set when instantiating this call,
4435 /// we provide this method for API completeness.
4436 pub fn comment_id(mut self, new_value: &str) -> CommentGetCall<'a, C> {
4437 self._comment_id = new_value.to_string();
4438 self
4439 }
4440 ///
4441 /// Sets the *view* query property to the given value.
4442 pub fn view(mut self, new_value: &str) -> CommentGetCall<'a, C> {
4443 self._view = Some(new_value.to_string());
4444 self
4445 }
4446 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4447 /// while executing the actual API request.
4448 ///
4449 /// ````text
4450 /// It should be used to handle progress information, and to implement a certain level of resilience.
4451 /// ````
4452 ///
4453 /// Sets the *delegate* property to the given value.
4454 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentGetCall<'a, C> {
4455 self._delegate = Some(new_value);
4456 self
4457 }
4458
4459 /// Set any additional parameter of the query string used in the request.
4460 /// It should be used to set parameters which are not yet available through their own
4461 /// setters.
4462 ///
4463 /// Please note that this method must not be used to set any of the known parameters
4464 /// which have their own setter method. If done anyway, the request will fail.
4465 ///
4466 /// # Additional Parameters
4467 ///
4468 /// * *$.xgafv* (query-string) - V1 error format.
4469 /// * *access_token* (query-string) - OAuth access token.
4470 /// * *alt* (query-string) - Data format for response.
4471 /// * *callback* (query-string) - JSONP
4472 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4473 /// * *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.
4474 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4475 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4476 /// * *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.
4477 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4478 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4479 pub fn param<T>(mut self, name: T, value: T) -> CommentGetCall<'a, C>
4480 where
4481 T: AsRef<str>,
4482 {
4483 self._additional_params
4484 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4485 self
4486 }
4487
4488 /// Identifies the authorization scope for the method you are building.
4489 ///
4490 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4491 /// [`Scope::Readonly`].
4492 ///
4493 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4494 /// tokens for more than one scope.
4495 ///
4496 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4497 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4498 /// sufficient, a read-write scope will do as well.
4499 pub fn add_scope<St>(mut self, scope: St) -> CommentGetCall<'a, C>
4500 where
4501 St: AsRef<str>,
4502 {
4503 self._scopes.insert(String::from(scope.as_ref()));
4504 self
4505 }
4506 /// Identifies the authorization scope(s) for the method you are building.
4507 ///
4508 /// See [`Self::add_scope()`] for details.
4509 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentGetCall<'a, C>
4510 where
4511 I: IntoIterator<Item = St>,
4512 St: AsRef<str>,
4513 {
4514 self._scopes
4515 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4516 self
4517 }
4518
4519 /// Removes all scopes, and no default scope will be used either.
4520 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4521 /// for details).
4522 pub fn clear_scopes(mut self) -> CommentGetCall<'a, C> {
4523 self._scopes.clear();
4524 self
4525 }
4526}
4527
4528/// Lists comments.
4529///
4530/// A builder for the *list* method supported by a *comment* resource.
4531/// It is not used directly, but through a [`CommentMethods`] instance.
4532///
4533/// # Example
4534///
4535/// Instantiate a resource method builder
4536///
4537/// ```test_harness,no_run
4538/// # extern crate hyper;
4539/// # extern crate hyper_rustls;
4540/// # extern crate google_blogger3 as blogger3;
4541/// # async fn dox() {
4542/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4543///
4544/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4545/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4546/// # .with_native_roots()
4547/// # .unwrap()
4548/// # .https_only()
4549/// # .enable_http2()
4550/// # .build();
4551///
4552/// # let executor = hyper_util::rt::TokioExecutor::new();
4553/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4554/// # secret,
4555/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4556/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4557/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4558/// # ),
4559/// # ).build().await.unwrap();
4560///
4561/// # let client = hyper_util::client::legacy::Client::builder(
4562/// # hyper_util::rt::TokioExecutor::new()
4563/// # )
4564/// # .build(
4565/// # hyper_rustls::HttpsConnectorBuilder::new()
4566/// # .with_native_roots()
4567/// # .unwrap()
4568/// # .https_or_http()
4569/// # .enable_http2()
4570/// # .build()
4571/// # );
4572/// # let mut hub = Blogger::new(client, auth);
4573/// // You can configure optional parameters by calling the respective setters at will, and
4574/// // execute the final call using `doit()`.
4575/// // Values shown here are possibly random and not representative !
4576/// let result = hub.comments().list("blogId", "postId")
4577/// .view("dolor")
4578/// .status("duo")
4579/// .start_date("vero")
4580/// .page_token("vero")
4581/// .max_results(13)
4582/// .fetch_bodies(true)
4583/// .end_date("vero")
4584/// .doit().await;
4585/// # }
4586/// ```
4587pub struct CommentListCall<'a, C>
4588where
4589 C: 'a,
4590{
4591 hub: &'a Blogger<C>,
4592 _blog_id: String,
4593 _post_id: String,
4594 _view: Option<String>,
4595 _status: Option<String>,
4596 _start_date: Option<String>,
4597 _page_token: Option<String>,
4598 _max_results: Option<u32>,
4599 _fetch_bodies: Option<bool>,
4600 _end_date: Option<String>,
4601 _delegate: Option<&'a mut dyn common::Delegate>,
4602 _additional_params: HashMap<String, String>,
4603 _scopes: BTreeSet<String>,
4604}
4605
4606impl<'a, C> common::CallBuilder for CommentListCall<'a, C> {}
4607
4608impl<'a, C> CommentListCall<'a, C>
4609where
4610 C: common::Connector,
4611{
4612 /// Perform the operation you have build so far.
4613 pub async fn doit(mut self) -> common::Result<(common::Response, CommentList)> {
4614 use std::borrow::Cow;
4615 use std::io::{Read, Seek};
4616
4617 use common::{url::Params, ToParts};
4618 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4619
4620 let mut dd = common::DefaultDelegate;
4621 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4622 dlg.begin(common::MethodInfo {
4623 id: "blogger.comments.list",
4624 http_method: hyper::Method::GET,
4625 });
4626
4627 for &field in [
4628 "alt",
4629 "blogId",
4630 "postId",
4631 "view",
4632 "status",
4633 "startDate",
4634 "pageToken",
4635 "maxResults",
4636 "fetchBodies",
4637 "endDate",
4638 ]
4639 .iter()
4640 {
4641 if self._additional_params.contains_key(field) {
4642 dlg.finished(false);
4643 return Err(common::Error::FieldClash(field));
4644 }
4645 }
4646
4647 let mut params = Params::with_capacity(11 + self._additional_params.len());
4648 params.push("blogId", self._blog_id);
4649 params.push("postId", self._post_id);
4650 if let Some(value) = self._view.as_ref() {
4651 params.push("view", value);
4652 }
4653 if let Some(value) = self._status.as_ref() {
4654 params.push("status", value);
4655 }
4656 if let Some(value) = self._start_date.as_ref() {
4657 params.push("startDate", value);
4658 }
4659 if let Some(value) = self._page_token.as_ref() {
4660 params.push("pageToken", value);
4661 }
4662 if let Some(value) = self._max_results.as_ref() {
4663 params.push("maxResults", value.to_string());
4664 }
4665 if let Some(value) = self._fetch_bodies.as_ref() {
4666 params.push("fetchBodies", value.to_string());
4667 }
4668 if let Some(value) = self._end_date.as_ref() {
4669 params.push("endDate", value);
4670 }
4671
4672 params.extend(self._additional_params.iter());
4673
4674 params.push("alt", "json");
4675 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}/comments";
4676 if self._scopes.is_empty() {
4677 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4678 }
4679
4680 #[allow(clippy::single_element_loop)]
4681 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{postId}", "postId")].iter() {
4682 url = params.uri_replacement(url, param_name, find_this, false);
4683 }
4684 {
4685 let to_remove = ["postId", "blogId"];
4686 params.remove_params(&to_remove);
4687 }
4688
4689 let url = params.parse_with_url(&url);
4690
4691 loop {
4692 let token = match self
4693 .hub
4694 .auth
4695 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4696 .await
4697 {
4698 Ok(token) => token,
4699 Err(e) => match dlg.token(e) {
4700 Ok(token) => token,
4701 Err(e) => {
4702 dlg.finished(false);
4703 return Err(common::Error::MissingToken(e));
4704 }
4705 },
4706 };
4707 let mut req_result = {
4708 let client = &self.hub.client;
4709 dlg.pre_request();
4710 let mut req_builder = hyper::Request::builder()
4711 .method(hyper::Method::GET)
4712 .uri(url.as_str())
4713 .header(USER_AGENT, self.hub._user_agent.clone());
4714
4715 if let Some(token) = token.as_ref() {
4716 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4717 }
4718
4719 let request = req_builder
4720 .header(CONTENT_LENGTH, 0_u64)
4721 .body(common::to_body::<String>(None));
4722
4723 client.request(request.unwrap()).await
4724 };
4725
4726 match req_result {
4727 Err(err) => {
4728 if let common::Retry::After(d) = dlg.http_error(&err) {
4729 sleep(d).await;
4730 continue;
4731 }
4732 dlg.finished(false);
4733 return Err(common::Error::HttpError(err));
4734 }
4735 Ok(res) => {
4736 let (mut parts, body) = res.into_parts();
4737 let mut body = common::Body::new(body);
4738 if !parts.status.is_success() {
4739 let bytes = common::to_bytes(body).await.unwrap_or_default();
4740 let error = serde_json::from_str(&common::to_string(&bytes));
4741 let response = common::to_response(parts, bytes.into());
4742
4743 if let common::Retry::After(d) =
4744 dlg.http_failure(&response, error.as_ref().ok())
4745 {
4746 sleep(d).await;
4747 continue;
4748 }
4749
4750 dlg.finished(false);
4751
4752 return Err(match error {
4753 Ok(value) => common::Error::BadRequest(value),
4754 _ => common::Error::Failure(response),
4755 });
4756 }
4757 let response = {
4758 let bytes = common::to_bytes(body).await.unwrap_or_default();
4759 let encoded = common::to_string(&bytes);
4760 match serde_json::from_str(&encoded) {
4761 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4762 Err(error) => {
4763 dlg.response_json_decode_error(&encoded, &error);
4764 return Err(common::Error::JsonDecodeError(
4765 encoded.to_string(),
4766 error,
4767 ));
4768 }
4769 }
4770 };
4771
4772 dlg.finished(true);
4773 return Ok(response);
4774 }
4775 }
4776 }
4777 }
4778
4779 ///
4780 /// Sets the *blog id* path property to the given value.
4781 ///
4782 /// Even though the property as already been set when instantiating this call,
4783 /// we provide this method for API completeness.
4784 pub fn blog_id(mut self, new_value: &str) -> CommentListCall<'a, C> {
4785 self._blog_id = new_value.to_string();
4786 self
4787 }
4788 ///
4789 /// Sets the *post id* path property to the given value.
4790 ///
4791 /// Even though the property as already been set when instantiating this call,
4792 /// we provide this method for API completeness.
4793 pub fn post_id(mut self, new_value: &str) -> CommentListCall<'a, C> {
4794 self._post_id = new_value.to_string();
4795 self
4796 }
4797 ///
4798 /// Sets the *view* query property to the given value.
4799 pub fn view(mut self, new_value: &str) -> CommentListCall<'a, C> {
4800 self._view = Some(new_value.to_string());
4801 self
4802 }
4803 ///
4804 /// Sets the *status* query property to the given value.
4805 pub fn status(mut self, new_value: &str) -> CommentListCall<'a, C> {
4806 self._status = Some(new_value.to_string());
4807 self
4808 }
4809 ///
4810 /// Sets the *start date* query property to the given value.
4811 pub fn start_date(mut self, new_value: &str) -> CommentListCall<'a, C> {
4812 self._start_date = Some(new_value.to_string());
4813 self
4814 }
4815 ///
4816 /// Sets the *page token* query property to the given value.
4817 pub fn page_token(mut self, new_value: &str) -> CommentListCall<'a, C> {
4818 self._page_token = Some(new_value.to_string());
4819 self
4820 }
4821 ///
4822 /// Sets the *max results* query property to the given value.
4823 pub fn max_results(mut self, new_value: u32) -> CommentListCall<'a, C> {
4824 self._max_results = Some(new_value);
4825 self
4826 }
4827 ///
4828 /// Sets the *fetch bodies* query property to the given value.
4829 pub fn fetch_bodies(mut self, new_value: bool) -> CommentListCall<'a, C> {
4830 self._fetch_bodies = Some(new_value);
4831 self
4832 }
4833 ///
4834 /// Sets the *end date* query property to the given value.
4835 pub fn end_date(mut self, new_value: &str) -> CommentListCall<'a, C> {
4836 self._end_date = Some(new_value.to_string());
4837 self
4838 }
4839 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4840 /// while executing the actual API request.
4841 ///
4842 /// ````text
4843 /// It should be used to handle progress information, and to implement a certain level of resilience.
4844 /// ````
4845 ///
4846 /// Sets the *delegate* property to the given value.
4847 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CommentListCall<'a, C> {
4848 self._delegate = Some(new_value);
4849 self
4850 }
4851
4852 /// Set any additional parameter of the query string used in the request.
4853 /// It should be used to set parameters which are not yet available through their own
4854 /// setters.
4855 ///
4856 /// Please note that this method must not be used to set any of the known parameters
4857 /// which have their own setter method. If done anyway, the request will fail.
4858 ///
4859 /// # Additional Parameters
4860 ///
4861 /// * *$.xgafv* (query-string) - V1 error format.
4862 /// * *access_token* (query-string) - OAuth access token.
4863 /// * *alt* (query-string) - Data format for response.
4864 /// * *callback* (query-string) - JSONP
4865 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4866 /// * *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.
4867 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4868 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4869 /// * *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.
4870 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4871 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4872 pub fn param<T>(mut self, name: T, value: T) -> CommentListCall<'a, C>
4873 where
4874 T: AsRef<str>,
4875 {
4876 self._additional_params
4877 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4878 self
4879 }
4880
4881 /// Identifies the authorization scope for the method you are building.
4882 ///
4883 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4884 /// [`Scope::Readonly`].
4885 ///
4886 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4887 /// tokens for more than one scope.
4888 ///
4889 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4890 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4891 /// sufficient, a read-write scope will do as well.
4892 pub fn add_scope<St>(mut self, scope: St) -> CommentListCall<'a, C>
4893 where
4894 St: AsRef<str>,
4895 {
4896 self._scopes.insert(String::from(scope.as_ref()));
4897 self
4898 }
4899 /// Identifies the authorization scope(s) for the method you are building.
4900 ///
4901 /// See [`Self::add_scope()`] for details.
4902 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentListCall<'a, C>
4903 where
4904 I: IntoIterator<Item = St>,
4905 St: AsRef<str>,
4906 {
4907 self._scopes
4908 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4909 self
4910 }
4911
4912 /// Removes all scopes, and no default scope will be used either.
4913 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4914 /// for details).
4915 pub fn clear_scopes(mut self) -> CommentListCall<'a, C> {
4916 self._scopes.clear();
4917 self
4918 }
4919}
4920
4921/// Lists comments by blog.
4922///
4923/// A builder for the *listByBlog* method supported by a *comment* resource.
4924/// It is not used directly, but through a [`CommentMethods`] instance.
4925///
4926/// # Example
4927///
4928/// Instantiate a resource method builder
4929///
4930/// ```test_harness,no_run
4931/// # extern crate hyper;
4932/// # extern crate hyper_rustls;
4933/// # extern crate google_blogger3 as blogger3;
4934/// # async fn dox() {
4935/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4936///
4937/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4938/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4939/// # .with_native_roots()
4940/// # .unwrap()
4941/// # .https_only()
4942/// # .enable_http2()
4943/// # .build();
4944///
4945/// # let executor = hyper_util::rt::TokioExecutor::new();
4946/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4947/// # secret,
4948/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4949/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4950/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4951/// # ),
4952/// # ).build().await.unwrap();
4953///
4954/// # let client = hyper_util::client::legacy::Client::builder(
4955/// # hyper_util::rt::TokioExecutor::new()
4956/// # )
4957/// # .build(
4958/// # hyper_rustls::HttpsConnectorBuilder::new()
4959/// # .with_native_roots()
4960/// # .unwrap()
4961/// # .https_or_http()
4962/// # .enable_http2()
4963/// # .build()
4964/// # );
4965/// # let mut hub = Blogger::new(client, auth);
4966/// // You can configure optional parameters by calling the respective setters at will, and
4967/// // execute the final call using `doit()`.
4968/// // Values shown here are possibly random and not representative !
4969/// let result = hub.comments().list_by_blog("blogId")
4970/// .add_status("Lorem")
4971/// .start_date("diam")
4972/// .page_token("no")
4973/// .max_results(1)
4974/// .fetch_bodies(true)
4975/// .end_date("consetetur")
4976/// .doit().await;
4977/// # }
4978/// ```
4979pub struct CommentListByBlogCall<'a, C>
4980where
4981 C: 'a,
4982{
4983 hub: &'a Blogger<C>,
4984 _blog_id: String,
4985 _status: Vec<String>,
4986 _start_date: Option<String>,
4987 _page_token: Option<String>,
4988 _max_results: Option<u32>,
4989 _fetch_bodies: Option<bool>,
4990 _end_date: Option<String>,
4991 _delegate: Option<&'a mut dyn common::Delegate>,
4992 _additional_params: HashMap<String, String>,
4993 _scopes: BTreeSet<String>,
4994}
4995
4996impl<'a, C> common::CallBuilder for CommentListByBlogCall<'a, C> {}
4997
4998impl<'a, C> CommentListByBlogCall<'a, C>
4999where
5000 C: common::Connector,
5001{
5002 /// Perform the operation you have build so far.
5003 pub async fn doit(mut self) -> common::Result<(common::Response, CommentList)> {
5004 use std::borrow::Cow;
5005 use std::io::{Read, Seek};
5006
5007 use common::{url::Params, ToParts};
5008 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5009
5010 let mut dd = common::DefaultDelegate;
5011 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5012 dlg.begin(common::MethodInfo {
5013 id: "blogger.comments.listByBlog",
5014 http_method: hyper::Method::GET,
5015 });
5016
5017 for &field in [
5018 "alt",
5019 "blogId",
5020 "status",
5021 "startDate",
5022 "pageToken",
5023 "maxResults",
5024 "fetchBodies",
5025 "endDate",
5026 ]
5027 .iter()
5028 {
5029 if self._additional_params.contains_key(field) {
5030 dlg.finished(false);
5031 return Err(common::Error::FieldClash(field));
5032 }
5033 }
5034
5035 let mut params = Params::with_capacity(9 + self._additional_params.len());
5036 params.push("blogId", self._blog_id);
5037 if !self._status.is_empty() {
5038 for f in self._status.iter() {
5039 params.push("status", f);
5040 }
5041 }
5042 if let Some(value) = self._start_date.as_ref() {
5043 params.push("startDate", value);
5044 }
5045 if let Some(value) = self._page_token.as_ref() {
5046 params.push("pageToken", value);
5047 }
5048 if let Some(value) = self._max_results.as_ref() {
5049 params.push("maxResults", value.to_string());
5050 }
5051 if let Some(value) = self._fetch_bodies.as_ref() {
5052 params.push("fetchBodies", value.to_string());
5053 }
5054 if let Some(value) = self._end_date.as_ref() {
5055 params.push("endDate", value);
5056 }
5057
5058 params.extend(self._additional_params.iter());
5059
5060 params.push("alt", "json");
5061 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/comments";
5062 if self._scopes.is_empty() {
5063 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5064 }
5065
5066 #[allow(clippy::single_element_loop)]
5067 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
5068 url = params.uri_replacement(url, param_name, find_this, false);
5069 }
5070 {
5071 let to_remove = ["blogId"];
5072 params.remove_params(&to_remove);
5073 }
5074
5075 let url = params.parse_with_url(&url);
5076
5077 loop {
5078 let token = match self
5079 .hub
5080 .auth
5081 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5082 .await
5083 {
5084 Ok(token) => token,
5085 Err(e) => match dlg.token(e) {
5086 Ok(token) => token,
5087 Err(e) => {
5088 dlg.finished(false);
5089 return Err(common::Error::MissingToken(e));
5090 }
5091 },
5092 };
5093 let mut req_result = {
5094 let client = &self.hub.client;
5095 dlg.pre_request();
5096 let mut req_builder = hyper::Request::builder()
5097 .method(hyper::Method::GET)
5098 .uri(url.as_str())
5099 .header(USER_AGENT, self.hub._user_agent.clone());
5100
5101 if let Some(token) = token.as_ref() {
5102 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5103 }
5104
5105 let request = req_builder
5106 .header(CONTENT_LENGTH, 0_u64)
5107 .body(common::to_body::<String>(None));
5108
5109 client.request(request.unwrap()).await
5110 };
5111
5112 match req_result {
5113 Err(err) => {
5114 if let common::Retry::After(d) = dlg.http_error(&err) {
5115 sleep(d).await;
5116 continue;
5117 }
5118 dlg.finished(false);
5119 return Err(common::Error::HttpError(err));
5120 }
5121 Ok(res) => {
5122 let (mut parts, body) = res.into_parts();
5123 let mut body = common::Body::new(body);
5124 if !parts.status.is_success() {
5125 let bytes = common::to_bytes(body).await.unwrap_or_default();
5126 let error = serde_json::from_str(&common::to_string(&bytes));
5127 let response = common::to_response(parts, bytes.into());
5128
5129 if let common::Retry::After(d) =
5130 dlg.http_failure(&response, error.as_ref().ok())
5131 {
5132 sleep(d).await;
5133 continue;
5134 }
5135
5136 dlg.finished(false);
5137
5138 return Err(match error {
5139 Ok(value) => common::Error::BadRequest(value),
5140 _ => common::Error::Failure(response),
5141 });
5142 }
5143 let response = {
5144 let bytes = common::to_bytes(body).await.unwrap_or_default();
5145 let encoded = common::to_string(&bytes);
5146 match serde_json::from_str(&encoded) {
5147 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5148 Err(error) => {
5149 dlg.response_json_decode_error(&encoded, &error);
5150 return Err(common::Error::JsonDecodeError(
5151 encoded.to_string(),
5152 error,
5153 ));
5154 }
5155 }
5156 };
5157
5158 dlg.finished(true);
5159 return Ok(response);
5160 }
5161 }
5162 }
5163 }
5164
5165 ///
5166 /// Sets the *blog id* path property to the given value.
5167 ///
5168 /// Even though the property as already been set when instantiating this call,
5169 /// we provide this method for API completeness.
5170 pub fn blog_id(mut self, new_value: &str) -> CommentListByBlogCall<'a, C> {
5171 self._blog_id = new_value.to_string();
5172 self
5173 }
5174 ///
5175 /// Append the given value to the *status* query property.
5176 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5177 pub fn add_status(mut self, new_value: &str) -> CommentListByBlogCall<'a, C> {
5178 self._status.push(new_value.to_string());
5179 self
5180 }
5181 ///
5182 /// Sets the *start date* query property to the given value.
5183 pub fn start_date(mut self, new_value: &str) -> CommentListByBlogCall<'a, C> {
5184 self._start_date = Some(new_value.to_string());
5185 self
5186 }
5187 ///
5188 /// Sets the *page token* query property to the given value.
5189 pub fn page_token(mut self, new_value: &str) -> CommentListByBlogCall<'a, C> {
5190 self._page_token = Some(new_value.to_string());
5191 self
5192 }
5193 ///
5194 /// Sets the *max results* query property to the given value.
5195 pub fn max_results(mut self, new_value: u32) -> CommentListByBlogCall<'a, C> {
5196 self._max_results = Some(new_value);
5197 self
5198 }
5199 ///
5200 /// Sets the *fetch bodies* query property to the given value.
5201 pub fn fetch_bodies(mut self, new_value: bool) -> CommentListByBlogCall<'a, C> {
5202 self._fetch_bodies = Some(new_value);
5203 self
5204 }
5205 ///
5206 /// Sets the *end date* query property to the given value.
5207 pub fn end_date(mut self, new_value: &str) -> CommentListByBlogCall<'a, C> {
5208 self._end_date = Some(new_value.to_string());
5209 self
5210 }
5211 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5212 /// while executing the actual API request.
5213 ///
5214 /// ````text
5215 /// It should be used to handle progress information, and to implement a certain level of resilience.
5216 /// ````
5217 ///
5218 /// Sets the *delegate* property to the given value.
5219 pub fn delegate(
5220 mut self,
5221 new_value: &'a mut dyn common::Delegate,
5222 ) -> CommentListByBlogCall<'a, C> {
5223 self._delegate = Some(new_value);
5224 self
5225 }
5226
5227 /// Set any additional parameter of the query string used in the request.
5228 /// It should be used to set parameters which are not yet available through their own
5229 /// setters.
5230 ///
5231 /// Please note that this method must not be used to set any of the known parameters
5232 /// which have their own setter method. If done anyway, the request will fail.
5233 ///
5234 /// # Additional Parameters
5235 ///
5236 /// * *$.xgafv* (query-string) - V1 error format.
5237 /// * *access_token* (query-string) - OAuth access token.
5238 /// * *alt* (query-string) - Data format for response.
5239 /// * *callback* (query-string) - JSONP
5240 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5241 /// * *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.
5242 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5243 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5244 /// * *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.
5245 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5246 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5247 pub fn param<T>(mut self, name: T, value: T) -> CommentListByBlogCall<'a, C>
5248 where
5249 T: AsRef<str>,
5250 {
5251 self._additional_params
5252 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5253 self
5254 }
5255
5256 /// Identifies the authorization scope for the method you are building.
5257 ///
5258 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5259 /// [`Scope::Readonly`].
5260 ///
5261 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5262 /// tokens for more than one scope.
5263 ///
5264 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5265 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5266 /// sufficient, a read-write scope will do as well.
5267 pub fn add_scope<St>(mut self, scope: St) -> CommentListByBlogCall<'a, C>
5268 where
5269 St: AsRef<str>,
5270 {
5271 self._scopes.insert(String::from(scope.as_ref()));
5272 self
5273 }
5274 /// Identifies the authorization scope(s) for the method you are building.
5275 ///
5276 /// See [`Self::add_scope()`] for details.
5277 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentListByBlogCall<'a, C>
5278 where
5279 I: IntoIterator<Item = St>,
5280 St: AsRef<str>,
5281 {
5282 self._scopes
5283 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5284 self
5285 }
5286
5287 /// Removes all scopes, and no default scope will be used either.
5288 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5289 /// for details).
5290 pub fn clear_scopes(mut self) -> CommentListByBlogCall<'a, C> {
5291 self._scopes.clear();
5292 self
5293 }
5294}
5295
5296/// Marks a comment as spam by blog id, post id and comment id.
5297///
5298/// A builder for the *markAsSpam* method supported by a *comment* resource.
5299/// It is not used directly, but through a [`CommentMethods`] instance.
5300///
5301/// # Example
5302///
5303/// Instantiate a resource method builder
5304///
5305/// ```test_harness,no_run
5306/// # extern crate hyper;
5307/// # extern crate hyper_rustls;
5308/// # extern crate google_blogger3 as blogger3;
5309/// # async fn dox() {
5310/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5311///
5312/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5313/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5314/// # .with_native_roots()
5315/// # .unwrap()
5316/// # .https_only()
5317/// # .enable_http2()
5318/// # .build();
5319///
5320/// # let executor = hyper_util::rt::TokioExecutor::new();
5321/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5322/// # secret,
5323/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5324/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5325/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5326/// # ),
5327/// # ).build().await.unwrap();
5328///
5329/// # let client = hyper_util::client::legacy::Client::builder(
5330/// # hyper_util::rt::TokioExecutor::new()
5331/// # )
5332/// # .build(
5333/// # hyper_rustls::HttpsConnectorBuilder::new()
5334/// # .with_native_roots()
5335/// # .unwrap()
5336/// # .https_or_http()
5337/// # .enable_http2()
5338/// # .build()
5339/// # );
5340/// # let mut hub = Blogger::new(client, auth);
5341/// // You can configure optional parameters by calling the respective setters at will, and
5342/// // execute the final call using `doit()`.
5343/// // Values shown here are possibly random and not representative !
5344/// let result = hub.comments().mark_as_spam("blogId", "postId", "commentId")
5345/// .doit().await;
5346/// # }
5347/// ```
5348pub struct CommentMarkAsSpamCall<'a, C>
5349where
5350 C: 'a,
5351{
5352 hub: &'a Blogger<C>,
5353 _blog_id: String,
5354 _post_id: String,
5355 _comment_id: String,
5356 _delegate: Option<&'a mut dyn common::Delegate>,
5357 _additional_params: HashMap<String, String>,
5358 _scopes: BTreeSet<String>,
5359}
5360
5361impl<'a, C> common::CallBuilder for CommentMarkAsSpamCall<'a, C> {}
5362
5363impl<'a, C> CommentMarkAsSpamCall<'a, C>
5364where
5365 C: common::Connector,
5366{
5367 /// Perform the operation you have build so far.
5368 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
5369 use std::borrow::Cow;
5370 use std::io::{Read, Seek};
5371
5372 use common::{url::Params, ToParts};
5373 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5374
5375 let mut dd = common::DefaultDelegate;
5376 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5377 dlg.begin(common::MethodInfo {
5378 id: "blogger.comments.markAsSpam",
5379 http_method: hyper::Method::POST,
5380 });
5381
5382 for &field in ["alt", "blogId", "postId", "commentId"].iter() {
5383 if self._additional_params.contains_key(field) {
5384 dlg.finished(false);
5385 return Err(common::Error::FieldClash(field));
5386 }
5387 }
5388
5389 let mut params = Params::with_capacity(5 + self._additional_params.len());
5390 params.push("blogId", self._blog_id);
5391 params.push("postId", self._post_id);
5392 params.push("commentId", self._comment_id);
5393
5394 params.extend(self._additional_params.iter());
5395
5396 params.push("alt", "json");
5397 let mut url = self.hub._base_url.clone()
5398 + "v3/blogs/{blogId}/posts/{postId}/comments/{commentId}/spam";
5399 if self._scopes.is_empty() {
5400 self._scopes.insert(Scope::Full.as_ref().to_string());
5401 }
5402
5403 #[allow(clippy::single_element_loop)]
5404 for &(find_this, param_name) in [
5405 ("{blogId}", "blogId"),
5406 ("{postId}", "postId"),
5407 ("{commentId}", "commentId"),
5408 ]
5409 .iter()
5410 {
5411 url = params.uri_replacement(url, param_name, find_this, false);
5412 }
5413 {
5414 let to_remove = ["commentId", "postId", "blogId"];
5415 params.remove_params(&to_remove);
5416 }
5417
5418 let url = params.parse_with_url(&url);
5419
5420 loop {
5421 let token = match self
5422 .hub
5423 .auth
5424 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5425 .await
5426 {
5427 Ok(token) => token,
5428 Err(e) => match dlg.token(e) {
5429 Ok(token) => token,
5430 Err(e) => {
5431 dlg.finished(false);
5432 return Err(common::Error::MissingToken(e));
5433 }
5434 },
5435 };
5436 let mut req_result = {
5437 let client = &self.hub.client;
5438 dlg.pre_request();
5439 let mut req_builder = hyper::Request::builder()
5440 .method(hyper::Method::POST)
5441 .uri(url.as_str())
5442 .header(USER_AGENT, self.hub._user_agent.clone());
5443
5444 if let Some(token) = token.as_ref() {
5445 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5446 }
5447
5448 let request = req_builder
5449 .header(CONTENT_LENGTH, 0_u64)
5450 .body(common::to_body::<String>(None));
5451
5452 client.request(request.unwrap()).await
5453 };
5454
5455 match req_result {
5456 Err(err) => {
5457 if let common::Retry::After(d) = dlg.http_error(&err) {
5458 sleep(d).await;
5459 continue;
5460 }
5461 dlg.finished(false);
5462 return Err(common::Error::HttpError(err));
5463 }
5464 Ok(res) => {
5465 let (mut parts, body) = res.into_parts();
5466 let mut body = common::Body::new(body);
5467 if !parts.status.is_success() {
5468 let bytes = common::to_bytes(body).await.unwrap_or_default();
5469 let error = serde_json::from_str(&common::to_string(&bytes));
5470 let response = common::to_response(parts, bytes.into());
5471
5472 if let common::Retry::After(d) =
5473 dlg.http_failure(&response, error.as_ref().ok())
5474 {
5475 sleep(d).await;
5476 continue;
5477 }
5478
5479 dlg.finished(false);
5480
5481 return Err(match error {
5482 Ok(value) => common::Error::BadRequest(value),
5483 _ => common::Error::Failure(response),
5484 });
5485 }
5486 let response = {
5487 let bytes = common::to_bytes(body).await.unwrap_or_default();
5488 let encoded = common::to_string(&bytes);
5489 match serde_json::from_str(&encoded) {
5490 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5491 Err(error) => {
5492 dlg.response_json_decode_error(&encoded, &error);
5493 return Err(common::Error::JsonDecodeError(
5494 encoded.to_string(),
5495 error,
5496 ));
5497 }
5498 }
5499 };
5500
5501 dlg.finished(true);
5502 return Ok(response);
5503 }
5504 }
5505 }
5506 }
5507
5508 ///
5509 /// Sets the *blog id* path property to the given value.
5510 ///
5511 /// Even though the property as already been set when instantiating this call,
5512 /// we provide this method for API completeness.
5513 pub fn blog_id(mut self, new_value: &str) -> CommentMarkAsSpamCall<'a, C> {
5514 self._blog_id = new_value.to_string();
5515 self
5516 }
5517 ///
5518 /// Sets the *post id* path property to the given value.
5519 ///
5520 /// Even though the property as already been set when instantiating this call,
5521 /// we provide this method for API completeness.
5522 pub fn post_id(mut self, new_value: &str) -> CommentMarkAsSpamCall<'a, C> {
5523 self._post_id = new_value.to_string();
5524 self
5525 }
5526 ///
5527 /// Sets the *comment id* path property to the given value.
5528 ///
5529 /// Even though the property as already been set when instantiating this call,
5530 /// we provide this method for API completeness.
5531 pub fn comment_id(mut self, new_value: &str) -> CommentMarkAsSpamCall<'a, C> {
5532 self._comment_id = new_value.to_string();
5533 self
5534 }
5535 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5536 /// while executing the actual API request.
5537 ///
5538 /// ````text
5539 /// It should be used to handle progress information, and to implement a certain level of resilience.
5540 /// ````
5541 ///
5542 /// Sets the *delegate* property to the given value.
5543 pub fn delegate(
5544 mut self,
5545 new_value: &'a mut dyn common::Delegate,
5546 ) -> CommentMarkAsSpamCall<'a, C> {
5547 self._delegate = Some(new_value);
5548 self
5549 }
5550
5551 /// Set any additional parameter of the query string used in the request.
5552 /// It should be used to set parameters which are not yet available through their own
5553 /// setters.
5554 ///
5555 /// Please note that this method must not be used to set any of the known parameters
5556 /// which have their own setter method. If done anyway, the request will fail.
5557 ///
5558 /// # Additional Parameters
5559 ///
5560 /// * *$.xgafv* (query-string) - V1 error format.
5561 /// * *access_token* (query-string) - OAuth access token.
5562 /// * *alt* (query-string) - Data format for response.
5563 /// * *callback* (query-string) - JSONP
5564 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5565 /// * *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.
5566 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5567 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5568 /// * *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.
5569 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5570 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5571 pub fn param<T>(mut self, name: T, value: T) -> CommentMarkAsSpamCall<'a, C>
5572 where
5573 T: AsRef<str>,
5574 {
5575 self._additional_params
5576 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5577 self
5578 }
5579
5580 /// Identifies the authorization scope for the method you are building.
5581 ///
5582 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5583 /// [`Scope::Full`].
5584 ///
5585 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5586 /// tokens for more than one scope.
5587 ///
5588 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5589 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5590 /// sufficient, a read-write scope will do as well.
5591 pub fn add_scope<St>(mut self, scope: St) -> CommentMarkAsSpamCall<'a, C>
5592 where
5593 St: AsRef<str>,
5594 {
5595 self._scopes.insert(String::from(scope.as_ref()));
5596 self
5597 }
5598 /// Identifies the authorization scope(s) for the method you are building.
5599 ///
5600 /// See [`Self::add_scope()`] for details.
5601 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentMarkAsSpamCall<'a, C>
5602 where
5603 I: IntoIterator<Item = St>,
5604 St: AsRef<str>,
5605 {
5606 self._scopes
5607 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5608 self
5609 }
5610
5611 /// Removes all scopes, and no default scope will be used either.
5612 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5613 /// for details).
5614 pub fn clear_scopes(mut self) -> CommentMarkAsSpamCall<'a, C> {
5615 self._scopes.clear();
5616 self
5617 }
5618}
5619
5620/// Removes the content of a comment by blog id, post id and comment id.
5621///
5622/// A builder for the *removeContent* method supported by a *comment* resource.
5623/// It is not used directly, but through a [`CommentMethods`] instance.
5624///
5625/// # Example
5626///
5627/// Instantiate a resource method builder
5628///
5629/// ```test_harness,no_run
5630/// # extern crate hyper;
5631/// # extern crate hyper_rustls;
5632/// # extern crate google_blogger3 as blogger3;
5633/// # async fn dox() {
5634/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5635///
5636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5637/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5638/// # .with_native_roots()
5639/// # .unwrap()
5640/// # .https_only()
5641/// # .enable_http2()
5642/// # .build();
5643///
5644/// # let executor = hyper_util::rt::TokioExecutor::new();
5645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5646/// # secret,
5647/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5648/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5649/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5650/// # ),
5651/// # ).build().await.unwrap();
5652///
5653/// # let client = hyper_util::client::legacy::Client::builder(
5654/// # hyper_util::rt::TokioExecutor::new()
5655/// # )
5656/// # .build(
5657/// # hyper_rustls::HttpsConnectorBuilder::new()
5658/// # .with_native_roots()
5659/// # .unwrap()
5660/// # .https_or_http()
5661/// # .enable_http2()
5662/// # .build()
5663/// # );
5664/// # let mut hub = Blogger::new(client, auth);
5665/// // You can configure optional parameters by calling the respective setters at will, and
5666/// // execute the final call using `doit()`.
5667/// // Values shown here are possibly random and not representative !
5668/// let result = hub.comments().remove_content("blogId", "postId", "commentId")
5669/// .doit().await;
5670/// # }
5671/// ```
5672pub struct CommentRemoveContentCall<'a, C>
5673where
5674 C: 'a,
5675{
5676 hub: &'a Blogger<C>,
5677 _blog_id: String,
5678 _post_id: String,
5679 _comment_id: String,
5680 _delegate: Option<&'a mut dyn common::Delegate>,
5681 _additional_params: HashMap<String, String>,
5682 _scopes: BTreeSet<String>,
5683}
5684
5685impl<'a, C> common::CallBuilder for CommentRemoveContentCall<'a, C> {}
5686
5687impl<'a, C> CommentRemoveContentCall<'a, C>
5688where
5689 C: common::Connector,
5690{
5691 /// Perform the operation you have build so far.
5692 pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
5693 use std::borrow::Cow;
5694 use std::io::{Read, Seek};
5695
5696 use common::{url::Params, ToParts};
5697 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5698
5699 let mut dd = common::DefaultDelegate;
5700 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5701 dlg.begin(common::MethodInfo {
5702 id: "blogger.comments.removeContent",
5703 http_method: hyper::Method::POST,
5704 });
5705
5706 for &field in ["alt", "blogId", "postId", "commentId"].iter() {
5707 if self._additional_params.contains_key(field) {
5708 dlg.finished(false);
5709 return Err(common::Error::FieldClash(field));
5710 }
5711 }
5712
5713 let mut params = Params::with_capacity(5 + self._additional_params.len());
5714 params.push("blogId", self._blog_id);
5715 params.push("postId", self._post_id);
5716 params.push("commentId", self._comment_id);
5717
5718 params.extend(self._additional_params.iter());
5719
5720 params.push("alt", "json");
5721 let mut url = self.hub._base_url.clone()
5722 + "v3/blogs/{blogId}/posts/{postId}/comments/{commentId}/removecontent";
5723 if self._scopes.is_empty() {
5724 self._scopes.insert(Scope::Full.as_ref().to_string());
5725 }
5726
5727 #[allow(clippy::single_element_loop)]
5728 for &(find_this, param_name) in [
5729 ("{blogId}", "blogId"),
5730 ("{postId}", "postId"),
5731 ("{commentId}", "commentId"),
5732 ]
5733 .iter()
5734 {
5735 url = params.uri_replacement(url, param_name, find_this, false);
5736 }
5737 {
5738 let to_remove = ["commentId", "postId", "blogId"];
5739 params.remove_params(&to_remove);
5740 }
5741
5742 let url = params.parse_with_url(&url);
5743
5744 loop {
5745 let token = match self
5746 .hub
5747 .auth
5748 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5749 .await
5750 {
5751 Ok(token) => token,
5752 Err(e) => match dlg.token(e) {
5753 Ok(token) => token,
5754 Err(e) => {
5755 dlg.finished(false);
5756 return Err(common::Error::MissingToken(e));
5757 }
5758 },
5759 };
5760 let mut req_result = {
5761 let client = &self.hub.client;
5762 dlg.pre_request();
5763 let mut req_builder = hyper::Request::builder()
5764 .method(hyper::Method::POST)
5765 .uri(url.as_str())
5766 .header(USER_AGENT, self.hub._user_agent.clone());
5767
5768 if let Some(token) = token.as_ref() {
5769 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5770 }
5771
5772 let request = req_builder
5773 .header(CONTENT_LENGTH, 0_u64)
5774 .body(common::to_body::<String>(None));
5775
5776 client.request(request.unwrap()).await
5777 };
5778
5779 match req_result {
5780 Err(err) => {
5781 if let common::Retry::After(d) = dlg.http_error(&err) {
5782 sleep(d).await;
5783 continue;
5784 }
5785 dlg.finished(false);
5786 return Err(common::Error::HttpError(err));
5787 }
5788 Ok(res) => {
5789 let (mut parts, body) = res.into_parts();
5790 let mut body = common::Body::new(body);
5791 if !parts.status.is_success() {
5792 let bytes = common::to_bytes(body).await.unwrap_or_default();
5793 let error = serde_json::from_str(&common::to_string(&bytes));
5794 let response = common::to_response(parts, bytes.into());
5795
5796 if let common::Retry::After(d) =
5797 dlg.http_failure(&response, error.as_ref().ok())
5798 {
5799 sleep(d).await;
5800 continue;
5801 }
5802
5803 dlg.finished(false);
5804
5805 return Err(match error {
5806 Ok(value) => common::Error::BadRequest(value),
5807 _ => common::Error::Failure(response),
5808 });
5809 }
5810 let response = {
5811 let bytes = common::to_bytes(body).await.unwrap_or_default();
5812 let encoded = common::to_string(&bytes);
5813 match serde_json::from_str(&encoded) {
5814 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5815 Err(error) => {
5816 dlg.response_json_decode_error(&encoded, &error);
5817 return Err(common::Error::JsonDecodeError(
5818 encoded.to_string(),
5819 error,
5820 ));
5821 }
5822 }
5823 };
5824
5825 dlg.finished(true);
5826 return Ok(response);
5827 }
5828 }
5829 }
5830 }
5831
5832 ///
5833 /// Sets the *blog id* path property to the given value.
5834 ///
5835 /// Even though the property as already been set when instantiating this call,
5836 /// we provide this method for API completeness.
5837 pub fn blog_id(mut self, new_value: &str) -> CommentRemoveContentCall<'a, C> {
5838 self._blog_id = new_value.to_string();
5839 self
5840 }
5841 ///
5842 /// Sets the *post id* path property to the given value.
5843 ///
5844 /// Even though the property as already been set when instantiating this call,
5845 /// we provide this method for API completeness.
5846 pub fn post_id(mut self, new_value: &str) -> CommentRemoveContentCall<'a, C> {
5847 self._post_id = new_value.to_string();
5848 self
5849 }
5850 ///
5851 /// Sets the *comment id* path property to the given value.
5852 ///
5853 /// Even though the property as already been set when instantiating this call,
5854 /// we provide this method for API completeness.
5855 pub fn comment_id(mut self, new_value: &str) -> CommentRemoveContentCall<'a, C> {
5856 self._comment_id = new_value.to_string();
5857 self
5858 }
5859 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5860 /// while executing the actual API request.
5861 ///
5862 /// ````text
5863 /// It should be used to handle progress information, and to implement a certain level of resilience.
5864 /// ````
5865 ///
5866 /// Sets the *delegate* property to the given value.
5867 pub fn delegate(
5868 mut self,
5869 new_value: &'a mut dyn common::Delegate,
5870 ) -> CommentRemoveContentCall<'a, C> {
5871 self._delegate = Some(new_value);
5872 self
5873 }
5874
5875 /// Set any additional parameter of the query string used in the request.
5876 /// It should be used to set parameters which are not yet available through their own
5877 /// setters.
5878 ///
5879 /// Please note that this method must not be used to set any of the known parameters
5880 /// which have their own setter method. If done anyway, the request will fail.
5881 ///
5882 /// # Additional Parameters
5883 ///
5884 /// * *$.xgafv* (query-string) - V1 error format.
5885 /// * *access_token* (query-string) - OAuth access token.
5886 /// * *alt* (query-string) - Data format for response.
5887 /// * *callback* (query-string) - JSONP
5888 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5889 /// * *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.
5890 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5891 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5892 /// * *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.
5893 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5894 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5895 pub fn param<T>(mut self, name: T, value: T) -> CommentRemoveContentCall<'a, C>
5896 where
5897 T: AsRef<str>,
5898 {
5899 self._additional_params
5900 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5901 self
5902 }
5903
5904 /// Identifies the authorization scope for the method you are building.
5905 ///
5906 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5907 /// [`Scope::Full`].
5908 ///
5909 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5910 /// tokens for more than one scope.
5911 ///
5912 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5913 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5914 /// sufficient, a read-write scope will do as well.
5915 pub fn add_scope<St>(mut self, scope: St) -> CommentRemoveContentCall<'a, C>
5916 where
5917 St: AsRef<str>,
5918 {
5919 self._scopes.insert(String::from(scope.as_ref()));
5920 self
5921 }
5922 /// Identifies the authorization scope(s) for the method you are building.
5923 ///
5924 /// See [`Self::add_scope()`] for details.
5925 pub fn add_scopes<I, St>(mut self, scopes: I) -> CommentRemoveContentCall<'a, C>
5926 where
5927 I: IntoIterator<Item = St>,
5928 St: AsRef<str>,
5929 {
5930 self._scopes
5931 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5932 self
5933 }
5934
5935 /// Removes all scopes, and no default scope will be used either.
5936 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5937 /// for details).
5938 pub fn clear_scopes(mut self) -> CommentRemoveContentCall<'a, C> {
5939 self._scopes.clear();
5940 self
5941 }
5942}
5943
5944/// Gets page views by blog id.
5945///
5946/// A builder for the *get* method supported by a *pageView* resource.
5947/// It is not used directly, but through a [`PageViewMethods`] instance.
5948///
5949/// # Example
5950///
5951/// Instantiate a resource method builder
5952///
5953/// ```test_harness,no_run
5954/// # extern crate hyper;
5955/// # extern crate hyper_rustls;
5956/// # extern crate google_blogger3 as blogger3;
5957/// # async fn dox() {
5958/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5959///
5960/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5961/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5962/// # .with_native_roots()
5963/// # .unwrap()
5964/// # .https_only()
5965/// # .enable_http2()
5966/// # .build();
5967///
5968/// # let executor = hyper_util::rt::TokioExecutor::new();
5969/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5970/// # secret,
5971/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5972/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5973/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5974/// # ),
5975/// # ).build().await.unwrap();
5976///
5977/// # let client = hyper_util::client::legacy::Client::builder(
5978/// # hyper_util::rt::TokioExecutor::new()
5979/// # )
5980/// # .build(
5981/// # hyper_rustls::HttpsConnectorBuilder::new()
5982/// # .with_native_roots()
5983/// # .unwrap()
5984/// # .https_or_http()
5985/// # .enable_http2()
5986/// # .build()
5987/// # );
5988/// # let mut hub = Blogger::new(client, auth);
5989/// // You can configure optional parameters by calling the respective setters at will, and
5990/// // execute the final call using `doit()`.
5991/// // Values shown here are possibly random and not representative !
5992/// let result = hub.page_views().get("blogId")
5993/// .add_range("dolores")
5994/// .doit().await;
5995/// # }
5996/// ```
5997pub struct PageViewGetCall<'a, C>
5998where
5999 C: 'a,
6000{
6001 hub: &'a Blogger<C>,
6002 _blog_id: String,
6003 _range: Vec<String>,
6004 _delegate: Option<&'a mut dyn common::Delegate>,
6005 _additional_params: HashMap<String, String>,
6006 _scopes: BTreeSet<String>,
6007}
6008
6009impl<'a, C> common::CallBuilder for PageViewGetCall<'a, C> {}
6010
6011impl<'a, C> PageViewGetCall<'a, C>
6012where
6013 C: common::Connector,
6014{
6015 /// Perform the operation you have build so far.
6016 pub async fn doit(mut self) -> common::Result<(common::Response, Pageviews)> {
6017 use std::borrow::Cow;
6018 use std::io::{Read, Seek};
6019
6020 use common::{url::Params, ToParts};
6021 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6022
6023 let mut dd = common::DefaultDelegate;
6024 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6025 dlg.begin(common::MethodInfo {
6026 id: "blogger.pageViews.get",
6027 http_method: hyper::Method::GET,
6028 });
6029
6030 for &field in ["alt", "blogId", "range"].iter() {
6031 if self._additional_params.contains_key(field) {
6032 dlg.finished(false);
6033 return Err(common::Error::FieldClash(field));
6034 }
6035 }
6036
6037 let mut params = Params::with_capacity(4 + self._additional_params.len());
6038 params.push("blogId", self._blog_id);
6039 if !self._range.is_empty() {
6040 for f in self._range.iter() {
6041 params.push("range", f);
6042 }
6043 }
6044
6045 params.extend(self._additional_params.iter());
6046
6047 params.push("alt", "json");
6048 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pageviews";
6049 if self._scopes.is_empty() {
6050 self._scopes.insert(Scope::Full.as_ref().to_string());
6051 }
6052
6053 #[allow(clippy::single_element_loop)]
6054 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
6055 url = params.uri_replacement(url, param_name, find_this, false);
6056 }
6057 {
6058 let to_remove = ["blogId"];
6059 params.remove_params(&to_remove);
6060 }
6061
6062 let url = params.parse_with_url(&url);
6063
6064 loop {
6065 let token = match self
6066 .hub
6067 .auth
6068 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6069 .await
6070 {
6071 Ok(token) => token,
6072 Err(e) => match dlg.token(e) {
6073 Ok(token) => token,
6074 Err(e) => {
6075 dlg.finished(false);
6076 return Err(common::Error::MissingToken(e));
6077 }
6078 },
6079 };
6080 let mut req_result = {
6081 let client = &self.hub.client;
6082 dlg.pre_request();
6083 let mut req_builder = hyper::Request::builder()
6084 .method(hyper::Method::GET)
6085 .uri(url.as_str())
6086 .header(USER_AGENT, self.hub._user_agent.clone());
6087
6088 if let Some(token) = token.as_ref() {
6089 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6090 }
6091
6092 let request = req_builder
6093 .header(CONTENT_LENGTH, 0_u64)
6094 .body(common::to_body::<String>(None));
6095
6096 client.request(request.unwrap()).await
6097 };
6098
6099 match req_result {
6100 Err(err) => {
6101 if let common::Retry::After(d) = dlg.http_error(&err) {
6102 sleep(d).await;
6103 continue;
6104 }
6105 dlg.finished(false);
6106 return Err(common::Error::HttpError(err));
6107 }
6108 Ok(res) => {
6109 let (mut parts, body) = res.into_parts();
6110 let mut body = common::Body::new(body);
6111 if !parts.status.is_success() {
6112 let bytes = common::to_bytes(body).await.unwrap_or_default();
6113 let error = serde_json::from_str(&common::to_string(&bytes));
6114 let response = common::to_response(parts, bytes.into());
6115
6116 if let common::Retry::After(d) =
6117 dlg.http_failure(&response, error.as_ref().ok())
6118 {
6119 sleep(d).await;
6120 continue;
6121 }
6122
6123 dlg.finished(false);
6124
6125 return Err(match error {
6126 Ok(value) => common::Error::BadRequest(value),
6127 _ => common::Error::Failure(response),
6128 });
6129 }
6130 let response = {
6131 let bytes = common::to_bytes(body).await.unwrap_or_default();
6132 let encoded = common::to_string(&bytes);
6133 match serde_json::from_str(&encoded) {
6134 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6135 Err(error) => {
6136 dlg.response_json_decode_error(&encoded, &error);
6137 return Err(common::Error::JsonDecodeError(
6138 encoded.to_string(),
6139 error,
6140 ));
6141 }
6142 }
6143 };
6144
6145 dlg.finished(true);
6146 return Ok(response);
6147 }
6148 }
6149 }
6150 }
6151
6152 ///
6153 /// Sets the *blog id* path property to the given value.
6154 ///
6155 /// Even though the property as already been set when instantiating this call,
6156 /// we provide this method for API completeness.
6157 pub fn blog_id(mut self, new_value: &str) -> PageViewGetCall<'a, C> {
6158 self._blog_id = new_value.to_string();
6159 self
6160 }
6161 ///
6162 /// Append the given value to the *range* query property.
6163 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6164 pub fn add_range(mut self, new_value: &str) -> PageViewGetCall<'a, C> {
6165 self._range.push(new_value.to_string());
6166 self
6167 }
6168 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6169 /// while executing the actual API request.
6170 ///
6171 /// ````text
6172 /// It should be used to handle progress information, and to implement a certain level of resilience.
6173 /// ````
6174 ///
6175 /// Sets the *delegate* property to the given value.
6176 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageViewGetCall<'a, C> {
6177 self._delegate = Some(new_value);
6178 self
6179 }
6180
6181 /// Set any additional parameter of the query string used in the request.
6182 /// It should be used to set parameters which are not yet available through their own
6183 /// setters.
6184 ///
6185 /// Please note that this method must not be used to set any of the known parameters
6186 /// which have their own setter method. If done anyway, the request will fail.
6187 ///
6188 /// # Additional Parameters
6189 ///
6190 /// * *$.xgafv* (query-string) - V1 error format.
6191 /// * *access_token* (query-string) - OAuth access token.
6192 /// * *alt* (query-string) - Data format for response.
6193 /// * *callback* (query-string) - JSONP
6194 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6195 /// * *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.
6196 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6197 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6198 /// * *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.
6199 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6200 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6201 pub fn param<T>(mut self, name: T, value: T) -> PageViewGetCall<'a, C>
6202 where
6203 T: AsRef<str>,
6204 {
6205 self._additional_params
6206 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6207 self
6208 }
6209
6210 /// Identifies the authorization scope for the method you are building.
6211 ///
6212 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6213 /// [`Scope::Full`].
6214 ///
6215 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6216 /// tokens for more than one scope.
6217 ///
6218 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6219 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6220 /// sufficient, a read-write scope will do as well.
6221 pub fn add_scope<St>(mut self, scope: St) -> PageViewGetCall<'a, C>
6222 where
6223 St: AsRef<str>,
6224 {
6225 self._scopes.insert(String::from(scope.as_ref()));
6226 self
6227 }
6228 /// Identifies the authorization scope(s) for the method you are building.
6229 ///
6230 /// See [`Self::add_scope()`] for details.
6231 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageViewGetCall<'a, C>
6232 where
6233 I: IntoIterator<Item = St>,
6234 St: AsRef<str>,
6235 {
6236 self._scopes
6237 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6238 self
6239 }
6240
6241 /// Removes all scopes, and no default scope will be used either.
6242 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6243 /// for details).
6244 pub fn clear_scopes(mut self) -> PageViewGetCall<'a, C> {
6245 self._scopes.clear();
6246 self
6247 }
6248}
6249
6250/// Deletes a page by blog id and page id.
6251///
6252/// A builder for the *delete* method supported by a *page* resource.
6253/// It is not used directly, but through a [`PageMethods`] instance.
6254///
6255/// # Example
6256///
6257/// Instantiate a resource method builder
6258///
6259/// ```test_harness,no_run
6260/// # extern crate hyper;
6261/// # extern crate hyper_rustls;
6262/// # extern crate google_blogger3 as blogger3;
6263/// # async fn dox() {
6264/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6265///
6266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6267/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6268/// # .with_native_roots()
6269/// # .unwrap()
6270/// # .https_only()
6271/// # .enable_http2()
6272/// # .build();
6273///
6274/// # let executor = hyper_util::rt::TokioExecutor::new();
6275/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6276/// # secret,
6277/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6278/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6279/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6280/// # ),
6281/// # ).build().await.unwrap();
6282///
6283/// # let client = hyper_util::client::legacy::Client::builder(
6284/// # hyper_util::rt::TokioExecutor::new()
6285/// # )
6286/// # .build(
6287/// # hyper_rustls::HttpsConnectorBuilder::new()
6288/// # .with_native_roots()
6289/// # .unwrap()
6290/// # .https_or_http()
6291/// # .enable_http2()
6292/// # .build()
6293/// # );
6294/// # let mut hub = Blogger::new(client, auth);
6295/// // You can configure optional parameters by calling the respective setters at will, and
6296/// // execute the final call using `doit()`.
6297/// // Values shown here are possibly random and not representative !
6298/// let result = hub.pages().delete("blogId", "pageId")
6299/// .use_trash(false)
6300/// .doit().await;
6301/// # }
6302/// ```
6303pub struct PageDeleteCall<'a, C>
6304where
6305 C: 'a,
6306{
6307 hub: &'a Blogger<C>,
6308 _blog_id: String,
6309 _page_id: String,
6310 _use_trash: Option<bool>,
6311 _delegate: Option<&'a mut dyn common::Delegate>,
6312 _additional_params: HashMap<String, String>,
6313 _scopes: BTreeSet<String>,
6314}
6315
6316impl<'a, C> common::CallBuilder for PageDeleteCall<'a, C> {}
6317
6318impl<'a, C> PageDeleteCall<'a, C>
6319where
6320 C: common::Connector,
6321{
6322 /// Perform the operation you have build so far.
6323 pub async fn doit(mut self) -> common::Result<common::Response> {
6324 use std::borrow::Cow;
6325 use std::io::{Read, Seek};
6326
6327 use common::{url::Params, ToParts};
6328 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6329
6330 let mut dd = common::DefaultDelegate;
6331 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6332 dlg.begin(common::MethodInfo {
6333 id: "blogger.pages.delete",
6334 http_method: hyper::Method::DELETE,
6335 });
6336
6337 for &field in ["blogId", "pageId", "useTrash"].iter() {
6338 if self._additional_params.contains_key(field) {
6339 dlg.finished(false);
6340 return Err(common::Error::FieldClash(field));
6341 }
6342 }
6343
6344 let mut params = Params::with_capacity(4 + self._additional_params.len());
6345 params.push("blogId", self._blog_id);
6346 params.push("pageId", self._page_id);
6347 if let Some(value) = self._use_trash.as_ref() {
6348 params.push("useTrash", value.to_string());
6349 }
6350
6351 params.extend(self._additional_params.iter());
6352
6353 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages/{pageId}";
6354 if self._scopes.is_empty() {
6355 self._scopes.insert(Scope::Full.as_ref().to_string());
6356 }
6357
6358 #[allow(clippy::single_element_loop)]
6359 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{pageId}", "pageId")].iter() {
6360 url = params.uri_replacement(url, param_name, find_this, false);
6361 }
6362 {
6363 let to_remove = ["pageId", "blogId"];
6364 params.remove_params(&to_remove);
6365 }
6366
6367 let url = params.parse_with_url(&url);
6368
6369 loop {
6370 let token = match self
6371 .hub
6372 .auth
6373 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6374 .await
6375 {
6376 Ok(token) => token,
6377 Err(e) => match dlg.token(e) {
6378 Ok(token) => token,
6379 Err(e) => {
6380 dlg.finished(false);
6381 return Err(common::Error::MissingToken(e));
6382 }
6383 },
6384 };
6385 let mut req_result = {
6386 let client = &self.hub.client;
6387 dlg.pre_request();
6388 let mut req_builder = hyper::Request::builder()
6389 .method(hyper::Method::DELETE)
6390 .uri(url.as_str())
6391 .header(USER_AGENT, self.hub._user_agent.clone());
6392
6393 if let Some(token) = token.as_ref() {
6394 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6395 }
6396
6397 let request = req_builder
6398 .header(CONTENT_LENGTH, 0_u64)
6399 .body(common::to_body::<String>(None));
6400
6401 client.request(request.unwrap()).await
6402 };
6403
6404 match req_result {
6405 Err(err) => {
6406 if let common::Retry::After(d) = dlg.http_error(&err) {
6407 sleep(d).await;
6408 continue;
6409 }
6410 dlg.finished(false);
6411 return Err(common::Error::HttpError(err));
6412 }
6413 Ok(res) => {
6414 let (mut parts, body) = res.into_parts();
6415 let mut body = common::Body::new(body);
6416 if !parts.status.is_success() {
6417 let bytes = common::to_bytes(body).await.unwrap_or_default();
6418 let error = serde_json::from_str(&common::to_string(&bytes));
6419 let response = common::to_response(parts, bytes.into());
6420
6421 if let common::Retry::After(d) =
6422 dlg.http_failure(&response, error.as_ref().ok())
6423 {
6424 sleep(d).await;
6425 continue;
6426 }
6427
6428 dlg.finished(false);
6429
6430 return Err(match error {
6431 Ok(value) => common::Error::BadRequest(value),
6432 _ => common::Error::Failure(response),
6433 });
6434 }
6435 let response = common::Response::from_parts(parts, body);
6436
6437 dlg.finished(true);
6438 return Ok(response);
6439 }
6440 }
6441 }
6442 }
6443
6444 ///
6445 /// Sets the *blog id* path property to the given value.
6446 ///
6447 /// Even though the property as already been set when instantiating this call,
6448 /// we provide this method for API completeness.
6449 pub fn blog_id(mut self, new_value: &str) -> PageDeleteCall<'a, C> {
6450 self._blog_id = new_value.to_string();
6451 self
6452 }
6453 ///
6454 /// Sets the *page id* path property to the given value.
6455 ///
6456 /// Even though the property as already been set when instantiating this call,
6457 /// we provide this method for API completeness.
6458 pub fn page_id(mut self, new_value: &str) -> PageDeleteCall<'a, C> {
6459 self._page_id = new_value.to_string();
6460 self
6461 }
6462 /// Move to Trash if possible
6463 ///
6464 /// Sets the *use trash* query property to the given value.
6465 pub fn use_trash(mut self, new_value: bool) -> PageDeleteCall<'a, C> {
6466 self._use_trash = Some(new_value);
6467 self
6468 }
6469 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6470 /// while executing the actual API request.
6471 ///
6472 /// ````text
6473 /// It should be used to handle progress information, and to implement a certain level of resilience.
6474 /// ````
6475 ///
6476 /// Sets the *delegate* property to the given value.
6477 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageDeleteCall<'a, C> {
6478 self._delegate = Some(new_value);
6479 self
6480 }
6481
6482 /// Set any additional parameter of the query string used in the request.
6483 /// It should be used to set parameters which are not yet available through their own
6484 /// setters.
6485 ///
6486 /// Please note that this method must not be used to set any of the known parameters
6487 /// which have their own setter method. If done anyway, the request will fail.
6488 ///
6489 /// # Additional Parameters
6490 ///
6491 /// * *$.xgafv* (query-string) - V1 error format.
6492 /// * *access_token* (query-string) - OAuth access token.
6493 /// * *alt* (query-string) - Data format for response.
6494 /// * *callback* (query-string) - JSONP
6495 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6496 /// * *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.
6497 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6498 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6499 /// * *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.
6500 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6501 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6502 pub fn param<T>(mut self, name: T, value: T) -> PageDeleteCall<'a, C>
6503 where
6504 T: AsRef<str>,
6505 {
6506 self._additional_params
6507 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6508 self
6509 }
6510
6511 /// Identifies the authorization scope for the method you are building.
6512 ///
6513 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6514 /// [`Scope::Full`].
6515 ///
6516 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6517 /// tokens for more than one scope.
6518 ///
6519 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6520 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6521 /// sufficient, a read-write scope will do as well.
6522 pub fn add_scope<St>(mut self, scope: St) -> PageDeleteCall<'a, C>
6523 where
6524 St: AsRef<str>,
6525 {
6526 self._scopes.insert(String::from(scope.as_ref()));
6527 self
6528 }
6529 /// Identifies the authorization scope(s) for the method you are building.
6530 ///
6531 /// See [`Self::add_scope()`] for details.
6532 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageDeleteCall<'a, C>
6533 where
6534 I: IntoIterator<Item = St>,
6535 St: AsRef<str>,
6536 {
6537 self._scopes
6538 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6539 self
6540 }
6541
6542 /// Removes all scopes, and no default scope will be used either.
6543 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6544 /// for details).
6545 pub fn clear_scopes(mut self) -> PageDeleteCall<'a, C> {
6546 self._scopes.clear();
6547 self
6548 }
6549}
6550
6551/// Gets a page by blog id and page id.
6552///
6553/// A builder for the *get* method supported by a *page* resource.
6554/// It is not used directly, but through a [`PageMethods`] instance.
6555///
6556/// # Example
6557///
6558/// Instantiate a resource method builder
6559///
6560/// ```test_harness,no_run
6561/// # extern crate hyper;
6562/// # extern crate hyper_rustls;
6563/// # extern crate google_blogger3 as blogger3;
6564/// # async fn dox() {
6565/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6566///
6567/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6568/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6569/// # .with_native_roots()
6570/// # .unwrap()
6571/// # .https_only()
6572/// # .enable_http2()
6573/// # .build();
6574///
6575/// # let executor = hyper_util::rt::TokioExecutor::new();
6576/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6577/// # secret,
6578/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6579/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6580/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6581/// # ),
6582/// # ).build().await.unwrap();
6583///
6584/// # let client = hyper_util::client::legacy::Client::builder(
6585/// # hyper_util::rt::TokioExecutor::new()
6586/// # )
6587/// # .build(
6588/// # hyper_rustls::HttpsConnectorBuilder::new()
6589/// # .with_native_roots()
6590/// # .unwrap()
6591/// # .https_or_http()
6592/// # .enable_http2()
6593/// # .build()
6594/// # );
6595/// # let mut hub = Blogger::new(client, auth);
6596/// // You can configure optional parameters by calling the respective setters at will, and
6597/// // execute the final call using `doit()`.
6598/// // Values shown here are possibly random and not representative !
6599/// let result = hub.pages().get("blogId", "pageId")
6600/// .view("dolore")
6601/// .doit().await;
6602/// # }
6603/// ```
6604pub struct PageGetCall<'a, C>
6605where
6606 C: 'a,
6607{
6608 hub: &'a Blogger<C>,
6609 _blog_id: String,
6610 _page_id: String,
6611 _view: Option<String>,
6612 _delegate: Option<&'a mut dyn common::Delegate>,
6613 _additional_params: HashMap<String, String>,
6614 _scopes: BTreeSet<String>,
6615}
6616
6617impl<'a, C> common::CallBuilder for PageGetCall<'a, C> {}
6618
6619impl<'a, C> PageGetCall<'a, C>
6620where
6621 C: common::Connector,
6622{
6623 /// Perform the operation you have build so far.
6624 pub async fn doit(mut self) -> common::Result<(common::Response, Page)> {
6625 use std::borrow::Cow;
6626 use std::io::{Read, Seek};
6627
6628 use common::{url::Params, ToParts};
6629 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6630
6631 let mut dd = common::DefaultDelegate;
6632 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6633 dlg.begin(common::MethodInfo {
6634 id: "blogger.pages.get",
6635 http_method: hyper::Method::GET,
6636 });
6637
6638 for &field in ["alt", "blogId", "pageId", "view"].iter() {
6639 if self._additional_params.contains_key(field) {
6640 dlg.finished(false);
6641 return Err(common::Error::FieldClash(field));
6642 }
6643 }
6644
6645 let mut params = Params::with_capacity(5 + self._additional_params.len());
6646 params.push("blogId", self._blog_id);
6647 params.push("pageId", self._page_id);
6648 if let Some(value) = self._view.as_ref() {
6649 params.push("view", value);
6650 }
6651
6652 params.extend(self._additional_params.iter());
6653
6654 params.push("alt", "json");
6655 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages/{pageId}";
6656 if self._scopes.is_empty() {
6657 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6658 }
6659
6660 #[allow(clippy::single_element_loop)]
6661 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{pageId}", "pageId")].iter() {
6662 url = params.uri_replacement(url, param_name, find_this, false);
6663 }
6664 {
6665 let to_remove = ["pageId", "blogId"];
6666 params.remove_params(&to_remove);
6667 }
6668
6669 let url = params.parse_with_url(&url);
6670
6671 loop {
6672 let token = match self
6673 .hub
6674 .auth
6675 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6676 .await
6677 {
6678 Ok(token) => token,
6679 Err(e) => match dlg.token(e) {
6680 Ok(token) => token,
6681 Err(e) => {
6682 dlg.finished(false);
6683 return Err(common::Error::MissingToken(e));
6684 }
6685 },
6686 };
6687 let mut req_result = {
6688 let client = &self.hub.client;
6689 dlg.pre_request();
6690 let mut req_builder = hyper::Request::builder()
6691 .method(hyper::Method::GET)
6692 .uri(url.as_str())
6693 .header(USER_AGENT, self.hub._user_agent.clone());
6694
6695 if let Some(token) = token.as_ref() {
6696 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6697 }
6698
6699 let request = req_builder
6700 .header(CONTENT_LENGTH, 0_u64)
6701 .body(common::to_body::<String>(None));
6702
6703 client.request(request.unwrap()).await
6704 };
6705
6706 match req_result {
6707 Err(err) => {
6708 if let common::Retry::After(d) = dlg.http_error(&err) {
6709 sleep(d).await;
6710 continue;
6711 }
6712 dlg.finished(false);
6713 return Err(common::Error::HttpError(err));
6714 }
6715 Ok(res) => {
6716 let (mut parts, body) = res.into_parts();
6717 let mut body = common::Body::new(body);
6718 if !parts.status.is_success() {
6719 let bytes = common::to_bytes(body).await.unwrap_or_default();
6720 let error = serde_json::from_str(&common::to_string(&bytes));
6721 let response = common::to_response(parts, bytes.into());
6722
6723 if let common::Retry::After(d) =
6724 dlg.http_failure(&response, error.as_ref().ok())
6725 {
6726 sleep(d).await;
6727 continue;
6728 }
6729
6730 dlg.finished(false);
6731
6732 return Err(match error {
6733 Ok(value) => common::Error::BadRequest(value),
6734 _ => common::Error::Failure(response),
6735 });
6736 }
6737 let response = {
6738 let bytes = common::to_bytes(body).await.unwrap_or_default();
6739 let encoded = common::to_string(&bytes);
6740 match serde_json::from_str(&encoded) {
6741 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6742 Err(error) => {
6743 dlg.response_json_decode_error(&encoded, &error);
6744 return Err(common::Error::JsonDecodeError(
6745 encoded.to_string(),
6746 error,
6747 ));
6748 }
6749 }
6750 };
6751
6752 dlg.finished(true);
6753 return Ok(response);
6754 }
6755 }
6756 }
6757 }
6758
6759 ///
6760 /// Sets the *blog id* path property to the given value.
6761 ///
6762 /// Even though the property as already been set when instantiating this call,
6763 /// we provide this method for API completeness.
6764 pub fn blog_id(mut self, new_value: &str) -> PageGetCall<'a, C> {
6765 self._blog_id = new_value.to_string();
6766 self
6767 }
6768 ///
6769 /// Sets the *page id* path property to the given value.
6770 ///
6771 /// Even though the property as already been set when instantiating this call,
6772 /// we provide this method for API completeness.
6773 pub fn page_id(mut self, new_value: &str) -> PageGetCall<'a, C> {
6774 self._page_id = new_value.to_string();
6775 self
6776 }
6777 ///
6778 /// Sets the *view* query property to the given value.
6779 pub fn view(mut self, new_value: &str) -> PageGetCall<'a, C> {
6780 self._view = Some(new_value.to_string());
6781 self
6782 }
6783 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6784 /// while executing the actual API request.
6785 ///
6786 /// ````text
6787 /// It should be used to handle progress information, and to implement a certain level of resilience.
6788 /// ````
6789 ///
6790 /// Sets the *delegate* property to the given value.
6791 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageGetCall<'a, C> {
6792 self._delegate = Some(new_value);
6793 self
6794 }
6795
6796 /// Set any additional parameter of the query string used in the request.
6797 /// It should be used to set parameters which are not yet available through their own
6798 /// setters.
6799 ///
6800 /// Please note that this method must not be used to set any of the known parameters
6801 /// which have their own setter method. If done anyway, the request will fail.
6802 ///
6803 /// # Additional Parameters
6804 ///
6805 /// * *$.xgafv* (query-string) - V1 error format.
6806 /// * *access_token* (query-string) - OAuth access token.
6807 /// * *alt* (query-string) - Data format for response.
6808 /// * *callback* (query-string) - JSONP
6809 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6810 /// * *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.
6811 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6812 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6813 /// * *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.
6814 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6815 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6816 pub fn param<T>(mut self, name: T, value: T) -> PageGetCall<'a, C>
6817 where
6818 T: AsRef<str>,
6819 {
6820 self._additional_params
6821 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6822 self
6823 }
6824
6825 /// Identifies the authorization scope for the method you are building.
6826 ///
6827 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6828 /// [`Scope::Readonly`].
6829 ///
6830 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6831 /// tokens for more than one scope.
6832 ///
6833 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6834 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6835 /// sufficient, a read-write scope will do as well.
6836 pub fn add_scope<St>(mut self, scope: St) -> PageGetCall<'a, C>
6837 where
6838 St: AsRef<str>,
6839 {
6840 self._scopes.insert(String::from(scope.as_ref()));
6841 self
6842 }
6843 /// Identifies the authorization scope(s) for the method you are building.
6844 ///
6845 /// See [`Self::add_scope()`] for details.
6846 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageGetCall<'a, C>
6847 where
6848 I: IntoIterator<Item = St>,
6849 St: AsRef<str>,
6850 {
6851 self._scopes
6852 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6853 self
6854 }
6855
6856 /// Removes all scopes, and no default scope will be used either.
6857 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6858 /// for details).
6859 pub fn clear_scopes(mut self) -> PageGetCall<'a, C> {
6860 self._scopes.clear();
6861 self
6862 }
6863}
6864
6865/// Inserts a page.
6866///
6867/// A builder for the *insert* method supported by a *page* resource.
6868/// It is not used directly, but through a [`PageMethods`] instance.
6869///
6870/// # Example
6871///
6872/// Instantiate a resource method builder
6873///
6874/// ```test_harness,no_run
6875/// # extern crate hyper;
6876/// # extern crate hyper_rustls;
6877/// # extern crate google_blogger3 as blogger3;
6878/// use blogger3::api::Page;
6879/// # async fn dox() {
6880/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6881///
6882/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6883/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6884/// # .with_native_roots()
6885/// # .unwrap()
6886/// # .https_only()
6887/// # .enable_http2()
6888/// # .build();
6889///
6890/// # let executor = hyper_util::rt::TokioExecutor::new();
6891/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6892/// # secret,
6893/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6894/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6895/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6896/// # ),
6897/// # ).build().await.unwrap();
6898///
6899/// # let client = hyper_util::client::legacy::Client::builder(
6900/// # hyper_util::rt::TokioExecutor::new()
6901/// # )
6902/// # .build(
6903/// # hyper_rustls::HttpsConnectorBuilder::new()
6904/// # .with_native_roots()
6905/// # .unwrap()
6906/// # .https_or_http()
6907/// # .enable_http2()
6908/// # .build()
6909/// # );
6910/// # let mut hub = Blogger::new(client, auth);
6911/// // As the method needs a request, you would usually fill it with the desired information
6912/// // into the respective structure. Some of the parts shown here might not be applicable !
6913/// // Values shown here are possibly random and not representative !
6914/// let mut req = Page::default();
6915///
6916/// // You can configure optional parameters by calling the respective setters at will, and
6917/// // execute the final call using `doit()`.
6918/// // Values shown here are possibly random and not representative !
6919/// let result = hub.pages().insert(req, "blogId")
6920/// .is_draft(false)
6921/// .doit().await;
6922/// # }
6923/// ```
6924pub struct PageInsertCall<'a, C>
6925where
6926 C: 'a,
6927{
6928 hub: &'a Blogger<C>,
6929 _request: Page,
6930 _blog_id: String,
6931 _is_draft: Option<bool>,
6932 _delegate: Option<&'a mut dyn common::Delegate>,
6933 _additional_params: HashMap<String, String>,
6934 _scopes: BTreeSet<String>,
6935}
6936
6937impl<'a, C> common::CallBuilder for PageInsertCall<'a, C> {}
6938
6939impl<'a, C> PageInsertCall<'a, C>
6940where
6941 C: common::Connector,
6942{
6943 /// Perform the operation you have build so far.
6944 pub async fn doit(mut self) -> common::Result<(common::Response, Page)> {
6945 use std::borrow::Cow;
6946 use std::io::{Read, Seek};
6947
6948 use common::{url::Params, ToParts};
6949 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6950
6951 let mut dd = common::DefaultDelegate;
6952 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6953 dlg.begin(common::MethodInfo {
6954 id: "blogger.pages.insert",
6955 http_method: hyper::Method::POST,
6956 });
6957
6958 for &field in ["alt", "blogId", "isDraft"].iter() {
6959 if self._additional_params.contains_key(field) {
6960 dlg.finished(false);
6961 return Err(common::Error::FieldClash(field));
6962 }
6963 }
6964
6965 let mut params = Params::with_capacity(5 + self._additional_params.len());
6966 params.push("blogId", self._blog_id);
6967 if let Some(value) = self._is_draft.as_ref() {
6968 params.push("isDraft", value.to_string());
6969 }
6970
6971 params.extend(self._additional_params.iter());
6972
6973 params.push("alt", "json");
6974 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages";
6975 if self._scopes.is_empty() {
6976 self._scopes.insert(Scope::Full.as_ref().to_string());
6977 }
6978
6979 #[allow(clippy::single_element_loop)]
6980 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
6981 url = params.uri_replacement(url, param_name, find_this, false);
6982 }
6983 {
6984 let to_remove = ["blogId"];
6985 params.remove_params(&to_remove);
6986 }
6987
6988 let url = params.parse_with_url(&url);
6989
6990 let mut json_mime_type = mime::APPLICATION_JSON;
6991 let mut request_value_reader = {
6992 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6993 common::remove_json_null_values(&mut value);
6994 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6995 serde_json::to_writer(&mut dst, &value).unwrap();
6996 dst
6997 };
6998 let request_size = request_value_reader
6999 .seek(std::io::SeekFrom::End(0))
7000 .unwrap();
7001 request_value_reader
7002 .seek(std::io::SeekFrom::Start(0))
7003 .unwrap();
7004
7005 loop {
7006 let token = match self
7007 .hub
7008 .auth
7009 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7010 .await
7011 {
7012 Ok(token) => token,
7013 Err(e) => match dlg.token(e) {
7014 Ok(token) => token,
7015 Err(e) => {
7016 dlg.finished(false);
7017 return Err(common::Error::MissingToken(e));
7018 }
7019 },
7020 };
7021 request_value_reader
7022 .seek(std::io::SeekFrom::Start(0))
7023 .unwrap();
7024 let mut req_result = {
7025 let client = &self.hub.client;
7026 dlg.pre_request();
7027 let mut req_builder = hyper::Request::builder()
7028 .method(hyper::Method::POST)
7029 .uri(url.as_str())
7030 .header(USER_AGENT, self.hub._user_agent.clone());
7031
7032 if let Some(token) = token.as_ref() {
7033 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7034 }
7035
7036 let request = req_builder
7037 .header(CONTENT_TYPE, json_mime_type.to_string())
7038 .header(CONTENT_LENGTH, request_size as u64)
7039 .body(common::to_body(
7040 request_value_reader.get_ref().clone().into(),
7041 ));
7042
7043 client.request(request.unwrap()).await
7044 };
7045
7046 match req_result {
7047 Err(err) => {
7048 if let common::Retry::After(d) = dlg.http_error(&err) {
7049 sleep(d).await;
7050 continue;
7051 }
7052 dlg.finished(false);
7053 return Err(common::Error::HttpError(err));
7054 }
7055 Ok(res) => {
7056 let (mut parts, body) = res.into_parts();
7057 let mut body = common::Body::new(body);
7058 if !parts.status.is_success() {
7059 let bytes = common::to_bytes(body).await.unwrap_or_default();
7060 let error = serde_json::from_str(&common::to_string(&bytes));
7061 let response = common::to_response(parts, bytes.into());
7062
7063 if let common::Retry::After(d) =
7064 dlg.http_failure(&response, error.as_ref().ok())
7065 {
7066 sleep(d).await;
7067 continue;
7068 }
7069
7070 dlg.finished(false);
7071
7072 return Err(match error {
7073 Ok(value) => common::Error::BadRequest(value),
7074 _ => common::Error::Failure(response),
7075 });
7076 }
7077 let response = {
7078 let bytes = common::to_bytes(body).await.unwrap_or_default();
7079 let encoded = common::to_string(&bytes);
7080 match serde_json::from_str(&encoded) {
7081 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7082 Err(error) => {
7083 dlg.response_json_decode_error(&encoded, &error);
7084 return Err(common::Error::JsonDecodeError(
7085 encoded.to_string(),
7086 error,
7087 ));
7088 }
7089 }
7090 };
7091
7092 dlg.finished(true);
7093 return Ok(response);
7094 }
7095 }
7096 }
7097 }
7098
7099 ///
7100 /// Sets the *request* property to the given value.
7101 ///
7102 /// Even though the property as already been set when instantiating this call,
7103 /// we provide this method for API completeness.
7104 pub fn request(mut self, new_value: Page) -> PageInsertCall<'a, C> {
7105 self._request = new_value;
7106 self
7107 }
7108 ///
7109 /// Sets the *blog id* path property to the given value.
7110 ///
7111 /// Even though the property as already been set when instantiating this call,
7112 /// we provide this method for API completeness.
7113 pub fn blog_id(mut self, new_value: &str) -> PageInsertCall<'a, C> {
7114 self._blog_id = new_value.to_string();
7115 self
7116 }
7117 ///
7118 /// Sets the *is draft* query property to the given value.
7119 pub fn is_draft(mut self, new_value: bool) -> PageInsertCall<'a, C> {
7120 self._is_draft = Some(new_value);
7121 self
7122 }
7123 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7124 /// while executing the actual API request.
7125 ///
7126 /// ````text
7127 /// It should be used to handle progress information, and to implement a certain level of resilience.
7128 /// ````
7129 ///
7130 /// Sets the *delegate* property to the given value.
7131 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageInsertCall<'a, C> {
7132 self._delegate = Some(new_value);
7133 self
7134 }
7135
7136 /// Set any additional parameter of the query string used in the request.
7137 /// It should be used to set parameters which are not yet available through their own
7138 /// setters.
7139 ///
7140 /// Please note that this method must not be used to set any of the known parameters
7141 /// which have their own setter method. If done anyway, the request will fail.
7142 ///
7143 /// # Additional Parameters
7144 ///
7145 /// * *$.xgafv* (query-string) - V1 error format.
7146 /// * *access_token* (query-string) - OAuth access token.
7147 /// * *alt* (query-string) - Data format for response.
7148 /// * *callback* (query-string) - JSONP
7149 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7150 /// * *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.
7151 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7152 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7153 /// * *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.
7154 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7155 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7156 pub fn param<T>(mut self, name: T, value: T) -> PageInsertCall<'a, C>
7157 where
7158 T: AsRef<str>,
7159 {
7160 self._additional_params
7161 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7162 self
7163 }
7164
7165 /// Identifies the authorization scope for the method you are building.
7166 ///
7167 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7168 /// [`Scope::Full`].
7169 ///
7170 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7171 /// tokens for more than one scope.
7172 ///
7173 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7174 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7175 /// sufficient, a read-write scope will do as well.
7176 pub fn add_scope<St>(mut self, scope: St) -> PageInsertCall<'a, C>
7177 where
7178 St: AsRef<str>,
7179 {
7180 self._scopes.insert(String::from(scope.as_ref()));
7181 self
7182 }
7183 /// Identifies the authorization scope(s) for the method you are building.
7184 ///
7185 /// See [`Self::add_scope()`] for details.
7186 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageInsertCall<'a, C>
7187 where
7188 I: IntoIterator<Item = St>,
7189 St: AsRef<str>,
7190 {
7191 self._scopes
7192 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7193 self
7194 }
7195
7196 /// Removes all scopes, and no default scope will be used either.
7197 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7198 /// for details).
7199 pub fn clear_scopes(mut self) -> PageInsertCall<'a, C> {
7200 self._scopes.clear();
7201 self
7202 }
7203}
7204
7205/// Lists pages.
7206///
7207/// A builder for the *list* method supported by a *page* resource.
7208/// It is not used directly, but through a [`PageMethods`] instance.
7209///
7210/// # Example
7211///
7212/// Instantiate a resource method builder
7213///
7214/// ```test_harness,no_run
7215/// # extern crate hyper;
7216/// # extern crate hyper_rustls;
7217/// # extern crate google_blogger3 as blogger3;
7218/// # async fn dox() {
7219/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7220///
7221/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7222/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7223/// # .with_native_roots()
7224/// # .unwrap()
7225/// # .https_only()
7226/// # .enable_http2()
7227/// # .build();
7228///
7229/// # let executor = hyper_util::rt::TokioExecutor::new();
7230/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7231/// # secret,
7232/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7233/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7234/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7235/// # ),
7236/// # ).build().await.unwrap();
7237///
7238/// # let client = hyper_util::client::legacy::Client::builder(
7239/// # hyper_util::rt::TokioExecutor::new()
7240/// # )
7241/// # .build(
7242/// # hyper_rustls::HttpsConnectorBuilder::new()
7243/// # .with_native_roots()
7244/// # .unwrap()
7245/// # .https_or_http()
7246/// # .enable_http2()
7247/// # .build()
7248/// # );
7249/// # let mut hub = Blogger::new(client, auth);
7250/// // You can configure optional parameters by calling the respective setters at will, and
7251/// // execute the final call using `doit()`.
7252/// // Values shown here are possibly random and not representative !
7253/// let result = hub.pages().list("blogId")
7254/// .view("invidunt")
7255/// .add_status("no")
7256/// .page_token("est")
7257/// .max_results(74)
7258/// .fetch_bodies(true)
7259/// .doit().await;
7260/// # }
7261/// ```
7262pub struct PageListCall<'a, C>
7263where
7264 C: 'a,
7265{
7266 hub: &'a Blogger<C>,
7267 _blog_id: String,
7268 _view: Option<String>,
7269 _status: Vec<String>,
7270 _page_token: Option<String>,
7271 _max_results: Option<u32>,
7272 _fetch_bodies: Option<bool>,
7273 _delegate: Option<&'a mut dyn common::Delegate>,
7274 _additional_params: HashMap<String, String>,
7275 _scopes: BTreeSet<String>,
7276}
7277
7278impl<'a, C> common::CallBuilder for PageListCall<'a, C> {}
7279
7280impl<'a, C> PageListCall<'a, C>
7281where
7282 C: common::Connector,
7283{
7284 /// Perform the operation you have build so far.
7285 pub async fn doit(mut self) -> common::Result<(common::Response, PageList)> {
7286 use std::borrow::Cow;
7287 use std::io::{Read, Seek};
7288
7289 use common::{url::Params, ToParts};
7290 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7291
7292 let mut dd = common::DefaultDelegate;
7293 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7294 dlg.begin(common::MethodInfo {
7295 id: "blogger.pages.list",
7296 http_method: hyper::Method::GET,
7297 });
7298
7299 for &field in [
7300 "alt",
7301 "blogId",
7302 "view",
7303 "status",
7304 "pageToken",
7305 "maxResults",
7306 "fetchBodies",
7307 ]
7308 .iter()
7309 {
7310 if self._additional_params.contains_key(field) {
7311 dlg.finished(false);
7312 return Err(common::Error::FieldClash(field));
7313 }
7314 }
7315
7316 let mut params = Params::with_capacity(8 + self._additional_params.len());
7317 params.push("blogId", self._blog_id);
7318 if let Some(value) = self._view.as_ref() {
7319 params.push("view", value);
7320 }
7321 if !self._status.is_empty() {
7322 for f in self._status.iter() {
7323 params.push("status", f);
7324 }
7325 }
7326 if let Some(value) = self._page_token.as_ref() {
7327 params.push("pageToken", value);
7328 }
7329 if let Some(value) = self._max_results.as_ref() {
7330 params.push("maxResults", value.to_string());
7331 }
7332 if let Some(value) = self._fetch_bodies.as_ref() {
7333 params.push("fetchBodies", value.to_string());
7334 }
7335
7336 params.extend(self._additional_params.iter());
7337
7338 params.push("alt", "json");
7339 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages";
7340 if self._scopes.is_empty() {
7341 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7342 }
7343
7344 #[allow(clippy::single_element_loop)]
7345 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
7346 url = params.uri_replacement(url, param_name, find_this, false);
7347 }
7348 {
7349 let to_remove = ["blogId"];
7350 params.remove_params(&to_remove);
7351 }
7352
7353 let url = params.parse_with_url(&url);
7354
7355 loop {
7356 let token = match self
7357 .hub
7358 .auth
7359 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7360 .await
7361 {
7362 Ok(token) => token,
7363 Err(e) => match dlg.token(e) {
7364 Ok(token) => token,
7365 Err(e) => {
7366 dlg.finished(false);
7367 return Err(common::Error::MissingToken(e));
7368 }
7369 },
7370 };
7371 let mut req_result = {
7372 let client = &self.hub.client;
7373 dlg.pre_request();
7374 let mut req_builder = hyper::Request::builder()
7375 .method(hyper::Method::GET)
7376 .uri(url.as_str())
7377 .header(USER_AGENT, self.hub._user_agent.clone());
7378
7379 if let Some(token) = token.as_ref() {
7380 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7381 }
7382
7383 let request = req_builder
7384 .header(CONTENT_LENGTH, 0_u64)
7385 .body(common::to_body::<String>(None));
7386
7387 client.request(request.unwrap()).await
7388 };
7389
7390 match req_result {
7391 Err(err) => {
7392 if let common::Retry::After(d) = dlg.http_error(&err) {
7393 sleep(d).await;
7394 continue;
7395 }
7396 dlg.finished(false);
7397 return Err(common::Error::HttpError(err));
7398 }
7399 Ok(res) => {
7400 let (mut parts, body) = res.into_parts();
7401 let mut body = common::Body::new(body);
7402 if !parts.status.is_success() {
7403 let bytes = common::to_bytes(body).await.unwrap_or_default();
7404 let error = serde_json::from_str(&common::to_string(&bytes));
7405 let response = common::to_response(parts, bytes.into());
7406
7407 if let common::Retry::After(d) =
7408 dlg.http_failure(&response, error.as_ref().ok())
7409 {
7410 sleep(d).await;
7411 continue;
7412 }
7413
7414 dlg.finished(false);
7415
7416 return Err(match error {
7417 Ok(value) => common::Error::BadRequest(value),
7418 _ => common::Error::Failure(response),
7419 });
7420 }
7421 let response = {
7422 let bytes = common::to_bytes(body).await.unwrap_or_default();
7423 let encoded = common::to_string(&bytes);
7424 match serde_json::from_str(&encoded) {
7425 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7426 Err(error) => {
7427 dlg.response_json_decode_error(&encoded, &error);
7428 return Err(common::Error::JsonDecodeError(
7429 encoded.to_string(),
7430 error,
7431 ));
7432 }
7433 }
7434 };
7435
7436 dlg.finished(true);
7437 return Ok(response);
7438 }
7439 }
7440 }
7441 }
7442
7443 ///
7444 /// Sets the *blog id* path property to the given value.
7445 ///
7446 /// Even though the property as already been set when instantiating this call,
7447 /// we provide this method for API completeness.
7448 pub fn blog_id(mut self, new_value: &str) -> PageListCall<'a, C> {
7449 self._blog_id = new_value.to_string();
7450 self
7451 }
7452 ///
7453 /// Sets the *view* query property to the given value.
7454 pub fn view(mut self, new_value: &str) -> PageListCall<'a, C> {
7455 self._view = Some(new_value.to_string());
7456 self
7457 }
7458 ///
7459 /// Append the given value to the *status* query property.
7460 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7461 pub fn add_status(mut self, new_value: &str) -> PageListCall<'a, C> {
7462 self._status.push(new_value.to_string());
7463 self
7464 }
7465 ///
7466 /// Sets the *page token* query property to the given value.
7467 pub fn page_token(mut self, new_value: &str) -> PageListCall<'a, C> {
7468 self._page_token = Some(new_value.to_string());
7469 self
7470 }
7471 ///
7472 /// Sets the *max results* query property to the given value.
7473 pub fn max_results(mut self, new_value: u32) -> PageListCall<'a, C> {
7474 self._max_results = Some(new_value);
7475 self
7476 }
7477 ///
7478 /// Sets the *fetch bodies* query property to the given value.
7479 pub fn fetch_bodies(mut self, new_value: bool) -> PageListCall<'a, C> {
7480 self._fetch_bodies = Some(new_value);
7481 self
7482 }
7483 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7484 /// while executing the actual API request.
7485 ///
7486 /// ````text
7487 /// It should be used to handle progress information, and to implement a certain level of resilience.
7488 /// ````
7489 ///
7490 /// Sets the *delegate* property to the given value.
7491 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageListCall<'a, C> {
7492 self._delegate = Some(new_value);
7493 self
7494 }
7495
7496 /// Set any additional parameter of the query string used in the request.
7497 /// It should be used to set parameters which are not yet available through their own
7498 /// setters.
7499 ///
7500 /// Please note that this method must not be used to set any of the known parameters
7501 /// which have their own setter method. If done anyway, the request will fail.
7502 ///
7503 /// # Additional Parameters
7504 ///
7505 /// * *$.xgafv* (query-string) - V1 error format.
7506 /// * *access_token* (query-string) - OAuth access token.
7507 /// * *alt* (query-string) - Data format for response.
7508 /// * *callback* (query-string) - JSONP
7509 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7510 /// * *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.
7511 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7512 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7513 /// * *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.
7514 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7515 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7516 pub fn param<T>(mut self, name: T, value: T) -> PageListCall<'a, C>
7517 where
7518 T: AsRef<str>,
7519 {
7520 self._additional_params
7521 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7522 self
7523 }
7524
7525 /// Identifies the authorization scope for the method you are building.
7526 ///
7527 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7528 /// [`Scope::Readonly`].
7529 ///
7530 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7531 /// tokens for more than one scope.
7532 ///
7533 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7534 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7535 /// sufficient, a read-write scope will do as well.
7536 pub fn add_scope<St>(mut self, scope: St) -> PageListCall<'a, C>
7537 where
7538 St: AsRef<str>,
7539 {
7540 self._scopes.insert(String::from(scope.as_ref()));
7541 self
7542 }
7543 /// Identifies the authorization scope(s) for the method you are building.
7544 ///
7545 /// See [`Self::add_scope()`] for details.
7546 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageListCall<'a, C>
7547 where
7548 I: IntoIterator<Item = St>,
7549 St: AsRef<str>,
7550 {
7551 self._scopes
7552 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7553 self
7554 }
7555
7556 /// Removes all scopes, and no default scope will be used either.
7557 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7558 /// for details).
7559 pub fn clear_scopes(mut self) -> PageListCall<'a, C> {
7560 self._scopes.clear();
7561 self
7562 }
7563}
7564
7565/// Patches a page.
7566///
7567/// A builder for the *patch* method supported by a *page* resource.
7568/// It is not used directly, but through a [`PageMethods`] instance.
7569///
7570/// # Example
7571///
7572/// Instantiate a resource method builder
7573///
7574/// ```test_harness,no_run
7575/// # extern crate hyper;
7576/// # extern crate hyper_rustls;
7577/// # extern crate google_blogger3 as blogger3;
7578/// use blogger3::api::Page;
7579/// # async fn dox() {
7580/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7581///
7582/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7583/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7584/// # .with_native_roots()
7585/// # .unwrap()
7586/// # .https_only()
7587/// # .enable_http2()
7588/// # .build();
7589///
7590/// # let executor = hyper_util::rt::TokioExecutor::new();
7591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7592/// # secret,
7593/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7594/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7595/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7596/// # ),
7597/// # ).build().await.unwrap();
7598///
7599/// # let client = hyper_util::client::legacy::Client::builder(
7600/// # hyper_util::rt::TokioExecutor::new()
7601/// # )
7602/// # .build(
7603/// # hyper_rustls::HttpsConnectorBuilder::new()
7604/// # .with_native_roots()
7605/// # .unwrap()
7606/// # .https_or_http()
7607/// # .enable_http2()
7608/// # .build()
7609/// # );
7610/// # let mut hub = Blogger::new(client, auth);
7611/// // As the method needs a request, you would usually fill it with the desired information
7612/// // into the respective structure. Some of the parts shown here might not be applicable !
7613/// // Values shown here are possibly random and not representative !
7614/// let mut req = Page::default();
7615///
7616/// // You can configure optional parameters by calling the respective setters at will, and
7617/// // execute the final call using `doit()`.
7618/// // Values shown here are possibly random and not representative !
7619/// let result = hub.pages().patch(req, "blogId", "pageId")
7620/// .revert(true)
7621/// .publish(true)
7622/// .doit().await;
7623/// # }
7624/// ```
7625pub struct PagePatchCall<'a, C>
7626where
7627 C: 'a,
7628{
7629 hub: &'a Blogger<C>,
7630 _request: Page,
7631 _blog_id: String,
7632 _page_id: String,
7633 _revert: Option<bool>,
7634 _publish: Option<bool>,
7635 _delegate: Option<&'a mut dyn common::Delegate>,
7636 _additional_params: HashMap<String, String>,
7637 _scopes: BTreeSet<String>,
7638}
7639
7640impl<'a, C> common::CallBuilder for PagePatchCall<'a, C> {}
7641
7642impl<'a, C> PagePatchCall<'a, C>
7643where
7644 C: common::Connector,
7645{
7646 /// Perform the operation you have build so far.
7647 pub async fn doit(mut self) -> common::Result<(common::Response, Page)> {
7648 use std::borrow::Cow;
7649 use std::io::{Read, Seek};
7650
7651 use common::{url::Params, ToParts};
7652 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7653
7654 let mut dd = common::DefaultDelegate;
7655 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7656 dlg.begin(common::MethodInfo {
7657 id: "blogger.pages.patch",
7658 http_method: hyper::Method::PATCH,
7659 });
7660
7661 for &field in ["alt", "blogId", "pageId", "revert", "publish"].iter() {
7662 if self._additional_params.contains_key(field) {
7663 dlg.finished(false);
7664 return Err(common::Error::FieldClash(field));
7665 }
7666 }
7667
7668 let mut params = Params::with_capacity(7 + self._additional_params.len());
7669 params.push("blogId", self._blog_id);
7670 params.push("pageId", self._page_id);
7671 if let Some(value) = self._revert.as_ref() {
7672 params.push("revert", value.to_string());
7673 }
7674 if let Some(value) = self._publish.as_ref() {
7675 params.push("publish", value.to_string());
7676 }
7677
7678 params.extend(self._additional_params.iter());
7679
7680 params.push("alt", "json");
7681 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages/{pageId}";
7682 if self._scopes.is_empty() {
7683 self._scopes.insert(Scope::Full.as_ref().to_string());
7684 }
7685
7686 #[allow(clippy::single_element_loop)]
7687 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{pageId}", "pageId")].iter() {
7688 url = params.uri_replacement(url, param_name, find_this, false);
7689 }
7690 {
7691 let to_remove = ["pageId", "blogId"];
7692 params.remove_params(&to_remove);
7693 }
7694
7695 let url = params.parse_with_url(&url);
7696
7697 let mut json_mime_type = mime::APPLICATION_JSON;
7698 let mut request_value_reader = {
7699 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7700 common::remove_json_null_values(&mut value);
7701 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7702 serde_json::to_writer(&mut dst, &value).unwrap();
7703 dst
7704 };
7705 let request_size = request_value_reader
7706 .seek(std::io::SeekFrom::End(0))
7707 .unwrap();
7708 request_value_reader
7709 .seek(std::io::SeekFrom::Start(0))
7710 .unwrap();
7711
7712 loop {
7713 let token = match self
7714 .hub
7715 .auth
7716 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7717 .await
7718 {
7719 Ok(token) => token,
7720 Err(e) => match dlg.token(e) {
7721 Ok(token) => token,
7722 Err(e) => {
7723 dlg.finished(false);
7724 return Err(common::Error::MissingToken(e));
7725 }
7726 },
7727 };
7728 request_value_reader
7729 .seek(std::io::SeekFrom::Start(0))
7730 .unwrap();
7731 let mut req_result = {
7732 let client = &self.hub.client;
7733 dlg.pre_request();
7734 let mut req_builder = hyper::Request::builder()
7735 .method(hyper::Method::PATCH)
7736 .uri(url.as_str())
7737 .header(USER_AGENT, self.hub._user_agent.clone());
7738
7739 if let Some(token) = token.as_ref() {
7740 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7741 }
7742
7743 let request = req_builder
7744 .header(CONTENT_TYPE, json_mime_type.to_string())
7745 .header(CONTENT_LENGTH, request_size as u64)
7746 .body(common::to_body(
7747 request_value_reader.get_ref().clone().into(),
7748 ));
7749
7750 client.request(request.unwrap()).await
7751 };
7752
7753 match req_result {
7754 Err(err) => {
7755 if let common::Retry::After(d) = dlg.http_error(&err) {
7756 sleep(d).await;
7757 continue;
7758 }
7759 dlg.finished(false);
7760 return Err(common::Error::HttpError(err));
7761 }
7762 Ok(res) => {
7763 let (mut parts, body) = res.into_parts();
7764 let mut body = common::Body::new(body);
7765 if !parts.status.is_success() {
7766 let bytes = common::to_bytes(body).await.unwrap_or_default();
7767 let error = serde_json::from_str(&common::to_string(&bytes));
7768 let response = common::to_response(parts, bytes.into());
7769
7770 if let common::Retry::After(d) =
7771 dlg.http_failure(&response, error.as_ref().ok())
7772 {
7773 sleep(d).await;
7774 continue;
7775 }
7776
7777 dlg.finished(false);
7778
7779 return Err(match error {
7780 Ok(value) => common::Error::BadRequest(value),
7781 _ => common::Error::Failure(response),
7782 });
7783 }
7784 let response = {
7785 let bytes = common::to_bytes(body).await.unwrap_or_default();
7786 let encoded = common::to_string(&bytes);
7787 match serde_json::from_str(&encoded) {
7788 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7789 Err(error) => {
7790 dlg.response_json_decode_error(&encoded, &error);
7791 return Err(common::Error::JsonDecodeError(
7792 encoded.to_string(),
7793 error,
7794 ));
7795 }
7796 }
7797 };
7798
7799 dlg.finished(true);
7800 return Ok(response);
7801 }
7802 }
7803 }
7804 }
7805
7806 ///
7807 /// Sets the *request* property to the given value.
7808 ///
7809 /// Even though the property as already been set when instantiating this call,
7810 /// we provide this method for API completeness.
7811 pub fn request(mut self, new_value: Page) -> PagePatchCall<'a, C> {
7812 self._request = new_value;
7813 self
7814 }
7815 ///
7816 /// Sets the *blog id* path property to the given value.
7817 ///
7818 /// Even though the property as already been set when instantiating this call,
7819 /// we provide this method for API completeness.
7820 pub fn blog_id(mut self, new_value: &str) -> PagePatchCall<'a, C> {
7821 self._blog_id = new_value.to_string();
7822 self
7823 }
7824 ///
7825 /// Sets the *page id* path property to the given value.
7826 ///
7827 /// Even though the property as already been set when instantiating this call,
7828 /// we provide this method for API completeness.
7829 pub fn page_id(mut self, new_value: &str) -> PagePatchCall<'a, C> {
7830 self._page_id = new_value.to_string();
7831 self
7832 }
7833 ///
7834 /// Sets the *revert* query property to the given value.
7835 pub fn revert(mut self, new_value: bool) -> PagePatchCall<'a, C> {
7836 self._revert = Some(new_value);
7837 self
7838 }
7839 ///
7840 /// Sets the *publish* query property to the given value.
7841 pub fn publish(mut self, new_value: bool) -> PagePatchCall<'a, C> {
7842 self._publish = Some(new_value);
7843 self
7844 }
7845 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7846 /// while executing the actual API request.
7847 ///
7848 /// ````text
7849 /// It should be used to handle progress information, and to implement a certain level of resilience.
7850 /// ````
7851 ///
7852 /// Sets the *delegate* property to the given value.
7853 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PagePatchCall<'a, C> {
7854 self._delegate = Some(new_value);
7855 self
7856 }
7857
7858 /// Set any additional parameter of the query string used in the request.
7859 /// It should be used to set parameters which are not yet available through their own
7860 /// setters.
7861 ///
7862 /// Please note that this method must not be used to set any of the known parameters
7863 /// which have their own setter method. If done anyway, the request will fail.
7864 ///
7865 /// # Additional Parameters
7866 ///
7867 /// * *$.xgafv* (query-string) - V1 error format.
7868 /// * *access_token* (query-string) - OAuth access token.
7869 /// * *alt* (query-string) - Data format for response.
7870 /// * *callback* (query-string) - JSONP
7871 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7872 /// * *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.
7873 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7874 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7875 /// * *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.
7876 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7877 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7878 pub fn param<T>(mut self, name: T, value: T) -> PagePatchCall<'a, C>
7879 where
7880 T: AsRef<str>,
7881 {
7882 self._additional_params
7883 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7884 self
7885 }
7886
7887 /// Identifies the authorization scope for the method you are building.
7888 ///
7889 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7890 /// [`Scope::Full`].
7891 ///
7892 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7893 /// tokens for more than one scope.
7894 ///
7895 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7896 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7897 /// sufficient, a read-write scope will do as well.
7898 pub fn add_scope<St>(mut self, scope: St) -> PagePatchCall<'a, C>
7899 where
7900 St: AsRef<str>,
7901 {
7902 self._scopes.insert(String::from(scope.as_ref()));
7903 self
7904 }
7905 /// Identifies the authorization scope(s) for the method you are building.
7906 ///
7907 /// See [`Self::add_scope()`] for details.
7908 pub fn add_scopes<I, St>(mut self, scopes: I) -> PagePatchCall<'a, C>
7909 where
7910 I: IntoIterator<Item = St>,
7911 St: AsRef<str>,
7912 {
7913 self._scopes
7914 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7915 self
7916 }
7917
7918 /// Removes all scopes, and no default scope will be used either.
7919 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7920 /// for details).
7921 pub fn clear_scopes(mut self) -> PagePatchCall<'a, C> {
7922 self._scopes.clear();
7923 self
7924 }
7925}
7926
7927/// Publishes a page.
7928///
7929/// A builder for the *publish* method supported by a *page* resource.
7930/// It is not used directly, but through a [`PageMethods`] instance.
7931///
7932/// # Example
7933///
7934/// Instantiate a resource method builder
7935///
7936/// ```test_harness,no_run
7937/// # extern crate hyper;
7938/// # extern crate hyper_rustls;
7939/// # extern crate google_blogger3 as blogger3;
7940/// # async fn dox() {
7941/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7942///
7943/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7944/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7945/// # .with_native_roots()
7946/// # .unwrap()
7947/// # .https_only()
7948/// # .enable_http2()
7949/// # .build();
7950///
7951/// # let executor = hyper_util::rt::TokioExecutor::new();
7952/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7953/// # secret,
7954/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7955/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7956/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7957/// # ),
7958/// # ).build().await.unwrap();
7959///
7960/// # let client = hyper_util::client::legacy::Client::builder(
7961/// # hyper_util::rt::TokioExecutor::new()
7962/// # )
7963/// # .build(
7964/// # hyper_rustls::HttpsConnectorBuilder::new()
7965/// # .with_native_roots()
7966/// # .unwrap()
7967/// # .https_or_http()
7968/// # .enable_http2()
7969/// # .build()
7970/// # );
7971/// # let mut hub = Blogger::new(client, auth);
7972/// // You can configure optional parameters by calling the respective setters at will, and
7973/// // execute the final call using `doit()`.
7974/// // Values shown here are possibly random and not representative !
7975/// let result = hub.pages().publish("blogId", "pageId")
7976/// .doit().await;
7977/// # }
7978/// ```
7979pub struct PagePublishCall<'a, C>
7980where
7981 C: 'a,
7982{
7983 hub: &'a Blogger<C>,
7984 _blog_id: String,
7985 _page_id: String,
7986 _delegate: Option<&'a mut dyn common::Delegate>,
7987 _additional_params: HashMap<String, String>,
7988 _scopes: BTreeSet<String>,
7989}
7990
7991impl<'a, C> common::CallBuilder for PagePublishCall<'a, C> {}
7992
7993impl<'a, C> PagePublishCall<'a, C>
7994where
7995 C: common::Connector,
7996{
7997 /// Perform the operation you have build so far.
7998 pub async fn doit(mut self) -> common::Result<(common::Response, Page)> {
7999 use std::borrow::Cow;
8000 use std::io::{Read, Seek};
8001
8002 use common::{url::Params, ToParts};
8003 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8004
8005 let mut dd = common::DefaultDelegate;
8006 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8007 dlg.begin(common::MethodInfo {
8008 id: "blogger.pages.publish",
8009 http_method: hyper::Method::POST,
8010 });
8011
8012 for &field in ["alt", "blogId", "pageId"].iter() {
8013 if self._additional_params.contains_key(field) {
8014 dlg.finished(false);
8015 return Err(common::Error::FieldClash(field));
8016 }
8017 }
8018
8019 let mut params = Params::with_capacity(4 + self._additional_params.len());
8020 params.push("blogId", self._blog_id);
8021 params.push("pageId", self._page_id);
8022
8023 params.extend(self._additional_params.iter());
8024
8025 params.push("alt", "json");
8026 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages/{pageId}/publish";
8027 if self._scopes.is_empty() {
8028 self._scopes.insert(Scope::Full.as_ref().to_string());
8029 }
8030
8031 #[allow(clippy::single_element_loop)]
8032 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{pageId}", "pageId")].iter() {
8033 url = params.uri_replacement(url, param_name, find_this, false);
8034 }
8035 {
8036 let to_remove = ["pageId", "blogId"];
8037 params.remove_params(&to_remove);
8038 }
8039
8040 let url = params.parse_with_url(&url);
8041
8042 loop {
8043 let token = match self
8044 .hub
8045 .auth
8046 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8047 .await
8048 {
8049 Ok(token) => token,
8050 Err(e) => match dlg.token(e) {
8051 Ok(token) => token,
8052 Err(e) => {
8053 dlg.finished(false);
8054 return Err(common::Error::MissingToken(e));
8055 }
8056 },
8057 };
8058 let mut req_result = {
8059 let client = &self.hub.client;
8060 dlg.pre_request();
8061 let mut req_builder = hyper::Request::builder()
8062 .method(hyper::Method::POST)
8063 .uri(url.as_str())
8064 .header(USER_AGENT, self.hub._user_agent.clone());
8065
8066 if let Some(token) = token.as_ref() {
8067 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8068 }
8069
8070 let request = req_builder
8071 .header(CONTENT_LENGTH, 0_u64)
8072 .body(common::to_body::<String>(None));
8073
8074 client.request(request.unwrap()).await
8075 };
8076
8077 match req_result {
8078 Err(err) => {
8079 if let common::Retry::After(d) = dlg.http_error(&err) {
8080 sleep(d).await;
8081 continue;
8082 }
8083 dlg.finished(false);
8084 return Err(common::Error::HttpError(err));
8085 }
8086 Ok(res) => {
8087 let (mut parts, body) = res.into_parts();
8088 let mut body = common::Body::new(body);
8089 if !parts.status.is_success() {
8090 let bytes = common::to_bytes(body).await.unwrap_or_default();
8091 let error = serde_json::from_str(&common::to_string(&bytes));
8092 let response = common::to_response(parts, bytes.into());
8093
8094 if let common::Retry::After(d) =
8095 dlg.http_failure(&response, error.as_ref().ok())
8096 {
8097 sleep(d).await;
8098 continue;
8099 }
8100
8101 dlg.finished(false);
8102
8103 return Err(match error {
8104 Ok(value) => common::Error::BadRequest(value),
8105 _ => common::Error::Failure(response),
8106 });
8107 }
8108 let response = {
8109 let bytes = common::to_bytes(body).await.unwrap_or_default();
8110 let encoded = common::to_string(&bytes);
8111 match serde_json::from_str(&encoded) {
8112 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8113 Err(error) => {
8114 dlg.response_json_decode_error(&encoded, &error);
8115 return Err(common::Error::JsonDecodeError(
8116 encoded.to_string(),
8117 error,
8118 ));
8119 }
8120 }
8121 };
8122
8123 dlg.finished(true);
8124 return Ok(response);
8125 }
8126 }
8127 }
8128 }
8129
8130 ///
8131 /// Sets the *blog id* path property to the given value.
8132 ///
8133 /// Even though the property as already been set when instantiating this call,
8134 /// we provide this method for API completeness.
8135 pub fn blog_id(mut self, new_value: &str) -> PagePublishCall<'a, C> {
8136 self._blog_id = new_value.to_string();
8137 self
8138 }
8139 ///
8140 /// Sets the *page id* path property to the given value.
8141 ///
8142 /// Even though the property as already been set when instantiating this call,
8143 /// we provide this method for API completeness.
8144 pub fn page_id(mut self, new_value: &str) -> PagePublishCall<'a, C> {
8145 self._page_id = new_value.to_string();
8146 self
8147 }
8148 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8149 /// while executing the actual API request.
8150 ///
8151 /// ````text
8152 /// It should be used to handle progress information, and to implement a certain level of resilience.
8153 /// ````
8154 ///
8155 /// Sets the *delegate* property to the given value.
8156 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PagePublishCall<'a, C> {
8157 self._delegate = Some(new_value);
8158 self
8159 }
8160
8161 /// Set any additional parameter of the query string used in the request.
8162 /// It should be used to set parameters which are not yet available through their own
8163 /// setters.
8164 ///
8165 /// Please note that this method must not be used to set any of the known parameters
8166 /// which have their own setter method. If done anyway, the request will fail.
8167 ///
8168 /// # Additional Parameters
8169 ///
8170 /// * *$.xgafv* (query-string) - V1 error format.
8171 /// * *access_token* (query-string) - OAuth access token.
8172 /// * *alt* (query-string) - Data format for response.
8173 /// * *callback* (query-string) - JSONP
8174 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8175 /// * *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.
8176 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8177 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8178 /// * *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.
8179 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8180 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8181 pub fn param<T>(mut self, name: T, value: T) -> PagePublishCall<'a, C>
8182 where
8183 T: AsRef<str>,
8184 {
8185 self._additional_params
8186 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8187 self
8188 }
8189
8190 /// Identifies the authorization scope for the method you are building.
8191 ///
8192 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8193 /// [`Scope::Full`].
8194 ///
8195 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8196 /// tokens for more than one scope.
8197 ///
8198 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8199 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8200 /// sufficient, a read-write scope will do as well.
8201 pub fn add_scope<St>(mut self, scope: St) -> PagePublishCall<'a, C>
8202 where
8203 St: AsRef<str>,
8204 {
8205 self._scopes.insert(String::from(scope.as_ref()));
8206 self
8207 }
8208 /// Identifies the authorization scope(s) for the method you are building.
8209 ///
8210 /// See [`Self::add_scope()`] for details.
8211 pub fn add_scopes<I, St>(mut self, scopes: I) -> PagePublishCall<'a, C>
8212 where
8213 I: IntoIterator<Item = St>,
8214 St: AsRef<str>,
8215 {
8216 self._scopes
8217 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8218 self
8219 }
8220
8221 /// Removes all scopes, and no default scope will be used either.
8222 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8223 /// for details).
8224 pub fn clear_scopes(mut self) -> PagePublishCall<'a, C> {
8225 self._scopes.clear();
8226 self
8227 }
8228}
8229
8230/// Reverts a published or scheduled page to draft state.
8231///
8232/// A builder for the *revert* method supported by a *page* resource.
8233/// It is not used directly, but through a [`PageMethods`] instance.
8234///
8235/// # Example
8236///
8237/// Instantiate a resource method builder
8238///
8239/// ```test_harness,no_run
8240/// # extern crate hyper;
8241/// # extern crate hyper_rustls;
8242/// # extern crate google_blogger3 as blogger3;
8243/// # async fn dox() {
8244/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8245///
8246/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8247/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8248/// # .with_native_roots()
8249/// # .unwrap()
8250/// # .https_only()
8251/// # .enable_http2()
8252/// # .build();
8253///
8254/// # let executor = hyper_util::rt::TokioExecutor::new();
8255/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8256/// # secret,
8257/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8258/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8259/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8260/// # ),
8261/// # ).build().await.unwrap();
8262///
8263/// # let client = hyper_util::client::legacy::Client::builder(
8264/// # hyper_util::rt::TokioExecutor::new()
8265/// # )
8266/// # .build(
8267/// # hyper_rustls::HttpsConnectorBuilder::new()
8268/// # .with_native_roots()
8269/// # .unwrap()
8270/// # .https_or_http()
8271/// # .enable_http2()
8272/// # .build()
8273/// # );
8274/// # let mut hub = Blogger::new(client, auth);
8275/// // You can configure optional parameters by calling the respective setters at will, and
8276/// // execute the final call using `doit()`.
8277/// // Values shown here are possibly random and not representative !
8278/// let result = hub.pages().revert("blogId", "pageId")
8279/// .doit().await;
8280/// # }
8281/// ```
8282pub struct PageRevertCall<'a, C>
8283where
8284 C: 'a,
8285{
8286 hub: &'a Blogger<C>,
8287 _blog_id: String,
8288 _page_id: String,
8289 _delegate: Option<&'a mut dyn common::Delegate>,
8290 _additional_params: HashMap<String, String>,
8291 _scopes: BTreeSet<String>,
8292}
8293
8294impl<'a, C> common::CallBuilder for PageRevertCall<'a, C> {}
8295
8296impl<'a, C> PageRevertCall<'a, C>
8297where
8298 C: common::Connector,
8299{
8300 /// Perform the operation you have build so far.
8301 pub async fn doit(mut self) -> common::Result<(common::Response, Page)> {
8302 use std::borrow::Cow;
8303 use std::io::{Read, Seek};
8304
8305 use common::{url::Params, ToParts};
8306 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8307
8308 let mut dd = common::DefaultDelegate;
8309 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8310 dlg.begin(common::MethodInfo {
8311 id: "blogger.pages.revert",
8312 http_method: hyper::Method::POST,
8313 });
8314
8315 for &field in ["alt", "blogId", "pageId"].iter() {
8316 if self._additional_params.contains_key(field) {
8317 dlg.finished(false);
8318 return Err(common::Error::FieldClash(field));
8319 }
8320 }
8321
8322 let mut params = Params::with_capacity(4 + self._additional_params.len());
8323 params.push("blogId", self._blog_id);
8324 params.push("pageId", self._page_id);
8325
8326 params.extend(self._additional_params.iter());
8327
8328 params.push("alt", "json");
8329 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages/{pageId}/revert";
8330 if self._scopes.is_empty() {
8331 self._scopes.insert(Scope::Full.as_ref().to_string());
8332 }
8333
8334 #[allow(clippy::single_element_loop)]
8335 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{pageId}", "pageId")].iter() {
8336 url = params.uri_replacement(url, param_name, find_this, false);
8337 }
8338 {
8339 let to_remove = ["pageId", "blogId"];
8340 params.remove_params(&to_remove);
8341 }
8342
8343 let url = params.parse_with_url(&url);
8344
8345 loop {
8346 let token = match self
8347 .hub
8348 .auth
8349 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8350 .await
8351 {
8352 Ok(token) => token,
8353 Err(e) => match dlg.token(e) {
8354 Ok(token) => token,
8355 Err(e) => {
8356 dlg.finished(false);
8357 return Err(common::Error::MissingToken(e));
8358 }
8359 },
8360 };
8361 let mut req_result = {
8362 let client = &self.hub.client;
8363 dlg.pre_request();
8364 let mut req_builder = hyper::Request::builder()
8365 .method(hyper::Method::POST)
8366 .uri(url.as_str())
8367 .header(USER_AGENT, self.hub._user_agent.clone());
8368
8369 if let Some(token) = token.as_ref() {
8370 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8371 }
8372
8373 let request = req_builder
8374 .header(CONTENT_LENGTH, 0_u64)
8375 .body(common::to_body::<String>(None));
8376
8377 client.request(request.unwrap()).await
8378 };
8379
8380 match req_result {
8381 Err(err) => {
8382 if let common::Retry::After(d) = dlg.http_error(&err) {
8383 sleep(d).await;
8384 continue;
8385 }
8386 dlg.finished(false);
8387 return Err(common::Error::HttpError(err));
8388 }
8389 Ok(res) => {
8390 let (mut parts, body) = res.into_parts();
8391 let mut body = common::Body::new(body);
8392 if !parts.status.is_success() {
8393 let bytes = common::to_bytes(body).await.unwrap_or_default();
8394 let error = serde_json::from_str(&common::to_string(&bytes));
8395 let response = common::to_response(parts, bytes.into());
8396
8397 if let common::Retry::After(d) =
8398 dlg.http_failure(&response, error.as_ref().ok())
8399 {
8400 sleep(d).await;
8401 continue;
8402 }
8403
8404 dlg.finished(false);
8405
8406 return Err(match error {
8407 Ok(value) => common::Error::BadRequest(value),
8408 _ => common::Error::Failure(response),
8409 });
8410 }
8411 let response = {
8412 let bytes = common::to_bytes(body).await.unwrap_or_default();
8413 let encoded = common::to_string(&bytes);
8414 match serde_json::from_str(&encoded) {
8415 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8416 Err(error) => {
8417 dlg.response_json_decode_error(&encoded, &error);
8418 return Err(common::Error::JsonDecodeError(
8419 encoded.to_string(),
8420 error,
8421 ));
8422 }
8423 }
8424 };
8425
8426 dlg.finished(true);
8427 return Ok(response);
8428 }
8429 }
8430 }
8431 }
8432
8433 ///
8434 /// Sets the *blog id* path property to the given value.
8435 ///
8436 /// Even though the property as already been set when instantiating this call,
8437 /// we provide this method for API completeness.
8438 pub fn blog_id(mut self, new_value: &str) -> PageRevertCall<'a, C> {
8439 self._blog_id = new_value.to_string();
8440 self
8441 }
8442 ///
8443 /// Sets the *page id* path property to the given value.
8444 ///
8445 /// Even though the property as already been set when instantiating this call,
8446 /// we provide this method for API completeness.
8447 pub fn page_id(mut self, new_value: &str) -> PageRevertCall<'a, C> {
8448 self._page_id = new_value.to_string();
8449 self
8450 }
8451 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8452 /// while executing the actual API request.
8453 ///
8454 /// ````text
8455 /// It should be used to handle progress information, and to implement a certain level of resilience.
8456 /// ````
8457 ///
8458 /// Sets the *delegate* property to the given value.
8459 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageRevertCall<'a, C> {
8460 self._delegate = Some(new_value);
8461 self
8462 }
8463
8464 /// Set any additional parameter of the query string used in the request.
8465 /// It should be used to set parameters which are not yet available through their own
8466 /// setters.
8467 ///
8468 /// Please note that this method must not be used to set any of the known parameters
8469 /// which have their own setter method. If done anyway, the request will fail.
8470 ///
8471 /// # Additional Parameters
8472 ///
8473 /// * *$.xgafv* (query-string) - V1 error format.
8474 /// * *access_token* (query-string) - OAuth access token.
8475 /// * *alt* (query-string) - Data format for response.
8476 /// * *callback* (query-string) - JSONP
8477 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8478 /// * *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.
8479 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8480 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8481 /// * *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.
8482 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8483 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8484 pub fn param<T>(mut self, name: T, value: T) -> PageRevertCall<'a, C>
8485 where
8486 T: AsRef<str>,
8487 {
8488 self._additional_params
8489 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8490 self
8491 }
8492
8493 /// Identifies the authorization scope for the method you are building.
8494 ///
8495 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8496 /// [`Scope::Full`].
8497 ///
8498 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8499 /// tokens for more than one scope.
8500 ///
8501 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8502 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8503 /// sufficient, a read-write scope will do as well.
8504 pub fn add_scope<St>(mut self, scope: St) -> PageRevertCall<'a, C>
8505 where
8506 St: AsRef<str>,
8507 {
8508 self._scopes.insert(String::from(scope.as_ref()));
8509 self
8510 }
8511 /// Identifies the authorization scope(s) for the method you are building.
8512 ///
8513 /// See [`Self::add_scope()`] for details.
8514 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageRevertCall<'a, C>
8515 where
8516 I: IntoIterator<Item = St>,
8517 St: AsRef<str>,
8518 {
8519 self._scopes
8520 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8521 self
8522 }
8523
8524 /// Removes all scopes, and no default scope will be used either.
8525 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8526 /// for details).
8527 pub fn clear_scopes(mut self) -> PageRevertCall<'a, C> {
8528 self._scopes.clear();
8529 self
8530 }
8531}
8532
8533/// Updates a page by blog id and page id.
8534///
8535/// A builder for the *update* method supported by a *page* resource.
8536/// It is not used directly, but through a [`PageMethods`] instance.
8537///
8538/// # Example
8539///
8540/// Instantiate a resource method builder
8541///
8542/// ```test_harness,no_run
8543/// # extern crate hyper;
8544/// # extern crate hyper_rustls;
8545/// # extern crate google_blogger3 as blogger3;
8546/// use blogger3::api::Page;
8547/// # async fn dox() {
8548/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8549///
8550/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8551/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8552/// # .with_native_roots()
8553/// # .unwrap()
8554/// # .https_only()
8555/// # .enable_http2()
8556/// # .build();
8557///
8558/// # let executor = hyper_util::rt::TokioExecutor::new();
8559/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8560/// # secret,
8561/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8562/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8563/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8564/// # ),
8565/// # ).build().await.unwrap();
8566///
8567/// # let client = hyper_util::client::legacy::Client::builder(
8568/// # hyper_util::rt::TokioExecutor::new()
8569/// # )
8570/// # .build(
8571/// # hyper_rustls::HttpsConnectorBuilder::new()
8572/// # .with_native_roots()
8573/// # .unwrap()
8574/// # .https_or_http()
8575/// # .enable_http2()
8576/// # .build()
8577/// # );
8578/// # let mut hub = Blogger::new(client, auth);
8579/// // As the method needs a request, you would usually fill it with the desired information
8580/// // into the respective structure. Some of the parts shown here might not be applicable !
8581/// // Values shown here are possibly random and not representative !
8582/// let mut req = Page::default();
8583///
8584/// // You can configure optional parameters by calling the respective setters at will, and
8585/// // execute the final call using `doit()`.
8586/// // Values shown here are possibly random and not representative !
8587/// let result = hub.pages().update(req, "blogId", "pageId")
8588/// .revert(false)
8589/// .publish(false)
8590/// .doit().await;
8591/// # }
8592/// ```
8593pub struct PageUpdateCall<'a, C>
8594where
8595 C: 'a,
8596{
8597 hub: &'a Blogger<C>,
8598 _request: Page,
8599 _blog_id: String,
8600 _page_id: String,
8601 _revert: Option<bool>,
8602 _publish: Option<bool>,
8603 _delegate: Option<&'a mut dyn common::Delegate>,
8604 _additional_params: HashMap<String, String>,
8605 _scopes: BTreeSet<String>,
8606}
8607
8608impl<'a, C> common::CallBuilder for PageUpdateCall<'a, C> {}
8609
8610impl<'a, C> PageUpdateCall<'a, C>
8611where
8612 C: common::Connector,
8613{
8614 /// Perform the operation you have build so far.
8615 pub async fn doit(mut self) -> common::Result<(common::Response, Page)> {
8616 use std::borrow::Cow;
8617 use std::io::{Read, Seek};
8618
8619 use common::{url::Params, ToParts};
8620 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8621
8622 let mut dd = common::DefaultDelegate;
8623 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8624 dlg.begin(common::MethodInfo {
8625 id: "blogger.pages.update",
8626 http_method: hyper::Method::PUT,
8627 });
8628
8629 for &field in ["alt", "blogId", "pageId", "revert", "publish"].iter() {
8630 if self._additional_params.contains_key(field) {
8631 dlg.finished(false);
8632 return Err(common::Error::FieldClash(field));
8633 }
8634 }
8635
8636 let mut params = Params::with_capacity(7 + self._additional_params.len());
8637 params.push("blogId", self._blog_id);
8638 params.push("pageId", self._page_id);
8639 if let Some(value) = self._revert.as_ref() {
8640 params.push("revert", value.to_string());
8641 }
8642 if let Some(value) = self._publish.as_ref() {
8643 params.push("publish", value.to_string());
8644 }
8645
8646 params.extend(self._additional_params.iter());
8647
8648 params.push("alt", "json");
8649 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/pages/{pageId}";
8650 if self._scopes.is_empty() {
8651 self._scopes.insert(Scope::Full.as_ref().to_string());
8652 }
8653
8654 #[allow(clippy::single_element_loop)]
8655 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{pageId}", "pageId")].iter() {
8656 url = params.uri_replacement(url, param_name, find_this, false);
8657 }
8658 {
8659 let to_remove = ["pageId", "blogId"];
8660 params.remove_params(&to_remove);
8661 }
8662
8663 let url = params.parse_with_url(&url);
8664
8665 let mut json_mime_type = mime::APPLICATION_JSON;
8666 let mut request_value_reader = {
8667 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8668 common::remove_json_null_values(&mut value);
8669 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8670 serde_json::to_writer(&mut dst, &value).unwrap();
8671 dst
8672 };
8673 let request_size = request_value_reader
8674 .seek(std::io::SeekFrom::End(0))
8675 .unwrap();
8676 request_value_reader
8677 .seek(std::io::SeekFrom::Start(0))
8678 .unwrap();
8679
8680 loop {
8681 let token = match self
8682 .hub
8683 .auth
8684 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8685 .await
8686 {
8687 Ok(token) => token,
8688 Err(e) => match dlg.token(e) {
8689 Ok(token) => token,
8690 Err(e) => {
8691 dlg.finished(false);
8692 return Err(common::Error::MissingToken(e));
8693 }
8694 },
8695 };
8696 request_value_reader
8697 .seek(std::io::SeekFrom::Start(0))
8698 .unwrap();
8699 let mut req_result = {
8700 let client = &self.hub.client;
8701 dlg.pre_request();
8702 let mut req_builder = hyper::Request::builder()
8703 .method(hyper::Method::PUT)
8704 .uri(url.as_str())
8705 .header(USER_AGENT, self.hub._user_agent.clone());
8706
8707 if let Some(token) = token.as_ref() {
8708 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8709 }
8710
8711 let request = req_builder
8712 .header(CONTENT_TYPE, json_mime_type.to_string())
8713 .header(CONTENT_LENGTH, request_size as u64)
8714 .body(common::to_body(
8715 request_value_reader.get_ref().clone().into(),
8716 ));
8717
8718 client.request(request.unwrap()).await
8719 };
8720
8721 match req_result {
8722 Err(err) => {
8723 if let common::Retry::After(d) = dlg.http_error(&err) {
8724 sleep(d).await;
8725 continue;
8726 }
8727 dlg.finished(false);
8728 return Err(common::Error::HttpError(err));
8729 }
8730 Ok(res) => {
8731 let (mut parts, body) = res.into_parts();
8732 let mut body = common::Body::new(body);
8733 if !parts.status.is_success() {
8734 let bytes = common::to_bytes(body).await.unwrap_or_default();
8735 let error = serde_json::from_str(&common::to_string(&bytes));
8736 let response = common::to_response(parts, bytes.into());
8737
8738 if let common::Retry::After(d) =
8739 dlg.http_failure(&response, error.as_ref().ok())
8740 {
8741 sleep(d).await;
8742 continue;
8743 }
8744
8745 dlg.finished(false);
8746
8747 return Err(match error {
8748 Ok(value) => common::Error::BadRequest(value),
8749 _ => common::Error::Failure(response),
8750 });
8751 }
8752 let response = {
8753 let bytes = common::to_bytes(body).await.unwrap_or_default();
8754 let encoded = common::to_string(&bytes);
8755 match serde_json::from_str(&encoded) {
8756 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8757 Err(error) => {
8758 dlg.response_json_decode_error(&encoded, &error);
8759 return Err(common::Error::JsonDecodeError(
8760 encoded.to_string(),
8761 error,
8762 ));
8763 }
8764 }
8765 };
8766
8767 dlg.finished(true);
8768 return Ok(response);
8769 }
8770 }
8771 }
8772 }
8773
8774 ///
8775 /// Sets the *request* property to the given value.
8776 ///
8777 /// Even though the property as already been set when instantiating this call,
8778 /// we provide this method for API completeness.
8779 pub fn request(mut self, new_value: Page) -> PageUpdateCall<'a, C> {
8780 self._request = new_value;
8781 self
8782 }
8783 ///
8784 /// Sets the *blog id* path property to the given value.
8785 ///
8786 /// Even though the property as already been set when instantiating this call,
8787 /// we provide this method for API completeness.
8788 pub fn blog_id(mut self, new_value: &str) -> PageUpdateCall<'a, C> {
8789 self._blog_id = new_value.to_string();
8790 self
8791 }
8792 ///
8793 /// Sets the *page id* path property to the given value.
8794 ///
8795 /// Even though the property as already been set when instantiating this call,
8796 /// we provide this method for API completeness.
8797 pub fn page_id(mut self, new_value: &str) -> PageUpdateCall<'a, C> {
8798 self._page_id = new_value.to_string();
8799 self
8800 }
8801 ///
8802 /// Sets the *revert* query property to the given value.
8803 pub fn revert(mut self, new_value: bool) -> PageUpdateCall<'a, C> {
8804 self._revert = Some(new_value);
8805 self
8806 }
8807 ///
8808 /// Sets the *publish* query property to the given value.
8809 pub fn publish(mut self, new_value: bool) -> PageUpdateCall<'a, C> {
8810 self._publish = Some(new_value);
8811 self
8812 }
8813 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8814 /// while executing the actual API request.
8815 ///
8816 /// ````text
8817 /// It should be used to handle progress information, and to implement a certain level of resilience.
8818 /// ````
8819 ///
8820 /// Sets the *delegate* property to the given value.
8821 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageUpdateCall<'a, C> {
8822 self._delegate = Some(new_value);
8823 self
8824 }
8825
8826 /// Set any additional parameter of the query string used in the request.
8827 /// It should be used to set parameters which are not yet available through their own
8828 /// setters.
8829 ///
8830 /// Please note that this method must not be used to set any of the known parameters
8831 /// which have their own setter method. If done anyway, the request will fail.
8832 ///
8833 /// # Additional Parameters
8834 ///
8835 /// * *$.xgafv* (query-string) - V1 error format.
8836 /// * *access_token* (query-string) - OAuth access token.
8837 /// * *alt* (query-string) - Data format for response.
8838 /// * *callback* (query-string) - JSONP
8839 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8840 /// * *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.
8841 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8842 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8843 /// * *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.
8844 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8845 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8846 pub fn param<T>(mut self, name: T, value: T) -> PageUpdateCall<'a, C>
8847 where
8848 T: AsRef<str>,
8849 {
8850 self._additional_params
8851 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8852 self
8853 }
8854
8855 /// Identifies the authorization scope for the method you are building.
8856 ///
8857 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8858 /// [`Scope::Full`].
8859 ///
8860 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8861 /// tokens for more than one scope.
8862 ///
8863 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8864 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8865 /// sufficient, a read-write scope will do as well.
8866 pub fn add_scope<St>(mut self, scope: St) -> PageUpdateCall<'a, C>
8867 where
8868 St: AsRef<str>,
8869 {
8870 self._scopes.insert(String::from(scope.as_ref()));
8871 self
8872 }
8873 /// Identifies the authorization scope(s) for the method you are building.
8874 ///
8875 /// See [`Self::add_scope()`] for details.
8876 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageUpdateCall<'a, C>
8877 where
8878 I: IntoIterator<Item = St>,
8879 St: AsRef<str>,
8880 {
8881 self._scopes
8882 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8883 self
8884 }
8885
8886 /// Removes all scopes, and no default scope will be used either.
8887 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8888 /// for details).
8889 pub fn clear_scopes(mut self) -> PageUpdateCall<'a, C> {
8890 self._scopes.clear();
8891 self
8892 }
8893}
8894
8895/// Gets one post and user info pair, by post_id and user_id.
8896///
8897/// A builder for the *get* method supported by a *postUserInfo* resource.
8898/// It is not used directly, but through a [`PostUserInfoMethods`] instance.
8899///
8900/// # Example
8901///
8902/// Instantiate a resource method builder
8903///
8904/// ```test_harness,no_run
8905/// # extern crate hyper;
8906/// # extern crate hyper_rustls;
8907/// # extern crate google_blogger3 as blogger3;
8908/// # async fn dox() {
8909/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8910///
8911/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8912/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8913/// # .with_native_roots()
8914/// # .unwrap()
8915/// # .https_only()
8916/// # .enable_http2()
8917/// # .build();
8918///
8919/// # let executor = hyper_util::rt::TokioExecutor::new();
8920/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8921/// # secret,
8922/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8923/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8924/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8925/// # ),
8926/// # ).build().await.unwrap();
8927///
8928/// # let client = hyper_util::client::legacy::Client::builder(
8929/// # hyper_util::rt::TokioExecutor::new()
8930/// # )
8931/// # .build(
8932/// # hyper_rustls::HttpsConnectorBuilder::new()
8933/// # .with_native_roots()
8934/// # .unwrap()
8935/// # .https_or_http()
8936/// # .enable_http2()
8937/// # .build()
8938/// # );
8939/// # let mut hub = Blogger::new(client, auth);
8940/// // You can configure optional parameters by calling the respective setters at will, and
8941/// // execute the final call using `doit()`.
8942/// // Values shown here are possibly random and not representative !
8943/// let result = hub.post_user_infos().get("userId", "blogId", "postId")
8944/// .max_comments(10)
8945/// .doit().await;
8946/// # }
8947/// ```
8948pub struct PostUserInfoGetCall<'a, C>
8949where
8950 C: 'a,
8951{
8952 hub: &'a Blogger<C>,
8953 _user_id: String,
8954 _blog_id: String,
8955 _post_id: String,
8956 _max_comments: Option<u32>,
8957 _delegate: Option<&'a mut dyn common::Delegate>,
8958 _additional_params: HashMap<String, String>,
8959 _scopes: BTreeSet<String>,
8960}
8961
8962impl<'a, C> common::CallBuilder for PostUserInfoGetCall<'a, C> {}
8963
8964impl<'a, C> PostUserInfoGetCall<'a, C>
8965where
8966 C: common::Connector,
8967{
8968 /// Perform the operation you have build so far.
8969 pub async fn doit(mut self) -> common::Result<(common::Response, PostUserInfo)> {
8970 use std::borrow::Cow;
8971 use std::io::{Read, Seek};
8972
8973 use common::{url::Params, ToParts};
8974 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8975
8976 let mut dd = common::DefaultDelegate;
8977 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8978 dlg.begin(common::MethodInfo {
8979 id: "blogger.postUserInfos.get",
8980 http_method: hyper::Method::GET,
8981 });
8982
8983 for &field in ["alt", "userId", "blogId", "postId", "maxComments"].iter() {
8984 if self._additional_params.contains_key(field) {
8985 dlg.finished(false);
8986 return Err(common::Error::FieldClash(field));
8987 }
8988 }
8989
8990 let mut params = Params::with_capacity(6 + self._additional_params.len());
8991 params.push("userId", self._user_id);
8992 params.push("blogId", self._blog_id);
8993 params.push("postId", self._post_id);
8994 if let Some(value) = self._max_comments.as_ref() {
8995 params.push("maxComments", value.to_string());
8996 }
8997
8998 params.extend(self._additional_params.iter());
8999
9000 params.push("alt", "json");
9001 let mut url =
9002 self.hub._base_url.clone() + "v3/users/{userId}/blogs/{blogId}/posts/{postId}";
9003 if self._scopes.is_empty() {
9004 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9005 }
9006
9007 #[allow(clippy::single_element_loop)]
9008 for &(find_this, param_name) in [
9009 ("{userId}", "userId"),
9010 ("{blogId}", "blogId"),
9011 ("{postId}", "postId"),
9012 ]
9013 .iter()
9014 {
9015 url = params.uri_replacement(url, param_name, find_this, false);
9016 }
9017 {
9018 let to_remove = ["postId", "blogId", "userId"];
9019 params.remove_params(&to_remove);
9020 }
9021
9022 let url = params.parse_with_url(&url);
9023
9024 loop {
9025 let token = match self
9026 .hub
9027 .auth
9028 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9029 .await
9030 {
9031 Ok(token) => token,
9032 Err(e) => match dlg.token(e) {
9033 Ok(token) => token,
9034 Err(e) => {
9035 dlg.finished(false);
9036 return Err(common::Error::MissingToken(e));
9037 }
9038 },
9039 };
9040 let mut req_result = {
9041 let client = &self.hub.client;
9042 dlg.pre_request();
9043 let mut req_builder = hyper::Request::builder()
9044 .method(hyper::Method::GET)
9045 .uri(url.as_str())
9046 .header(USER_AGENT, self.hub._user_agent.clone());
9047
9048 if let Some(token) = token.as_ref() {
9049 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9050 }
9051
9052 let request = req_builder
9053 .header(CONTENT_LENGTH, 0_u64)
9054 .body(common::to_body::<String>(None));
9055
9056 client.request(request.unwrap()).await
9057 };
9058
9059 match req_result {
9060 Err(err) => {
9061 if let common::Retry::After(d) = dlg.http_error(&err) {
9062 sleep(d).await;
9063 continue;
9064 }
9065 dlg.finished(false);
9066 return Err(common::Error::HttpError(err));
9067 }
9068 Ok(res) => {
9069 let (mut parts, body) = res.into_parts();
9070 let mut body = common::Body::new(body);
9071 if !parts.status.is_success() {
9072 let bytes = common::to_bytes(body).await.unwrap_or_default();
9073 let error = serde_json::from_str(&common::to_string(&bytes));
9074 let response = common::to_response(parts, bytes.into());
9075
9076 if let common::Retry::After(d) =
9077 dlg.http_failure(&response, error.as_ref().ok())
9078 {
9079 sleep(d).await;
9080 continue;
9081 }
9082
9083 dlg.finished(false);
9084
9085 return Err(match error {
9086 Ok(value) => common::Error::BadRequest(value),
9087 _ => common::Error::Failure(response),
9088 });
9089 }
9090 let response = {
9091 let bytes = common::to_bytes(body).await.unwrap_or_default();
9092 let encoded = common::to_string(&bytes);
9093 match serde_json::from_str(&encoded) {
9094 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9095 Err(error) => {
9096 dlg.response_json_decode_error(&encoded, &error);
9097 return Err(common::Error::JsonDecodeError(
9098 encoded.to_string(),
9099 error,
9100 ));
9101 }
9102 }
9103 };
9104
9105 dlg.finished(true);
9106 return Ok(response);
9107 }
9108 }
9109 }
9110 }
9111
9112 ///
9113 /// Sets the *user id* path property to the given value.
9114 ///
9115 /// Even though the property as already been set when instantiating this call,
9116 /// we provide this method for API completeness.
9117 pub fn user_id(mut self, new_value: &str) -> PostUserInfoGetCall<'a, C> {
9118 self._user_id = new_value.to_string();
9119 self
9120 }
9121 ///
9122 /// Sets the *blog id* path property to the given value.
9123 ///
9124 /// Even though the property as already been set when instantiating this call,
9125 /// we provide this method for API completeness.
9126 pub fn blog_id(mut self, new_value: &str) -> PostUserInfoGetCall<'a, C> {
9127 self._blog_id = new_value.to_string();
9128 self
9129 }
9130 ///
9131 /// Sets the *post id* path property to the given value.
9132 ///
9133 /// Even though the property as already been set when instantiating this call,
9134 /// we provide this method for API completeness.
9135 pub fn post_id(mut self, new_value: &str) -> PostUserInfoGetCall<'a, C> {
9136 self._post_id = new_value.to_string();
9137 self
9138 }
9139 ///
9140 /// Sets the *max comments* query property to the given value.
9141 pub fn max_comments(mut self, new_value: u32) -> PostUserInfoGetCall<'a, C> {
9142 self._max_comments = Some(new_value);
9143 self
9144 }
9145 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9146 /// while executing the actual API request.
9147 ///
9148 /// ````text
9149 /// It should be used to handle progress information, and to implement a certain level of resilience.
9150 /// ````
9151 ///
9152 /// Sets the *delegate* property to the given value.
9153 pub fn delegate(
9154 mut self,
9155 new_value: &'a mut dyn common::Delegate,
9156 ) -> PostUserInfoGetCall<'a, C> {
9157 self._delegate = Some(new_value);
9158 self
9159 }
9160
9161 /// Set any additional parameter of the query string used in the request.
9162 /// It should be used to set parameters which are not yet available through their own
9163 /// setters.
9164 ///
9165 /// Please note that this method must not be used to set any of the known parameters
9166 /// which have their own setter method. If done anyway, the request will fail.
9167 ///
9168 /// # Additional Parameters
9169 ///
9170 /// * *$.xgafv* (query-string) - V1 error format.
9171 /// * *access_token* (query-string) - OAuth access token.
9172 /// * *alt* (query-string) - Data format for response.
9173 /// * *callback* (query-string) - JSONP
9174 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9175 /// * *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.
9176 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9177 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9178 /// * *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.
9179 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9180 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9181 pub fn param<T>(mut self, name: T, value: T) -> PostUserInfoGetCall<'a, C>
9182 where
9183 T: AsRef<str>,
9184 {
9185 self._additional_params
9186 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9187 self
9188 }
9189
9190 /// Identifies the authorization scope for the method you are building.
9191 ///
9192 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9193 /// [`Scope::Readonly`].
9194 ///
9195 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9196 /// tokens for more than one scope.
9197 ///
9198 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9199 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9200 /// sufficient, a read-write scope will do as well.
9201 pub fn add_scope<St>(mut self, scope: St) -> PostUserInfoGetCall<'a, C>
9202 where
9203 St: AsRef<str>,
9204 {
9205 self._scopes.insert(String::from(scope.as_ref()));
9206 self
9207 }
9208 /// Identifies the authorization scope(s) for the method you are building.
9209 ///
9210 /// See [`Self::add_scope()`] for details.
9211 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostUserInfoGetCall<'a, C>
9212 where
9213 I: IntoIterator<Item = St>,
9214 St: AsRef<str>,
9215 {
9216 self._scopes
9217 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9218 self
9219 }
9220
9221 /// Removes all scopes, and no default scope will be used either.
9222 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9223 /// for details).
9224 pub fn clear_scopes(mut self) -> PostUserInfoGetCall<'a, C> {
9225 self._scopes.clear();
9226 self
9227 }
9228}
9229
9230/// Lists post and user info pairs.
9231///
9232/// A builder for the *list* method supported by a *postUserInfo* resource.
9233/// It is not used directly, but through a [`PostUserInfoMethods`] instance.
9234///
9235/// # Example
9236///
9237/// Instantiate a resource method builder
9238///
9239/// ```test_harness,no_run
9240/// # extern crate hyper;
9241/// # extern crate hyper_rustls;
9242/// # extern crate google_blogger3 as blogger3;
9243/// # async fn dox() {
9244/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9245///
9246/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9247/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9248/// # .with_native_roots()
9249/// # .unwrap()
9250/// # .https_only()
9251/// # .enable_http2()
9252/// # .build();
9253///
9254/// # let executor = hyper_util::rt::TokioExecutor::new();
9255/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9256/// # secret,
9257/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9258/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9259/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9260/// # ),
9261/// # ).build().await.unwrap();
9262///
9263/// # let client = hyper_util::client::legacy::Client::builder(
9264/// # hyper_util::rt::TokioExecutor::new()
9265/// # )
9266/// # .build(
9267/// # hyper_rustls::HttpsConnectorBuilder::new()
9268/// # .with_native_roots()
9269/// # .unwrap()
9270/// # .https_or_http()
9271/// # .enable_http2()
9272/// # .build()
9273/// # );
9274/// # let mut hub = Blogger::new(client, auth);
9275/// // You can configure optional parameters by calling the respective setters at will, and
9276/// // execute the final call using `doit()`.
9277/// // Values shown here are possibly random and not representative !
9278/// let result = hub.post_user_infos().list("userId", "blogId")
9279/// .view("aliquyam")
9280/// .add_status("dolores")
9281/// .start_date("sadipscing")
9282/// .page_token("erat")
9283/// .order_by("aliquyam")
9284/// .max_results(54)
9285/// .labels("est")
9286/// .fetch_bodies(false)
9287/// .end_date("consetetur")
9288/// .doit().await;
9289/// # }
9290/// ```
9291pub struct PostUserInfoListCall<'a, C>
9292where
9293 C: 'a,
9294{
9295 hub: &'a Blogger<C>,
9296 _user_id: String,
9297 _blog_id: String,
9298 _view: Option<String>,
9299 _status: Vec<String>,
9300 _start_date: Option<String>,
9301 _page_token: Option<String>,
9302 _order_by: Option<String>,
9303 _max_results: Option<u32>,
9304 _labels: Option<String>,
9305 _fetch_bodies: Option<bool>,
9306 _end_date: Option<String>,
9307 _delegate: Option<&'a mut dyn common::Delegate>,
9308 _additional_params: HashMap<String, String>,
9309 _scopes: BTreeSet<String>,
9310}
9311
9312impl<'a, C> common::CallBuilder for PostUserInfoListCall<'a, C> {}
9313
9314impl<'a, C> PostUserInfoListCall<'a, C>
9315where
9316 C: common::Connector,
9317{
9318 /// Perform the operation you have build so far.
9319 pub async fn doit(mut self) -> common::Result<(common::Response, PostUserInfosList)> {
9320 use std::borrow::Cow;
9321 use std::io::{Read, Seek};
9322
9323 use common::{url::Params, ToParts};
9324 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9325
9326 let mut dd = common::DefaultDelegate;
9327 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9328 dlg.begin(common::MethodInfo {
9329 id: "blogger.postUserInfos.list",
9330 http_method: hyper::Method::GET,
9331 });
9332
9333 for &field in [
9334 "alt",
9335 "userId",
9336 "blogId",
9337 "view",
9338 "status",
9339 "startDate",
9340 "pageToken",
9341 "orderBy",
9342 "maxResults",
9343 "labels",
9344 "fetchBodies",
9345 "endDate",
9346 ]
9347 .iter()
9348 {
9349 if self._additional_params.contains_key(field) {
9350 dlg.finished(false);
9351 return Err(common::Error::FieldClash(field));
9352 }
9353 }
9354
9355 let mut params = Params::with_capacity(13 + self._additional_params.len());
9356 params.push("userId", self._user_id);
9357 params.push("blogId", self._blog_id);
9358 if let Some(value) = self._view.as_ref() {
9359 params.push("view", value);
9360 }
9361 if !self._status.is_empty() {
9362 for f in self._status.iter() {
9363 params.push("status", f);
9364 }
9365 }
9366 if let Some(value) = self._start_date.as_ref() {
9367 params.push("startDate", value);
9368 }
9369 if let Some(value) = self._page_token.as_ref() {
9370 params.push("pageToken", value);
9371 }
9372 if let Some(value) = self._order_by.as_ref() {
9373 params.push("orderBy", value);
9374 }
9375 if let Some(value) = self._max_results.as_ref() {
9376 params.push("maxResults", value.to_string());
9377 }
9378 if let Some(value) = self._labels.as_ref() {
9379 params.push("labels", value);
9380 }
9381 if let Some(value) = self._fetch_bodies.as_ref() {
9382 params.push("fetchBodies", value.to_string());
9383 }
9384 if let Some(value) = self._end_date.as_ref() {
9385 params.push("endDate", value);
9386 }
9387
9388 params.extend(self._additional_params.iter());
9389
9390 params.push("alt", "json");
9391 let mut url = self.hub._base_url.clone() + "v3/users/{userId}/blogs/{blogId}/posts";
9392 if self._scopes.is_empty() {
9393 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9394 }
9395
9396 #[allow(clippy::single_element_loop)]
9397 for &(find_this, param_name) in [("{userId}", "userId"), ("{blogId}", "blogId")].iter() {
9398 url = params.uri_replacement(url, param_name, find_this, false);
9399 }
9400 {
9401 let to_remove = ["blogId", "userId"];
9402 params.remove_params(&to_remove);
9403 }
9404
9405 let url = params.parse_with_url(&url);
9406
9407 loop {
9408 let token = match self
9409 .hub
9410 .auth
9411 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9412 .await
9413 {
9414 Ok(token) => token,
9415 Err(e) => match dlg.token(e) {
9416 Ok(token) => token,
9417 Err(e) => {
9418 dlg.finished(false);
9419 return Err(common::Error::MissingToken(e));
9420 }
9421 },
9422 };
9423 let mut req_result = {
9424 let client = &self.hub.client;
9425 dlg.pre_request();
9426 let mut req_builder = hyper::Request::builder()
9427 .method(hyper::Method::GET)
9428 .uri(url.as_str())
9429 .header(USER_AGENT, self.hub._user_agent.clone());
9430
9431 if let Some(token) = token.as_ref() {
9432 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9433 }
9434
9435 let request = req_builder
9436 .header(CONTENT_LENGTH, 0_u64)
9437 .body(common::to_body::<String>(None));
9438
9439 client.request(request.unwrap()).await
9440 };
9441
9442 match req_result {
9443 Err(err) => {
9444 if let common::Retry::After(d) = dlg.http_error(&err) {
9445 sleep(d).await;
9446 continue;
9447 }
9448 dlg.finished(false);
9449 return Err(common::Error::HttpError(err));
9450 }
9451 Ok(res) => {
9452 let (mut parts, body) = res.into_parts();
9453 let mut body = common::Body::new(body);
9454 if !parts.status.is_success() {
9455 let bytes = common::to_bytes(body).await.unwrap_or_default();
9456 let error = serde_json::from_str(&common::to_string(&bytes));
9457 let response = common::to_response(parts, bytes.into());
9458
9459 if let common::Retry::After(d) =
9460 dlg.http_failure(&response, error.as_ref().ok())
9461 {
9462 sleep(d).await;
9463 continue;
9464 }
9465
9466 dlg.finished(false);
9467
9468 return Err(match error {
9469 Ok(value) => common::Error::BadRequest(value),
9470 _ => common::Error::Failure(response),
9471 });
9472 }
9473 let response = {
9474 let bytes = common::to_bytes(body).await.unwrap_or_default();
9475 let encoded = common::to_string(&bytes);
9476 match serde_json::from_str(&encoded) {
9477 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9478 Err(error) => {
9479 dlg.response_json_decode_error(&encoded, &error);
9480 return Err(common::Error::JsonDecodeError(
9481 encoded.to_string(),
9482 error,
9483 ));
9484 }
9485 }
9486 };
9487
9488 dlg.finished(true);
9489 return Ok(response);
9490 }
9491 }
9492 }
9493 }
9494
9495 ///
9496 /// Sets the *user id* path property to the given value.
9497 ///
9498 /// Even though the property as already been set when instantiating this call,
9499 /// we provide this method for API completeness.
9500 pub fn user_id(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9501 self._user_id = new_value.to_string();
9502 self
9503 }
9504 ///
9505 /// Sets the *blog id* path property to the given value.
9506 ///
9507 /// Even though the property as already been set when instantiating this call,
9508 /// we provide this method for API completeness.
9509 pub fn blog_id(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9510 self._blog_id = new_value.to_string();
9511 self
9512 }
9513 ///
9514 /// Sets the *view* query property to the given value.
9515 pub fn view(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9516 self._view = Some(new_value.to_string());
9517 self
9518 }
9519 ///
9520 /// Append the given value to the *status* query property.
9521 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9522 pub fn add_status(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9523 self._status.push(new_value.to_string());
9524 self
9525 }
9526 ///
9527 /// Sets the *start date* query property to the given value.
9528 pub fn start_date(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9529 self._start_date = Some(new_value.to_string());
9530 self
9531 }
9532 ///
9533 /// Sets the *page token* query property to the given value.
9534 pub fn page_token(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9535 self._page_token = Some(new_value.to_string());
9536 self
9537 }
9538 ///
9539 /// Sets the *order by* query property to the given value.
9540 pub fn order_by(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9541 self._order_by = Some(new_value.to_string());
9542 self
9543 }
9544 ///
9545 /// Sets the *max results* query property to the given value.
9546 pub fn max_results(mut self, new_value: u32) -> PostUserInfoListCall<'a, C> {
9547 self._max_results = Some(new_value);
9548 self
9549 }
9550 ///
9551 /// Sets the *labels* query property to the given value.
9552 pub fn labels(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9553 self._labels = Some(new_value.to_string());
9554 self
9555 }
9556 ///
9557 /// Sets the *fetch bodies* query property to the given value.
9558 pub fn fetch_bodies(mut self, new_value: bool) -> PostUserInfoListCall<'a, C> {
9559 self._fetch_bodies = Some(new_value);
9560 self
9561 }
9562 ///
9563 /// Sets the *end date* query property to the given value.
9564 pub fn end_date(mut self, new_value: &str) -> PostUserInfoListCall<'a, C> {
9565 self._end_date = Some(new_value.to_string());
9566 self
9567 }
9568 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9569 /// while executing the actual API request.
9570 ///
9571 /// ````text
9572 /// It should be used to handle progress information, and to implement a certain level of resilience.
9573 /// ````
9574 ///
9575 /// Sets the *delegate* property to the given value.
9576 pub fn delegate(
9577 mut self,
9578 new_value: &'a mut dyn common::Delegate,
9579 ) -> PostUserInfoListCall<'a, C> {
9580 self._delegate = Some(new_value);
9581 self
9582 }
9583
9584 /// Set any additional parameter of the query string used in the request.
9585 /// It should be used to set parameters which are not yet available through their own
9586 /// setters.
9587 ///
9588 /// Please note that this method must not be used to set any of the known parameters
9589 /// which have their own setter method. If done anyway, the request will fail.
9590 ///
9591 /// # Additional Parameters
9592 ///
9593 /// * *$.xgafv* (query-string) - V1 error format.
9594 /// * *access_token* (query-string) - OAuth access token.
9595 /// * *alt* (query-string) - Data format for response.
9596 /// * *callback* (query-string) - JSONP
9597 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9598 /// * *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.
9599 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9600 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9601 /// * *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.
9602 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9603 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9604 pub fn param<T>(mut self, name: T, value: T) -> PostUserInfoListCall<'a, C>
9605 where
9606 T: AsRef<str>,
9607 {
9608 self._additional_params
9609 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9610 self
9611 }
9612
9613 /// Identifies the authorization scope for the method you are building.
9614 ///
9615 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9616 /// [`Scope::Readonly`].
9617 ///
9618 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9619 /// tokens for more than one scope.
9620 ///
9621 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9622 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9623 /// sufficient, a read-write scope will do as well.
9624 pub fn add_scope<St>(mut self, scope: St) -> PostUserInfoListCall<'a, C>
9625 where
9626 St: AsRef<str>,
9627 {
9628 self._scopes.insert(String::from(scope.as_ref()));
9629 self
9630 }
9631 /// Identifies the authorization scope(s) for the method you are building.
9632 ///
9633 /// See [`Self::add_scope()`] for details.
9634 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostUserInfoListCall<'a, C>
9635 where
9636 I: IntoIterator<Item = St>,
9637 St: AsRef<str>,
9638 {
9639 self._scopes
9640 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9641 self
9642 }
9643
9644 /// Removes all scopes, and no default scope will be used either.
9645 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9646 /// for details).
9647 pub fn clear_scopes(mut self) -> PostUserInfoListCall<'a, C> {
9648 self._scopes.clear();
9649 self
9650 }
9651}
9652
9653/// Deletes a post by blog id and post id.
9654///
9655/// A builder for the *delete* method supported by a *post* resource.
9656/// It is not used directly, but through a [`PostMethods`] instance.
9657///
9658/// # Example
9659///
9660/// Instantiate a resource method builder
9661///
9662/// ```test_harness,no_run
9663/// # extern crate hyper;
9664/// # extern crate hyper_rustls;
9665/// # extern crate google_blogger3 as blogger3;
9666/// # async fn dox() {
9667/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9668///
9669/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9670/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9671/// # .with_native_roots()
9672/// # .unwrap()
9673/// # .https_only()
9674/// # .enable_http2()
9675/// # .build();
9676///
9677/// # let executor = hyper_util::rt::TokioExecutor::new();
9678/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9679/// # secret,
9680/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9681/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9682/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9683/// # ),
9684/// # ).build().await.unwrap();
9685///
9686/// # let client = hyper_util::client::legacy::Client::builder(
9687/// # hyper_util::rt::TokioExecutor::new()
9688/// # )
9689/// # .build(
9690/// # hyper_rustls::HttpsConnectorBuilder::new()
9691/// # .with_native_roots()
9692/// # .unwrap()
9693/// # .https_or_http()
9694/// # .enable_http2()
9695/// # .build()
9696/// # );
9697/// # let mut hub = Blogger::new(client, auth);
9698/// // You can configure optional parameters by calling the respective setters at will, and
9699/// // execute the final call using `doit()`.
9700/// // Values shown here are possibly random and not representative !
9701/// let result = hub.posts().delete("blogId", "postId")
9702/// .use_trash(false)
9703/// .doit().await;
9704/// # }
9705/// ```
9706pub struct PostDeleteCall<'a, C>
9707where
9708 C: 'a,
9709{
9710 hub: &'a Blogger<C>,
9711 _blog_id: String,
9712 _post_id: String,
9713 _use_trash: Option<bool>,
9714 _delegate: Option<&'a mut dyn common::Delegate>,
9715 _additional_params: HashMap<String, String>,
9716 _scopes: BTreeSet<String>,
9717}
9718
9719impl<'a, C> common::CallBuilder for PostDeleteCall<'a, C> {}
9720
9721impl<'a, C> PostDeleteCall<'a, C>
9722where
9723 C: common::Connector,
9724{
9725 /// Perform the operation you have build so far.
9726 pub async fn doit(mut self) -> common::Result<common::Response> {
9727 use std::borrow::Cow;
9728 use std::io::{Read, Seek};
9729
9730 use common::{url::Params, ToParts};
9731 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9732
9733 let mut dd = common::DefaultDelegate;
9734 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9735 dlg.begin(common::MethodInfo {
9736 id: "blogger.posts.delete",
9737 http_method: hyper::Method::DELETE,
9738 });
9739
9740 for &field in ["blogId", "postId", "useTrash"].iter() {
9741 if self._additional_params.contains_key(field) {
9742 dlg.finished(false);
9743 return Err(common::Error::FieldClash(field));
9744 }
9745 }
9746
9747 let mut params = Params::with_capacity(4 + self._additional_params.len());
9748 params.push("blogId", self._blog_id);
9749 params.push("postId", self._post_id);
9750 if let Some(value) = self._use_trash.as_ref() {
9751 params.push("useTrash", value.to_string());
9752 }
9753
9754 params.extend(self._additional_params.iter());
9755
9756 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}";
9757 if self._scopes.is_empty() {
9758 self._scopes.insert(Scope::Full.as_ref().to_string());
9759 }
9760
9761 #[allow(clippy::single_element_loop)]
9762 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{postId}", "postId")].iter() {
9763 url = params.uri_replacement(url, param_name, find_this, false);
9764 }
9765 {
9766 let to_remove = ["postId", "blogId"];
9767 params.remove_params(&to_remove);
9768 }
9769
9770 let url = params.parse_with_url(&url);
9771
9772 loop {
9773 let token = match self
9774 .hub
9775 .auth
9776 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9777 .await
9778 {
9779 Ok(token) => token,
9780 Err(e) => match dlg.token(e) {
9781 Ok(token) => token,
9782 Err(e) => {
9783 dlg.finished(false);
9784 return Err(common::Error::MissingToken(e));
9785 }
9786 },
9787 };
9788 let mut req_result = {
9789 let client = &self.hub.client;
9790 dlg.pre_request();
9791 let mut req_builder = hyper::Request::builder()
9792 .method(hyper::Method::DELETE)
9793 .uri(url.as_str())
9794 .header(USER_AGENT, self.hub._user_agent.clone());
9795
9796 if let Some(token) = token.as_ref() {
9797 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9798 }
9799
9800 let request = req_builder
9801 .header(CONTENT_LENGTH, 0_u64)
9802 .body(common::to_body::<String>(None));
9803
9804 client.request(request.unwrap()).await
9805 };
9806
9807 match req_result {
9808 Err(err) => {
9809 if let common::Retry::After(d) = dlg.http_error(&err) {
9810 sleep(d).await;
9811 continue;
9812 }
9813 dlg.finished(false);
9814 return Err(common::Error::HttpError(err));
9815 }
9816 Ok(res) => {
9817 let (mut parts, body) = res.into_parts();
9818 let mut body = common::Body::new(body);
9819 if !parts.status.is_success() {
9820 let bytes = common::to_bytes(body).await.unwrap_or_default();
9821 let error = serde_json::from_str(&common::to_string(&bytes));
9822 let response = common::to_response(parts, bytes.into());
9823
9824 if let common::Retry::After(d) =
9825 dlg.http_failure(&response, error.as_ref().ok())
9826 {
9827 sleep(d).await;
9828 continue;
9829 }
9830
9831 dlg.finished(false);
9832
9833 return Err(match error {
9834 Ok(value) => common::Error::BadRequest(value),
9835 _ => common::Error::Failure(response),
9836 });
9837 }
9838 let response = common::Response::from_parts(parts, body);
9839
9840 dlg.finished(true);
9841 return Ok(response);
9842 }
9843 }
9844 }
9845 }
9846
9847 ///
9848 /// Sets the *blog id* path property to the given value.
9849 ///
9850 /// Even though the property as already been set when instantiating this call,
9851 /// we provide this method for API completeness.
9852 pub fn blog_id(mut self, new_value: &str) -> PostDeleteCall<'a, C> {
9853 self._blog_id = new_value.to_string();
9854 self
9855 }
9856 ///
9857 /// Sets the *post id* path property to the given value.
9858 ///
9859 /// Even though the property as already been set when instantiating this call,
9860 /// we provide this method for API completeness.
9861 pub fn post_id(mut self, new_value: &str) -> PostDeleteCall<'a, C> {
9862 self._post_id = new_value.to_string();
9863 self
9864 }
9865 /// Move to Trash if possible
9866 ///
9867 /// Sets the *use trash* query property to the given value.
9868 pub fn use_trash(mut self, new_value: bool) -> PostDeleteCall<'a, C> {
9869 self._use_trash = Some(new_value);
9870 self
9871 }
9872 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9873 /// while executing the actual API request.
9874 ///
9875 /// ````text
9876 /// It should be used to handle progress information, and to implement a certain level of resilience.
9877 /// ````
9878 ///
9879 /// Sets the *delegate* property to the given value.
9880 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostDeleteCall<'a, C> {
9881 self._delegate = Some(new_value);
9882 self
9883 }
9884
9885 /// Set any additional parameter of the query string used in the request.
9886 /// It should be used to set parameters which are not yet available through their own
9887 /// setters.
9888 ///
9889 /// Please note that this method must not be used to set any of the known parameters
9890 /// which have their own setter method. If done anyway, the request will fail.
9891 ///
9892 /// # Additional Parameters
9893 ///
9894 /// * *$.xgafv* (query-string) - V1 error format.
9895 /// * *access_token* (query-string) - OAuth access token.
9896 /// * *alt* (query-string) - Data format for response.
9897 /// * *callback* (query-string) - JSONP
9898 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9899 /// * *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.
9900 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9901 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9902 /// * *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.
9903 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9904 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9905 pub fn param<T>(mut self, name: T, value: T) -> PostDeleteCall<'a, C>
9906 where
9907 T: AsRef<str>,
9908 {
9909 self._additional_params
9910 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9911 self
9912 }
9913
9914 /// Identifies the authorization scope for the method you are building.
9915 ///
9916 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9917 /// [`Scope::Full`].
9918 ///
9919 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9920 /// tokens for more than one scope.
9921 ///
9922 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9923 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9924 /// sufficient, a read-write scope will do as well.
9925 pub fn add_scope<St>(mut self, scope: St) -> PostDeleteCall<'a, C>
9926 where
9927 St: AsRef<str>,
9928 {
9929 self._scopes.insert(String::from(scope.as_ref()));
9930 self
9931 }
9932 /// Identifies the authorization scope(s) for the method you are building.
9933 ///
9934 /// See [`Self::add_scope()`] for details.
9935 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostDeleteCall<'a, C>
9936 where
9937 I: IntoIterator<Item = St>,
9938 St: AsRef<str>,
9939 {
9940 self._scopes
9941 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9942 self
9943 }
9944
9945 /// Removes all scopes, and no default scope will be used either.
9946 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9947 /// for details).
9948 pub fn clear_scopes(mut self) -> PostDeleteCall<'a, C> {
9949 self._scopes.clear();
9950 self
9951 }
9952}
9953
9954/// Gets a post by blog id and post id
9955///
9956/// A builder for the *get* method supported by a *post* resource.
9957/// It is not used directly, but through a [`PostMethods`] instance.
9958///
9959/// # Example
9960///
9961/// Instantiate a resource method builder
9962///
9963/// ```test_harness,no_run
9964/// # extern crate hyper;
9965/// # extern crate hyper_rustls;
9966/// # extern crate google_blogger3 as blogger3;
9967/// # async fn dox() {
9968/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9969///
9970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9971/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9972/// # .with_native_roots()
9973/// # .unwrap()
9974/// # .https_only()
9975/// # .enable_http2()
9976/// # .build();
9977///
9978/// # let executor = hyper_util::rt::TokioExecutor::new();
9979/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9980/// # secret,
9981/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9982/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9983/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9984/// # ),
9985/// # ).build().await.unwrap();
9986///
9987/// # let client = hyper_util::client::legacy::Client::builder(
9988/// # hyper_util::rt::TokioExecutor::new()
9989/// # )
9990/// # .build(
9991/// # hyper_rustls::HttpsConnectorBuilder::new()
9992/// # .with_native_roots()
9993/// # .unwrap()
9994/// # .https_or_http()
9995/// # .enable_http2()
9996/// # .build()
9997/// # );
9998/// # let mut hub = Blogger::new(client, auth);
9999/// // You can configure optional parameters by calling the respective setters at will, and
10000/// // execute the final call using `doit()`.
10001/// // Values shown here are possibly random and not representative !
10002/// let result = hub.posts().get("blogId", "postId")
10003/// .view("diam")
10004/// .max_comments(44)
10005/// .fetch_images(true)
10006/// .fetch_body(false)
10007/// .doit().await;
10008/// # }
10009/// ```
10010pub struct PostGetCall<'a, C>
10011where
10012 C: 'a,
10013{
10014 hub: &'a Blogger<C>,
10015 _blog_id: String,
10016 _post_id: String,
10017 _view: Option<String>,
10018 _max_comments: Option<u32>,
10019 _fetch_images: Option<bool>,
10020 _fetch_body: Option<bool>,
10021 _delegate: Option<&'a mut dyn common::Delegate>,
10022 _additional_params: HashMap<String, String>,
10023 _scopes: BTreeSet<String>,
10024}
10025
10026impl<'a, C> common::CallBuilder for PostGetCall<'a, C> {}
10027
10028impl<'a, C> PostGetCall<'a, C>
10029where
10030 C: common::Connector,
10031{
10032 /// Perform the operation you have build so far.
10033 pub async fn doit(mut self) -> common::Result<(common::Response, Post)> {
10034 use std::borrow::Cow;
10035 use std::io::{Read, Seek};
10036
10037 use common::{url::Params, ToParts};
10038 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10039
10040 let mut dd = common::DefaultDelegate;
10041 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10042 dlg.begin(common::MethodInfo {
10043 id: "blogger.posts.get",
10044 http_method: hyper::Method::GET,
10045 });
10046
10047 for &field in [
10048 "alt",
10049 "blogId",
10050 "postId",
10051 "view",
10052 "maxComments",
10053 "fetchImages",
10054 "fetchBody",
10055 ]
10056 .iter()
10057 {
10058 if self._additional_params.contains_key(field) {
10059 dlg.finished(false);
10060 return Err(common::Error::FieldClash(field));
10061 }
10062 }
10063
10064 let mut params = Params::with_capacity(8 + self._additional_params.len());
10065 params.push("blogId", self._blog_id);
10066 params.push("postId", self._post_id);
10067 if let Some(value) = self._view.as_ref() {
10068 params.push("view", value);
10069 }
10070 if let Some(value) = self._max_comments.as_ref() {
10071 params.push("maxComments", value.to_string());
10072 }
10073 if let Some(value) = self._fetch_images.as_ref() {
10074 params.push("fetchImages", value.to_string());
10075 }
10076 if let Some(value) = self._fetch_body.as_ref() {
10077 params.push("fetchBody", value.to_string());
10078 }
10079
10080 params.extend(self._additional_params.iter());
10081
10082 params.push("alt", "json");
10083 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}";
10084 if self._scopes.is_empty() {
10085 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10086 }
10087
10088 #[allow(clippy::single_element_loop)]
10089 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{postId}", "postId")].iter() {
10090 url = params.uri_replacement(url, param_name, find_this, false);
10091 }
10092 {
10093 let to_remove = ["postId", "blogId"];
10094 params.remove_params(&to_remove);
10095 }
10096
10097 let url = params.parse_with_url(&url);
10098
10099 loop {
10100 let token = match self
10101 .hub
10102 .auth
10103 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10104 .await
10105 {
10106 Ok(token) => token,
10107 Err(e) => match dlg.token(e) {
10108 Ok(token) => token,
10109 Err(e) => {
10110 dlg.finished(false);
10111 return Err(common::Error::MissingToken(e));
10112 }
10113 },
10114 };
10115 let mut req_result = {
10116 let client = &self.hub.client;
10117 dlg.pre_request();
10118 let mut req_builder = hyper::Request::builder()
10119 .method(hyper::Method::GET)
10120 .uri(url.as_str())
10121 .header(USER_AGENT, self.hub._user_agent.clone());
10122
10123 if let Some(token) = token.as_ref() {
10124 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10125 }
10126
10127 let request = req_builder
10128 .header(CONTENT_LENGTH, 0_u64)
10129 .body(common::to_body::<String>(None));
10130
10131 client.request(request.unwrap()).await
10132 };
10133
10134 match req_result {
10135 Err(err) => {
10136 if let common::Retry::After(d) = dlg.http_error(&err) {
10137 sleep(d).await;
10138 continue;
10139 }
10140 dlg.finished(false);
10141 return Err(common::Error::HttpError(err));
10142 }
10143 Ok(res) => {
10144 let (mut parts, body) = res.into_parts();
10145 let mut body = common::Body::new(body);
10146 if !parts.status.is_success() {
10147 let bytes = common::to_bytes(body).await.unwrap_or_default();
10148 let error = serde_json::from_str(&common::to_string(&bytes));
10149 let response = common::to_response(parts, bytes.into());
10150
10151 if let common::Retry::After(d) =
10152 dlg.http_failure(&response, error.as_ref().ok())
10153 {
10154 sleep(d).await;
10155 continue;
10156 }
10157
10158 dlg.finished(false);
10159
10160 return Err(match error {
10161 Ok(value) => common::Error::BadRequest(value),
10162 _ => common::Error::Failure(response),
10163 });
10164 }
10165 let response = {
10166 let bytes = common::to_bytes(body).await.unwrap_or_default();
10167 let encoded = common::to_string(&bytes);
10168 match serde_json::from_str(&encoded) {
10169 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10170 Err(error) => {
10171 dlg.response_json_decode_error(&encoded, &error);
10172 return Err(common::Error::JsonDecodeError(
10173 encoded.to_string(),
10174 error,
10175 ));
10176 }
10177 }
10178 };
10179
10180 dlg.finished(true);
10181 return Ok(response);
10182 }
10183 }
10184 }
10185 }
10186
10187 ///
10188 /// Sets the *blog id* path property to the given value.
10189 ///
10190 /// Even though the property as already been set when instantiating this call,
10191 /// we provide this method for API completeness.
10192 pub fn blog_id(mut self, new_value: &str) -> PostGetCall<'a, C> {
10193 self._blog_id = new_value.to_string();
10194 self
10195 }
10196 ///
10197 /// Sets the *post id* path property to the given value.
10198 ///
10199 /// Even though the property as already been set when instantiating this call,
10200 /// we provide this method for API completeness.
10201 pub fn post_id(mut self, new_value: &str) -> PostGetCall<'a, C> {
10202 self._post_id = new_value.to_string();
10203 self
10204 }
10205 ///
10206 /// Sets the *view* query property to the given value.
10207 pub fn view(mut self, new_value: &str) -> PostGetCall<'a, C> {
10208 self._view = Some(new_value.to_string());
10209 self
10210 }
10211 ///
10212 /// Sets the *max comments* query property to the given value.
10213 pub fn max_comments(mut self, new_value: u32) -> PostGetCall<'a, C> {
10214 self._max_comments = Some(new_value);
10215 self
10216 }
10217 ///
10218 /// Sets the *fetch images* query property to the given value.
10219 pub fn fetch_images(mut self, new_value: bool) -> PostGetCall<'a, C> {
10220 self._fetch_images = Some(new_value);
10221 self
10222 }
10223 ///
10224 /// Sets the *fetch body* query property to the given value.
10225 pub fn fetch_body(mut self, new_value: bool) -> PostGetCall<'a, C> {
10226 self._fetch_body = Some(new_value);
10227 self
10228 }
10229 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10230 /// while executing the actual API request.
10231 ///
10232 /// ````text
10233 /// It should be used to handle progress information, and to implement a certain level of resilience.
10234 /// ````
10235 ///
10236 /// Sets the *delegate* property to the given value.
10237 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostGetCall<'a, C> {
10238 self._delegate = Some(new_value);
10239 self
10240 }
10241
10242 /// Set any additional parameter of the query string used in the request.
10243 /// It should be used to set parameters which are not yet available through their own
10244 /// setters.
10245 ///
10246 /// Please note that this method must not be used to set any of the known parameters
10247 /// which have their own setter method. If done anyway, the request will fail.
10248 ///
10249 /// # Additional Parameters
10250 ///
10251 /// * *$.xgafv* (query-string) - V1 error format.
10252 /// * *access_token* (query-string) - OAuth access token.
10253 /// * *alt* (query-string) - Data format for response.
10254 /// * *callback* (query-string) - JSONP
10255 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10256 /// * *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.
10257 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10258 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10259 /// * *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.
10260 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10261 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10262 pub fn param<T>(mut self, name: T, value: T) -> PostGetCall<'a, C>
10263 where
10264 T: AsRef<str>,
10265 {
10266 self._additional_params
10267 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10268 self
10269 }
10270
10271 /// Identifies the authorization scope for the method you are building.
10272 ///
10273 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10274 /// [`Scope::Readonly`].
10275 ///
10276 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10277 /// tokens for more than one scope.
10278 ///
10279 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10280 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10281 /// sufficient, a read-write scope will do as well.
10282 pub fn add_scope<St>(mut self, scope: St) -> PostGetCall<'a, C>
10283 where
10284 St: AsRef<str>,
10285 {
10286 self._scopes.insert(String::from(scope.as_ref()));
10287 self
10288 }
10289 /// Identifies the authorization scope(s) for the method you are building.
10290 ///
10291 /// See [`Self::add_scope()`] for details.
10292 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostGetCall<'a, C>
10293 where
10294 I: IntoIterator<Item = St>,
10295 St: AsRef<str>,
10296 {
10297 self._scopes
10298 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10299 self
10300 }
10301
10302 /// Removes all scopes, and no default scope will be used either.
10303 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10304 /// for details).
10305 pub fn clear_scopes(mut self) -> PostGetCall<'a, C> {
10306 self._scopes.clear();
10307 self
10308 }
10309}
10310
10311/// Gets a post by path.
10312///
10313/// A builder for the *getByPath* method supported by a *post* resource.
10314/// It is not used directly, but through a [`PostMethods`] instance.
10315///
10316/// # Example
10317///
10318/// Instantiate a resource method builder
10319///
10320/// ```test_harness,no_run
10321/// # extern crate hyper;
10322/// # extern crate hyper_rustls;
10323/// # extern crate google_blogger3 as blogger3;
10324/// # async fn dox() {
10325/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10326///
10327/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10328/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10329/// # .with_native_roots()
10330/// # .unwrap()
10331/// # .https_only()
10332/// # .enable_http2()
10333/// # .build();
10334///
10335/// # let executor = hyper_util::rt::TokioExecutor::new();
10336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10337/// # secret,
10338/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10339/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10340/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10341/// # ),
10342/// # ).build().await.unwrap();
10343///
10344/// # let client = hyper_util::client::legacy::Client::builder(
10345/// # hyper_util::rt::TokioExecutor::new()
10346/// # )
10347/// # .build(
10348/// # hyper_rustls::HttpsConnectorBuilder::new()
10349/// # .with_native_roots()
10350/// # .unwrap()
10351/// # .https_or_http()
10352/// # .enable_http2()
10353/// # .build()
10354/// # );
10355/// # let mut hub = Blogger::new(client, auth);
10356/// // You can configure optional parameters by calling the respective setters at will, and
10357/// // execute the final call using `doit()`.
10358/// // Values shown here are possibly random and not representative !
10359/// let result = hub.posts().get_by_path("blogId", "path")
10360/// .view("ea")
10361/// .max_comments(86)
10362/// .doit().await;
10363/// # }
10364/// ```
10365pub struct PostGetByPathCall<'a, C>
10366where
10367 C: 'a,
10368{
10369 hub: &'a Blogger<C>,
10370 _blog_id: String,
10371 _path: String,
10372 _view: Option<String>,
10373 _max_comments: Option<u32>,
10374 _delegate: Option<&'a mut dyn common::Delegate>,
10375 _additional_params: HashMap<String, String>,
10376 _scopes: BTreeSet<String>,
10377}
10378
10379impl<'a, C> common::CallBuilder for PostGetByPathCall<'a, C> {}
10380
10381impl<'a, C> PostGetByPathCall<'a, C>
10382where
10383 C: common::Connector,
10384{
10385 /// Perform the operation you have build so far.
10386 pub async fn doit(mut self) -> common::Result<(common::Response, Post)> {
10387 use std::borrow::Cow;
10388 use std::io::{Read, Seek};
10389
10390 use common::{url::Params, ToParts};
10391 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10392
10393 let mut dd = common::DefaultDelegate;
10394 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10395 dlg.begin(common::MethodInfo {
10396 id: "blogger.posts.getByPath",
10397 http_method: hyper::Method::GET,
10398 });
10399
10400 for &field in ["alt", "blogId", "path", "view", "maxComments"].iter() {
10401 if self._additional_params.contains_key(field) {
10402 dlg.finished(false);
10403 return Err(common::Error::FieldClash(field));
10404 }
10405 }
10406
10407 let mut params = Params::with_capacity(6 + self._additional_params.len());
10408 params.push("blogId", self._blog_id);
10409 params.push("path", self._path);
10410 if let Some(value) = self._view.as_ref() {
10411 params.push("view", value);
10412 }
10413 if let Some(value) = self._max_comments.as_ref() {
10414 params.push("maxComments", value.to_string());
10415 }
10416
10417 params.extend(self._additional_params.iter());
10418
10419 params.push("alt", "json");
10420 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/bypath";
10421 if self._scopes.is_empty() {
10422 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10423 }
10424
10425 #[allow(clippy::single_element_loop)]
10426 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
10427 url = params.uri_replacement(url, param_name, find_this, false);
10428 }
10429 {
10430 let to_remove = ["blogId"];
10431 params.remove_params(&to_remove);
10432 }
10433
10434 let url = params.parse_with_url(&url);
10435
10436 loop {
10437 let token = match self
10438 .hub
10439 .auth
10440 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10441 .await
10442 {
10443 Ok(token) => token,
10444 Err(e) => match dlg.token(e) {
10445 Ok(token) => token,
10446 Err(e) => {
10447 dlg.finished(false);
10448 return Err(common::Error::MissingToken(e));
10449 }
10450 },
10451 };
10452 let mut req_result = {
10453 let client = &self.hub.client;
10454 dlg.pre_request();
10455 let mut req_builder = hyper::Request::builder()
10456 .method(hyper::Method::GET)
10457 .uri(url.as_str())
10458 .header(USER_AGENT, self.hub._user_agent.clone());
10459
10460 if let Some(token) = token.as_ref() {
10461 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10462 }
10463
10464 let request = req_builder
10465 .header(CONTENT_LENGTH, 0_u64)
10466 .body(common::to_body::<String>(None));
10467
10468 client.request(request.unwrap()).await
10469 };
10470
10471 match req_result {
10472 Err(err) => {
10473 if let common::Retry::After(d) = dlg.http_error(&err) {
10474 sleep(d).await;
10475 continue;
10476 }
10477 dlg.finished(false);
10478 return Err(common::Error::HttpError(err));
10479 }
10480 Ok(res) => {
10481 let (mut parts, body) = res.into_parts();
10482 let mut body = common::Body::new(body);
10483 if !parts.status.is_success() {
10484 let bytes = common::to_bytes(body).await.unwrap_or_default();
10485 let error = serde_json::from_str(&common::to_string(&bytes));
10486 let response = common::to_response(parts, bytes.into());
10487
10488 if let common::Retry::After(d) =
10489 dlg.http_failure(&response, error.as_ref().ok())
10490 {
10491 sleep(d).await;
10492 continue;
10493 }
10494
10495 dlg.finished(false);
10496
10497 return Err(match error {
10498 Ok(value) => common::Error::BadRequest(value),
10499 _ => common::Error::Failure(response),
10500 });
10501 }
10502 let response = {
10503 let bytes = common::to_bytes(body).await.unwrap_or_default();
10504 let encoded = common::to_string(&bytes);
10505 match serde_json::from_str(&encoded) {
10506 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10507 Err(error) => {
10508 dlg.response_json_decode_error(&encoded, &error);
10509 return Err(common::Error::JsonDecodeError(
10510 encoded.to_string(),
10511 error,
10512 ));
10513 }
10514 }
10515 };
10516
10517 dlg.finished(true);
10518 return Ok(response);
10519 }
10520 }
10521 }
10522 }
10523
10524 ///
10525 /// Sets the *blog id* path property to the given value.
10526 ///
10527 /// Even though the property as already been set when instantiating this call,
10528 /// we provide this method for API completeness.
10529 pub fn blog_id(mut self, new_value: &str) -> PostGetByPathCall<'a, C> {
10530 self._blog_id = new_value.to_string();
10531 self
10532 }
10533 ///
10534 /// Sets the *path* query property to the given value.
10535 ///
10536 /// Even though the property as already been set when instantiating this call,
10537 /// we provide this method for API completeness.
10538 pub fn path(mut self, new_value: &str) -> PostGetByPathCall<'a, C> {
10539 self._path = new_value.to_string();
10540 self
10541 }
10542 ///
10543 /// Sets the *view* query property to the given value.
10544 pub fn view(mut self, new_value: &str) -> PostGetByPathCall<'a, C> {
10545 self._view = Some(new_value.to_string());
10546 self
10547 }
10548 ///
10549 /// Sets the *max comments* query property to the given value.
10550 pub fn max_comments(mut self, new_value: u32) -> PostGetByPathCall<'a, C> {
10551 self._max_comments = Some(new_value);
10552 self
10553 }
10554 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10555 /// while executing the actual API request.
10556 ///
10557 /// ````text
10558 /// It should be used to handle progress information, and to implement a certain level of resilience.
10559 /// ````
10560 ///
10561 /// Sets the *delegate* property to the given value.
10562 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostGetByPathCall<'a, C> {
10563 self._delegate = Some(new_value);
10564 self
10565 }
10566
10567 /// Set any additional parameter of the query string used in the request.
10568 /// It should be used to set parameters which are not yet available through their own
10569 /// setters.
10570 ///
10571 /// Please note that this method must not be used to set any of the known parameters
10572 /// which have their own setter method. If done anyway, the request will fail.
10573 ///
10574 /// # Additional Parameters
10575 ///
10576 /// * *$.xgafv* (query-string) - V1 error format.
10577 /// * *access_token* (query-string) - OAuth access token.
10578 /// * *alt* (query-string) - Data format for response.
10579 /// * *callback* (query-string) - JSONP
10580 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10581 /// * *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.
10582 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10583 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10584 /// * *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.
10585 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10586 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10587 pub fn param<T>(mut self, name: T, value: T) -> PostGetByPathCall<'a, C>
10588 where
10589 T: AsRef<str>,
10590 {
10591 self._additional_params
10592 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10593 self
10594 }
10595
10596 /// Identifies the authorization scope for the method you are building.
10597 ///
10598 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10599 /// [`Scope::Readonly`].
10600 ///
10601 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10602 /// tokens for more than one scope.
10603 ///
10604 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10605 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10606 /// sufficient, a read-write scope will do as well.
10607 pub fn add_scope<St>(mut self, scope: St) -> PostGetByPathCall<'a, C>
10608 where
10609 St: AsRef<str>,
10610 {
10611 self._scopes.insert(String::from(scope.as_ref()));
10612 self
10613 }
10614 /// Identifies the authorization scope(s) for the method you are building.
10615 ///
10616 /// See [`Self::add_scope()`] for details.
10617 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostGetByPathCall<'a, C>
10618 where
10619 I: IntoIterator<Item = St>,
10620 St: AsRef<str>,
10621 {
10622 self._scopes
10623 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10624 self
10625 }
10626
10627 /// Removes all scopes, and no default scope will be used either.
10628 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10629 /// for details).
10630 pub fn clear_scopes(mut self) -> PostGetByPathCall<'a, C> {
10631 self._scopes.clear();
10632 self
10633 }
10634}
10635
10636/// Inserts a post.
10637///
10638/// A builder for the *insert* method supported by a *post* resource.
10639/// It is not used directly, but through a [`PostMethods`] instance.
10640///
10641/// # Example
10642///
10643/// Instantiate a resource method builder
10644///
10645/// ```test_harness,no_run
10646/// # extern crate hyper;
10647/// # extern crate hyper_rustls;
10648/// # extern crate google_blogger3 as blogger3;
10649/// use blogger3::api::Post;
10650/// # async fn dox() {
10651/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10652///
10653/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10654/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10655/// # .with_native_roots()
10656/// # .unwrap()
10657/// # .https_only()
10658/// # .enable_http2()
10659/// # .build();
10660///
10661/// # let executor = hyper_util::rt::TokioExecutor::new();
10662/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10663/// # secret,
10664/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10665/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10666/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10667/// # ),
10668/// # ).build().await.unwrap();
10669///
10670/// # let client = hyper_util::client::legacy::Client::builder(
10671/// # hyper_util::rt::TokioExecutor::new()
10672/// # )
10673/// # .build(
10674/// # hyper_rustls::HttpsConnectorBuilder::new()
10675/// # .with_native_roots()
10676/// # .unwrap()
10677/// # .https_or_http()
10678/// # .enable_http2()
10679/// # .build()
10680/// # );
10681/// # let mut hub = Blogger::new(client, auth);
10682/// // As the method needs a request, you would usually fill it with the desired information
10683/// // into the respective structure. Some of the parts shown here might not be applicable !
10684/// // Values shown here are possibly random and not representative !
10685/// let mut req = Post::default();
10686///
10687/// // You can configure optional parameters by calling the respective setters at will, and
10688/// // execute the final call using `doit()`.
10689/// // Values shown here are possibly random and not representative !
10690/// let result = hub.posts().insert(req, "blogId")
10691/// .is_draft(true)
10692/// .fetch_images(false)
10693/// .fetch_body(false)
10694/// .doit().await;
10695/// # }
10696/// ```
10697pub struct PostInsertCall<'a, C>
10698where
10699 C: 'a,
10700{
10701 hub: &'a Blogger<C>,
10702 _request: Post,
10703 _blog_id: String,
10704 _is_draft: Option<bool>,
10705 _fetch_images: Option<bool>,
10706 _fetch_body: Option<bool>,
10707 _delegate: Option<&'a mut dyn common::Delegate>,
10708 _additional_params: HashMap<String, String>,
10709 _scopes: BTreeSet<String>,
10710}
10711
10712impl<'a, C> common::CallBuilder for PostInsertCall<'a, C> {}
10713
10714impl<'a, C> PostInsertCall<'a, C>
10715where
10716 C: common::Connector,
10717{
10718 /// Perform the operation you have build so far.
10719 pub async fn doit(mut self) -> common::Result<(common::Response, Post)> {
10720 use std::borrow::Cow;
10721 use std::io::{Read, Seek};
10722
10723 use common::{url::Params, ToParts};
10724 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10725
10726 let mut dd = common::DefaultDelegate;
10727 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10728 dlg.begin(common::MethodInfo {
10729 id: "blogger.posts.insert",
10730 http_method: hyper::Method::POST,
10731 });
10732
10733 for &field in ["alt", "blogId", "isDraft", "fetchImages", "fetchBody"].iter() {
10734 if self._additional_params.contains_key(field) {
10735 dlg.finished(false);
10736 return Err(common::Error::FieldClash(field));
10737 }
10738 }
10739
10740 let mut params = Params::with_capacity(7 + self._additional_params.len());
10741 params.push("blogId", self._blog_id);
10742 if let Some(value) = self._is_draft.as_ref() {
10743 params.push("isDraft", value.to_string());
10744 }
10745 if let Some(value) = self._fetch_images.as_ref() {
10746 params.push("fetchImages", value.to_string());
10747 }
10748 if let Some(value) = self._fetch_body.as_ref() {
10749 params.push("fetchBody", value.to_string());
10750 }
10751
10752 params.extend(self._additional_params.iter());
10753
10754 params.push("alt", "json");
10755 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts";
10756 if self._scopes.is_empty() {
10757 self._scopes.insert(Scope::Full.as_ref().to_string());
10758 }
10759
10760 #[allow(clippy::single_element_loop)]
10761 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
10762 url = params.uri_replacement(url, param_name, find_this, false);
10763 }
10764 {
10765 let to_remove = ["blogId"];
10766 params.remove_params(&to_remove);
10767 }
10768
10769 let url = params.parse_with_url(&url);
10770
10771 let mut json_mime_type = mime::APPLICATION_JSON;
10772 let mut request_value_reader = {
10773 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10774 common::remove_json_null_values(&mut value);
10775 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10776 serde_json::to_writer(&mut dst, &value).unwrap();
10777 dst
10778 };
10779 let request_size = request_value_reader
10780 .seek(std::io::SeekFrom::End(0))
10781 .unwrap();
10782 request_value_reader
10783 .seek(std::io::SeekFrom::Start(0))
10784 .unwrap();
10785
10786 loop {
10787 let token = match self
10788 .hub
10789 .auth
10790 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10791 .await
10792 {
10793 Ok(token) => token,
10794 Err(e) => match dlg.token(e) {
10795 Ok(token) => token,
10796 Err(e) => {
10797 dlg.finished(false);
10798 return Err(common::Error::MissingToken(e));
10799 }
10800 },
10801 };
10802 request_value_reader
10803 .seek(std::io::SeekFrom::Start(0))
10804 .unwrap();
10805 let mut req_result = {
10806 let client = &self.hub.client;
10807 dlg.pre_request();
10808 let mut req_builder = hyper::Request::builder()
10809 .method(hyper::Method::POST)
10810 .uri(url.as_str())
10811 .header(USER_AGENT, self.hub._user_agent.clone());
10812
10813 if let Some(token) = token.as_ref() {
10814 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10815 }
10816
10817 let request = req_builder
10818 .header(CONTENT_TYPE, json_mime_type.to_string())
10819 .header(CONTENT_LENGTH, request_size as u64)
10820 .body(common::to_body(
10821 request_value_reader.get_ref().clone().into(),
10822 ));
10823
10824 client.request(request.unwrap()).await
10825 };
10826
10827 match req_result {
10828 Err(err) => {
10829 if let common::Retry::After(d) = dlg.http_error(&err) {
10830 sleep(d).await;
10831 continue;
10832 }
10833 dlg.finished(false);
10834 return Err(common::Error::HttpError(err));
10835 }
10836 Ok(res) => {
10837 let (mut parts, body) = res.into_parts();
10838 let mut body = common::Body::new(body);
10839 if !parts.status.is_success() {
10840 let bytes = common::to_bytes(body).await.unwrap_or_default();
10841 let error = serde_json::from_str(&common::to_string(&bytes));
10842 let response = common::to_response(parts, bytes.into());
10843
10844 if let common::Retry::After(d) =
10845 dlg.http_failure(&response, error.as_ref().ok())
10846 {
10847 sleep(d).await;
10848 continue;
10849 }
10850
10851 dlg.finished(false);
10852
10853 return Err(match error {
10854 Ok(value) => common::Error::BadRequest(value),
10855 _ => common::Error::Failure(response),
10856 });
10857 }
10858 let response = {
10859 let bytes = common::to_bytes(body).await.unwrap_or_default();
10860 let encoded = common::to_string(&bytes);
10861 match serde_json::from_str(&encoded) {
10862 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10863 Err(error) => {
10864 dlg.response_json_decode_error(&encoded, &error);
10865 return Err(common::Error::JsonDecodeError(
10866 encoded.to_string(),
10867 error,
10868 ));
10869 }
10870 }
10871 };
10872
10873 dlg.finished(true);
10874 return Ok(response);
10875 }
10876 }
10877 }
10878 }
10879
10880 ///
10881 /// Sets the *request* property to the given value.
10882 ///
10883 /// Even though the property as already been set when instantiating this call,
10884 /// we provide this method for API completeness.
10885 pub fn request(mut self, new_value: Post) -> PostInsertCall<'a, C> {
10886 self._request = new_value;
10887 self
10888 }
10889 ///
10890 /// Sets the *blog id* path property to the given value.
10891 ///
10892 /// Even though the property as already been set when instantiating this call,
10893 /// we provide this method for API completeness.
10894 pub fn blog_id(mut self, new_value: &str) -> PostInsertCall<'a, C> {
10895 self._blog_id = new_value.to_string();
10896 self
10897 }
10898 ///
10899 /// Sets the *is draft* query property to the given value.
10900 pub fn is_draft(mut self, new_value: bool) -> PostInsertCall<'a, C> {
10901 self._is_draft = Some(new_value);
10902 self
10903 }
10904 ///
10905 /// Sets the *fetch images* query property to the given value.
10906 pub fn fetch_images(mut self, new_value: bool) -> PostInsertCall<'a, C> {
10907 self._fetch_images = Some(new_value);
10908 self
10909 }
10910 ///
10911 /// Sets the *fetch body* query property to the given value.
10912 pub fn fetch_body(mut self, new_value: bool) -> PostInsertCall<'a, C> {
10913 self._fetch_body = Some(new_value);
10914 self
10915 }
10916 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10917 /// while executing the actual API request.
10918 ///
10919 /// ````text
10920 /// It should be used to handle progress information, and to implement a certain level of resilience.
10921 /// ````
10922 ///
10923 /// Sets the *delegate* property to the given value.
10924 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostInsertCall<'a, C> {
10925 self._delegate = Some(new_value);
10926 self
10927 }
10928
10929 /// Set any additional parameter of the query string used in the request.
10930 /// It should be used to set parameters which are not yet available through their own
10931 /// setters.
10932 ///
10933 /// Please note that this method must not be used to set any of the known parameters
10934 /// which have their own setter method. If done anyway, the request will fail.
10935 ///
10936 /// # Additional Parameters
10937 ///
10938 /// * *$.xgafv* (query-string) - V1 error format.
10939 /// * *access_token* (query-string) - OAuth access token.
10940 /// * *alt* (query-string) - Data format for response.
10941 /// * *callback* (query-string) - JSONP
10942 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10943 /// * *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.
10944 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10945 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10946 /// * *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.
10947 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10948 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10949 pub fn param<T>(mut self, name: T, value: T) -> PostInsertCall<'a, C>
10950 where
10951 T: AsRef<str>,
10952 {
10953 self._additional_params
10954 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10955 self
10956 }
10957
10958 /// Identifies the authorization scope for the method you are building.
10959 ///
10960 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10961 /// [`Scope::Full`].
10962 ///
10963 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10964 /// tokens for more than one scope.
10965 ///
10966 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10967 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10968 /// sufficient, a read-write scope will do as well.
10969 pub fn add_scope<St>(mut self, scope: St) -> PostInsertCall<'a, C>
10970 where
10971 St: AsRef<str>,
10972 {
10973 self._scopes.insert(String::from(scope.as_ref()));
10974 self
10975 }
10976 /// Identifies the authorization scope(s) for the method you are building.
10977 ///
10978 /// See [`Self::add_scope()`] for details.
10979 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostInsertCall<'a, C>
10980 where
10981 I: IntoIterator<Item = St>,
10982 St: AsRef<str>,
10983 {
10984 self._scopes
10985 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10986 self
10987 }
10988
10989 /// Removes all scopes, and no default scope will be used either.
10990 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10991 /// for details).
10992 pub fn clear_scopes(mut self) -> PostInsertCall<'a, C> {
10993 self._scopes.clear();
10994 self
10995 }
10996}
10997
10998/// Lists posts.
10999///
11000/// A builder for the *list* method supported by a *post* resource.
11001/// It is not used directly, but through a [`PostMethods`] instance.
11002///
11003/// # Example
11004///
11005/// Instantiate a resource method builder
11006///
11007/// ```test_harness,no_run
11008/// # extern crate hyper;
11009/// # extern crate hyper_rustls;
11010/// # extern crate google_blogger3 as blogger3;
11011/// # async fn dox() {
11012/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11013///
11014/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11015/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11016/// # .with_native_roots()
11017/// # .unwrap()
11018/// # .https_only()
11019/// # .enable_http2()
11020/// # .build();
11021///
11022/// # let executor = hyper_util::rt::TokioExecutor::new();
11023/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11024/// # secret,
11025/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11026/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11027/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11028/// # ),
11029/// # ).build().await.unwrap();
11030///
11031/// # let client = hyper_util::client::legacy::Client::builder(
11032/// # hyper_util::rt::TokioExecutor::new()
11033/// # )
11034/// # .build(
11035/// # hyper_rustls::HttpsConnectorBuilder::new()
11036/// # .with_native_roots()
11037/// # .unwrap()
11038/// # .https_or_http()
11039/// # .enable_http2()
11040/// # .build()
11041/// # );
11042/// # let mut hub = Blogger::new(client, auth);
11043/// // You can configure optional parameters by calling the respective setters at will, and
11044/// // execute the final call using `doit()`.
11045/// // Values shown here are possibly random and not representative !
11046/// let result = hub.posts().list("blogId")
11047/// .view("eirmod")
11048/// .add_status("Lorem")
11049/// .start_date("accusam")
11050/// .sort_option("amet")
11051/// .page_token("erat")
11052/// .order_by("dolores")
11053/// .max_results(20)
11054/// .labels("accusam")
11055/// .fetch_images(true)
11056/// .fetch_bodies(true)
11057/// .end_date("et")
11058/// .doit().await;
11059/// # }
11060/// ```
11061pub struct PostListCall<'a, C>
11062where
11063 C: 'a,
11064{
11065 hub: &'a Blogger<C>,
11066 _blog_id: String,
11067 _view: Option<String>,
11068 _status: Vec<String>,
11069 _start_date: Option<String>,
11070 _sort_option: Option<String>,
11071 _page_token: Option<String>,
11072 _order_by: Option<String>,
11073 _max_results: Option<u32>,
11074 _labels: Option<String>,
11075 _fetch_images: Option<bool>,
11076 _fetch_bodies: Option<bool>,
11077 _end_date: Option<String>,
11078 _delegate: Option<&'a mut dyn common::Delegate>,
11079 _additional_params: HashMap<String, String>,
11080 _scopes: BTreeSet<String>,
11081}
11082
11083impl<'a, C> common::CallBuilder for PostListCall<'a, C> {}
11084
11085impl<'a, C> PostListCall<'a, C>
11086where
11087 C: common::Connector,
11088{
11089 /// Perform the operation you have build so far.
11090 pub async fn doit(mut self) -> common::Result<(common::Response, PostList)> {
11091 use std::borrow::Cow;
11092 use std::io::{Read, Seek};
11093
11094 use common::{url::Params, ToParts};
11095 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11096
11097 let mut dd = common::DefaultDelegate;
11098 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11099 dlg.begin(common::MethodInfo {
11100 id: "blogger.posts.list",
11101 http_method: hyper::Method::GET,
11102 });
11103
11104 for &field in [
11105 "alt",
11106 "blogId",
11107 "view",
11108 "status",
11109 "startDate",
11110 "sortOption",
11111 "pageToken",
11112 "orderBy",
11113 "maxResults",
11114 "labels",
11115 "fetchImages",
11116 "fetchBodies",
11117 "endDate",
11118 ]
11119 .iter()
11120 {
11121 if self._additional_params.contains_key(field) {
11122 dlg.finished(false);
11123 return Err(common::Error::FieldClash(field));
11124 }
11125 }
11126
11127 let mut params = Params::with_capacity(14 + self._additional_params.len());
11128 params.push("blogId", self._blog_id);
11129 if let Some(value) = self._view.as_ref() {
11130 params.push("view", value);
11131 }
11132 if !self._status.is_empty() {
11133 for f in self._status.iter() {
11134 params.push("status", f);
11135 }
11136 }
11137 if let Some(value) = self._start_date.as_ref() {
11138 params.push("startDate", value);
11139 }
11140 if let Some(value) = self._sort_option.as_ref() {
11141 params.push("sortOption", value);
11142 }
11143 if let Some(value) = self._page_token.as_ref() {
11144 params.push("pageToken", value);
11145 }
11146 if let Some(value) = self._order_by.as_ref() {
11147 params.push("orderBy", value);
11148 }
11149 if let Some(value) = self._max_results.as_ref() {
11150 params.push("maxResults", value.to_string());
11151 }
11152 if let Some(value) = self._labels.as_ref() {
11153 params.push("labels", value);
11154 }
11155 if let Some(value) = self._fetch_images.as_ref() {
11156 params.push("fetchImages", value.to_string());
11157 }
11158 if let Some(value) = self._fetch_bodies.as_ref() {
11159 params.push("fetchBodies", value.to_string());
11160 }
11161 if let Some(value) = self._end_date.as_ref() {
11162 params.push("endDate", value);
11163 }
11164
11165 params.extend(self._additional_params.iter());
11166
11167 params.push("alt", "json");
11168 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts";
11169 if self._scopes.is_empty() {
11170 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11171 }
11172
11173 #[allow(clippy::single_element_loop)]
11174 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
11175 url = params.uri_replacement(url, param_name, find_this, false);
11176 }
11177 {
11178 let to_remove = ["blogId"];
11179 params.remove_params(&to_remove);
11180 }
11181
11182 let url = params.parse_with_url(&url);
11183
11184 loop {
11185 let token = match self
11186 .hub
11187 .auth
11188 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11189 .await
11190 {
11191 Ok(token) => token,
11192 Err(e) => match dlg.token(e) {
11193 Ok(token) => token,
11194 Err(e) => {
11195 dlg.finished(false);
11196 return Err(common::Error::MissingToken(e));
11197 }
11198 },
11199 };
11200 let mut req_result = {
11201 let client = &self.hub.client;
11202 dlg.pre_request();
11203 let mut req_builder = hyper::Request::builder()
11204 .method(hyper::Method::GET)
11205 .uri(url.as_str())
11206 .header(USER_AGENT, self.hub._user_agent.clone());
11207
11208 if let Some(token) = token.as_ref() {
11209 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11210 }
11211
11212 let request = req_builder
11213 .header(CONTENT_LENGTH, 0_u64)
11214 .body(common::to_body::<String>(None));
11215
11216 client.request(request.unwrap()).await
11217 };
11218
11219 match req_result {
11220 Err(err) => {
11221 if let common::Retry::After(d) = dlg.http_error(&err) {
11222 sleep(d).await;
11223 continue;
11224 }
11225 dlg.finished(false);
11226 return Err(common::Error::HttpError(err));
11227 }
11228 Ok(res) => {
11229 let (mut parts, body) = res.into_parts();
11230 let mut body = common::Body::new(body);
11231 if !parts.status.is_success() {
11232 let bytes = common::to_bytes(body).await.unwrap_or_default();
11233 let error = serde_json::from_str(&common::to_string(&bytes));
11234 let response = common::to_response(parts, bytes.into());
11235
11236 if let common::Retry::After(d) =
11237 dlg.http_failure(&response, error.as_ref().ok())
11238 {
11239 sleep(d).await;
11240 continue;
11241 }
11242
11243 dlg.finished(false);
11244
11245 return Err(match error {
11246 Ok(value) => common::Error::BadRequest(value),
11247 _ => common::Error::Failure(response),
11248 });
11249 }
11250 let response = {
11251 let bytes = common::to_bytes(body).await.unwrap_or_default();
11252 let encoded = common::to_string(&bytes);
11253 match serde_json::from_str(&encoded) {
11254 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11255 Err(error) => {
11256 dlg.response_json_decode_error(&encoded, &error);
11257 return Err(common::Error::JsonDecodeError(
11258 encoded.to_string(),
11259 error,
11260 ));
11261 }
11262 }
11263 };
11264
11265 dlg.finished(true);
11266 return Ok(response);
11267 }
11268 }
11269 }
11270 }
11271
11272 ///
11273 /// Sets the *blog id* path property to the given value.
11274 ///
11275 /// Even though the property as already been set when instantiating this call,
11276 /// we provide this method for API completeness.
11277 pub fn blog_id(mut self, new_value: &str) -> PostListCall<'a, C> {
11278 self._blog_id = new_value.to_string();
11279 self
11280 }
11281 ///
11282 /// Sets the *view* query property to the given value.
11283 pub fn view(mut self, new_value: &str) -> PostListCall<'a, C> {
11284 self._view = Some(new_value.to_string());
11285 self
11286 }
11287 ///
11288 /// Append the given value to the *status* query property.
11289 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11290 pub fn add_status(mut self, new_value: &str) -> PostListCall<'a, C> {
11291 self._status.push(new_value.to_string());
11292 self
11293 }
11294 ///
11295 /// Sets the *start date* query property to the given value.
11296 pub fn start_date(mut self, new_value: &str) -> PostListCall<'a, C> {
11297 self._start_date = Some(new_value.to_string());
11298 self
11299 }
11300 /// Sort direction applied to post list.
11301 ///
11302 /// Sets the *sort option* query property to the given value.
11303 pub fn sort_option(mut self, new_value: &str) -> PostListCall<'a, C> {
11304 self._sort_option = Some(new_value.to_string());
11305 self
11306 }
11307 ///
11308 /// Sets the *page token* query property to the given value.
11309 pub fn page_token(mut self, new_value: &str) -> PostListCall<'a, C> {
11310 self._page_token = Some(new_value.to_string());
11311 self
11312 }
11313 ///
11314 /// Sets the *order by* query property to the given value.
11315 pub fn order_by(mut self, new_value: &str) -> PostListCall<'a, C> {
11316 self._order_by = Some(new_value.to_string());
11317 self
11318 }
11319 ///
11320 /// Sets the *max results* query property to the given value.
11321 pub fn max_results(mut self, new_value: u32) -> PostListCall<'a, C> {
11322 self._max_results = Some(new_value);
11323 self
11324 }
11325 ///
11326 /// Sets the *labels* query property to the given value.
11327 pub fn labels(mut self, new_value: &str) -> PostListCall<'a, C> {
11328 self._labels = Some(new_value.to_string());
11329 self
11330 }
11331 ///
11332 /// Sets the *fetch images* query property to the given value.
11333 pub fn fetch_images(mut self, new_value: bool) -> PostListCall<'a, C> {
11334 self._fetch_images = Some(new_value);
11335 self
11336 }
11337 ///
11338 /// Sets the *fetch bodies* query property to the given value.
11339 pub fn fetch_bodies(mut self, new_value: bool) -> PostListCall<'a, C> {
11340 self._fetch_bodies = Some(new_value);
11341 self
11342 }
11343 ///
11344 /// Sets the *end date* query property to the given value.
11345 pub fn end_date(mut self, new_value: &str) -> PostListCall<'a, C> {
11346 self._end_date = Some(new_value.to_string());
11347 self
11348 }
11349 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11350 /// while executing the actual API request.
11351 ///
11352 /// ````text
11353 /// It should be used to handle progress information, and to implement a certain level of resilience.
11354 /// ````
11355 ///
11356 /// Sets the *delegate* property to the given value.
11357 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostListCall<'a, C> {
11358 self._delegate = Some(new_value);
11359 self
11360 }
11361
11362 /// Set any additional parameter of the query string used in the request.
11363 /// It should be used to set parameters which are not yet available through their own
11364 /// setters.
11365 ///
11366 /// Please note that this method must not be used to set any of the known parameters
11367 /// which have their own setter method. If done anyway, the request will fail.
11368 ///
11369 /// # Additional Parameters
11370 ///
11371 /// * *$.xgafv* (query-string) - V1 error format.
11372 /// * *access_token* (query-string) - OAuth access token.
11373 /// * *alt* (query-string) - Data format for response.
11374 /// * *callback* (query-string) - JSONP
11375 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11376 /// * *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.
11377 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11378 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11379 /// * *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.
11380 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11381 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11382 pub fn param<T>(mut self, name: T, value: T) -> PostListCall<'a, C>
11383 where
11384 T: AsRef<str>,
11385 {
11386 self._additional_params
11387 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11388 self
11389 }
11390
11391 /// Identifies the authorization scope for the method you are building.
11392 ///
11393 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11394 /// [`Scope::Readonly`].
11395 ///
11396 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11397 /// tokens for more than one scope.
11398 ///
11399 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11400 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11401 /// sufficient, a read-write scope will do as well.
11402 pub fn add_scope<St>(mut self, scope: St) -> PostListCall<'a, C>
11403 where
11404 St: AsRef<str>,
11405 {
11406 self._scopes.insert(String::from(scope.as_ref()));
11407 self
11408 }
11409 /// Identifies the authorization scope(s) for the method you are building.
11410 ///
11411 /// See [`Self::add_scope()`] for details.
11412 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostListCall<'a, C>
11413 where
11414 I: IntoIterator<Item = St>,
11415 St: AsRef<str>,
11416 {
11417 self._scopes
11418 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11419 self
11420 }
11421
11422 /// Removes all scopes, and no default scope will be used either.
11423 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11424 /// for details).
11425 pub fn clear_scopes(mut self) -> PostListCall<'a, C> {
11426 self._scopes.clear();
11427 self
11428 }
11429}
11430
11431/// Patches a post.
11432///
11433/// A builder for the *patch* method supported by a *post* resource.
11434/// It is not used directly, but through a [`PostMethods`] instance.
11435///
11436/// # Example
11437///
11438/// Instantiate a resource method builder
11439///
11440/// ```test_harness,no_run
11441/// # extern crate hyper;
11442/// # extern crate hyper_rustls;
11443/// # extern crate google_blogger3 as blogger3;
11444/// use blogger3::api::Post;
11445/// # async fn dox() {
11446/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11447///
11448/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11449/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11450/// # .with_native_roots()
11451/// # .unwrap()
11452/// # .https_only()
11453/// # .enable_http2()
11454/// # .build();
11455///
11456/// # let executor = hyper_util::rt::TokioExecutor::new();
11457/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11458/// # secret,
11459/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11460/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11461/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11462/// # ),
11463/// # ).build().await.unwrap();
11464///
11465/// # let client = hyper_util::client::legacy::Client::builder(
11466/// # hyper_util::rt::TokioExecutor::new()
11467/// # )
11468/// # .build(
11469/// # hyper_rustls::HttpsConnectorBuilder::new()
11470/// # .with_native_roots()
11471/// # .unwrap()
11472/// # .https_or_http()
11473/// # .enable_http2()
11474/// # .build()
11475/// # );
11476/// # let mut hub = Blogger::new(client, auth);
11477/// // As the method needs a request, you would usually fill it with the desired information
11478/// // into the respective structure. Some of the parts shown here might not be applicable !
11479/// // Values shown here are possibly random and not representative !
11480/// let mut req = Post::default();
11481///
11482/// // You can configure optional parameters by calling the respective setters at will, and
11483/// // execute the final call using `doit()`.
11484/// // Values shown here are possibly random and not representative !
11485/// let result = hub.posts().patch(req, "blogId", "postId")
11486/// .revert(true)
11487/// .publish(false)
11488/// .max_comments(91)
11489/// .fetch_images(true)
11490/// .fetch_body(true)
11491/// .doit().await;
11492/// # }
11493/// ```
11494pub struct PostPatchCall<'a, C>
11495where
11496 C: 'a,
11497{
11498 hub: &'a Blogger<C>,
11499 _request: Post,
11500 _blog_id: String,
11501 _post_id: String,
11502 _revert: Option<bool>,
11503 _publish: Option<bool>,
11504 _max_comments: Option<u32>,
11505 _fetch_images: Option<bool>,
11506 _fetch_body: Option<bool>,
11507 _delegate: Option<&'a mut dyn common::Delegate>,
11508 _additional_params: HashMap<String, String>,
11509 _scopes: BTreeSet<String>,
11510}
11511
11512impl<'a, C> common::CallBuilder for PostPatchCall<'a, C> {}
11513
11514impl<'a, C> PostPatchCall<'a, C>
11515where
11516 C: common::Connector,
11517{
11518 /// Perform the operation you have build so far.
11519 pub async fn doit(mut self) -> common::Result<(common::Response, Post)> {
11520 use std::borrow::Cow;
11521 use std::io::{Read, Seek};
11522
11523 use common::{url::Params, ToParts};
11524 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11525
11526 let mut dd = common::DefaultDelegate;
11527 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11528 dlg.begin(common::MethodInfo {
11529 id: "blogger.posts.patch",
11530 http_method: hyper::Method::PATCH,
11531 });
11532
11533 for &field in [
11534 "alt",
11535 "blogId",
11536 "postId",
11537 "revert",
11538 "publish",
11539 "maxComments",
11540 "fetchImages",
11541 "fetchBody",
11542 ]
11543 .iter()
11544 {
11545 if self._additional_params.contains_key(field) {
11546 dlg.finished(false);
11547 return Err(common::Error::FieldClash(field));
11548 }
11549 }
11550
11551 let mut params = Params::with_capacity(10 + self._additional_params.len());
11552 params.push("blogId", self._blog_id);
11553 params.push("postId", self._post_id);
11554 if let Some(value) = self._revert.as_ref() {
11555 params.push("revert", value.to_string());
11556 }
11557 if let Some(value) = self._publish.as_ref() {
11558 params.push("publish", value.to_string());
11559 }
11560 if let Some(value) = self._max_comments.as_ref() {
11561 params.push("maxComments", value.to_string());
11562 }
11563 if let Some(value) = self._fetch_images.as_ref() {
11564 params.push("fetchImages", value.to_string());
11565 }
11566 if let Some(value) = self._fetch_body.as_ref() {
11567 params.push("fetchBody", value.to_string());
11568 }
11569
11570 params.extend(self._additional_params.iter());
11571
11572 params.push("alt", "json");
11573 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}";
11574 if self._scopes.is_empty() {
11575 self._scopes.insert(Scope::Full.as_ref().to_string());
11576 }
11577
11578 #[allow(clippy::single_element_loop)]
11579 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{postId}", "postId")].iter() {
11580 url = params.uri_replacement(url, param_name, find_this, false);
11581 }
11582 {
11583 let to_remove = ["postId", "blogId"];
11584 params.remove_params(&to_remove);
11585 }
11586
11587 let url = params.parse_with_url(&url);
11588
11589 let mut json_mime_type = mime::APPLICATION_JSON;
11590 let mut request_value_reader = {
11591 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11592 common::remove_json_null_values(&mut value);
11593 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11594 serde_json::to_writer(&mut dst, &value).unwrap();
11595 dst
11596 };
11597 let request_size = request_value_reader
11598 .seek(std::io::SeekFrom::End(0))
11599 .unwrap();
11600 request_value_reader
11601 .seek(std::io::SeekFrom::Start(0))
11602 .unwrap();
11603
11604 loop {
11605 let token = match self
11606 .hub
11607 .auth
11608 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11609 .await
11610 {
11611 Ok(token) => token,
11612 Err(e) => match dlg.token(e) {
11613 Ok(token) => token,
11614 Err(e) => {
11615 dlg.finished(false);
11616 return Err(common::Error::MissingToken(e));
11617 }
11618 },
11619 };
11620 request_value_reader
11621 .seek(std::io::SeekFrom::Start(0))
11622 .unwrap();
11623 let mut req_result = {
11624 let client = &self.hub.client;
11625 dlg.pre_request();
11626 let mut req_builder = hyper::Request::builder()
11627 .method(hyper::Method::PATCH)
11628 .uri(url.as_str())
11629 .header(USER_AGENT, self.hub._user_agent.clone());
11630
11631 if let Some(token) = token.as_ref() {
11632 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11633 }
11634
11635 let request = req_builder
11636 .header(CONTENT_TYPE, json_mime_type.to_string())
11637 .header(CONTENT_LENGTH, request_size as u64)
11638 .body(common::to_body(
11639 request_value_reader.get_ref().clone().into(),
11640 ));
11641
11642 client.request(request.unwrap()).await
11643 };
11644
11645 match req_result {
11646 Err(err) => {
11647 if let common::Retry::After(d) = dlg.http_error(&err) {
11648 sleep(d).await;
11649 continue;
11650 }
11651 dlg.finished(false);
11652 return Err(common::Error::HttpError(err));
11653 }
11654 Ok(res) => {
11655 let (mut parts, body) = res.into_parts();
11656 let mut body = common::Body::new(body);
11657 if !parts.status.is_success() {
11658 let bytes = common::to_bytes(body).await.unwrap_or_default();
11659 let error = serde_json::from_str(&common::to_string(&bytes));
11660 let response = common::to_response(parts, bytes.into());
11661
11662 if let common::Retry::After(d) =
11663 dlg.http_failure(&response, error.as_ref().ok())
11664 {
11665 sleep(d).await;
11666 continue;
11667 }
11668
11669 dlg.finished(false);
11670
11671 return Err(match error {
11672 Ok(value) => common::Error::BadRequest(value),
11673 _ => common::Error::Failure(response),
11674 });
11675 }
11676 let response = {
11677 let bytes = common::to_bytes(body).await.unwrap_or_default();
11678 let encoded = common::to_string(&bytes);
11679 match serde_json::from_str(&encoded) {
11680 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11681 Err(error) => {
11682 dlg.response_json_decode_error(&encoded, &error);
11683 return Err(common::Error::JsonDecodeError(
11684 encoded.to_string(),
11685 error,
11686 ));
11687 }
11688 }
11689 };
11690
11691 dlg.finished(true);
11692 return Ok(response);
11693 }
11694 }
11695 }
11696 }
11697
11698 ///
11699 /// Sets the *request* property to the given value.
11700 ///
11701 /// Even though the property as already been set when instantiating this call,
11702 /// we provide this method for API completeness.
11703 pub fn request(mut self, new_value: Post) -> PostPatchCall<'a, C> {
11704 self._request = new_value;
11705 self
11706 }
11707 ///
11708 /// Sets the *blog id* path property to the given value.
11709 ///
11710 /// Even though the property as already been set when instantiating this call,
11711 /// we provide this method for API completeness.
11712 pub fn blog_id(mut self, new_value: &str) -> PostPatchCall<'a, C> {
11713 self._blog_id = new_value.to_string();
11714 self
11715 }
11716 ///
11717 /// Sets the *post id* path property to the given value.
11718 ///
11719 /// Even though the property as already been set when instantiating this call,
11720 /// we provide this method for API completeness.
11721 pub fn post_id(mut self, new_value: &str) -> PostPatchCall<'a, C> {
11722 self._post_id = new_value.to_string();
11723 self
11724 }
11725 ///
11726 /// Sets the *revert* query property to the given value.
11727 pub fn revert(mut self, new_value: bool) -> PostPatchCall<'a, C> {
11728 self._revert = Some(new_value);
11729 self
11730 }
11731 ///
11732 /// Sets the *publish* query property to the given value.
11733 pub fn publish(mut self, new_value: bool) -> PostPatchCall<'a, C> {
11734 self._publish = Some(new_value);
11735 self
11736 }
11737 ///
11738 /// Sets the *max comments* query property to the given value.
11739 pub fn max_comments(mut self, new_value: u32) -> PostPatchCall<'a, C> {
11740 self._max_comments = Some(new_value);
11741 self
11742 }
11743 ///
11744 /// Sets the *fetch images* query property to the given value.
11745 pub fn fetch_images(mut self, new_value: bool) -> PostPatchCall<'a, C> {
11746 self._fetch_images = Some(new_value);
11747 self
11748 }
11749 ///
11750 /// Sets the *fetch body* query property to the given value.
11751 pub fn fetch_body(mut self, new_value: bool) -> PostPatchCall<'a, C> {
11752 self._fetch_body = Some(new_value);
11753 self
11754 }
11755 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11756 /// while executing the actual API request.
11757 ///
11758 /// ````text
11759 /// It should be used to handle progress information, and to implement a certain level of resilience.
11760 /// ````
11761 ///
11762 /// Sets the *delegate* property to the given value.
11763 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostPatchCall<'a, C> {
11764 self._delegate = Some(new_value);
11765 self
11766 }
11767
11768 /// Set any additional parameter of the query string used in the request.
11769 /// It should be used to set parameters which are not yet available through their own
11770 /// setters.
11771 ///
11772 /// Please note that this method must not be used to set any of the known parameters
11773 /// which have their own setter method. If done anyway, the request will fail.
11774 ///
11775 /// # Additional Parameters
11776 ///
11777 /// * *$.xgafv* (query-string) - V1 error format.
11778 /// * *access_token* (query-string) - OAuth access token.
11779 /// * *alt* (query-string) - Data format for response.
11780 /// * *callback* (query-string) - JSONP
11781 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11782 /// * *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.
11783 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11784 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11785 /// * *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.
11786 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11787 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11788 pub fn param<T>(mut self, name: T, value: T) -> PostPatchCall<'a, C>
11789 where
11790 T: AsRef<str>,
11791 {
11792 self._additional_params
11793 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11794 self
11795 }
11796
11797 /// Identifies the authorization scope for the method you are building.
11798 ///
11799 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11800 /// [`Scope::Full`].
11801 ///
11802 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11803 /// tokens for more than one scope.
11804 ///
11805 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11806 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11807 /// sufficient, a read-write scope will do as well.
11808 pub fn add_scope<St>(mut self, scope: St) -> PostPatchCall<'a, C>
11809 where
11810 St: AsRef<str>,
11811 {
11812 self._scopes.insert(String::from(scope.as_ref()));
11813 self
11814 }
11815 /// Identifies the authorization scope(s) for the method you are building.
11816 ///
11817 /// See [`Self::add_scope()`] for details.
11818 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostPatchCall<'a, C>
11819 where
11820 I: IntoIterator<Item = St>,
11821 St: AsRef<str>,
11822 {
11823 self._scopes
11824 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11825 self
11826 }
11827
11828 /// Removes all scopes, and no default scope will be used either.
11829 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11830 /// for details).
11831 pub fn clear_scopes(mut self) -> PostPatchCall<'a, C> {
11832 self._scopes.clear();
11833 self
11834 }
11835}
11836
11837/// Publishes a post.
11838///
11839/// A builder for the *publish* method supported by a *post* resource.
11840/// It is not used directly, but through a [`PostMethods`] instance.
11841///
11842/// # Example
11843///
11844/// Instantiate a resource method builder
11845///
11846/// ```test_harness,no_run
11847/// # extern crate hyper;
11848/// # extern crate hyper_rustls;
11849/// # extern crate google_blogger3 as blogger3;
11850/// # async fn dox() {
11851/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11852///
11853/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11854/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11855/// # .with_native_roots()
11856/// # .unwrap()
11857/// # .https_only()
11858/// # .enable_http2()
11859/// # .build();
11860///
11861/// # let executor = hyper_util::rt::TokioExecutor::new();
11862/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11863/// # secret,
11864/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11865/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11866/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11867/// # ),
11868/// # ).build().await.unwrap();
11869///
11870/// # let client = hyper_util::client::legacy::Client::builder(
11871/// # hyper_util::rt::TokioExecutor::new()
11872/// # )
11873/// # .build(
11874/// # hyper_rustls::HttpsConnectorBuilder::new()
11875/// # .with_native_roots()
11876/// # .unwrap()
11877/// # .https_or_http()
11878/// # .enable_http2()
11879/// # .build()
11880/// # );
11881/// # let mut hub = Blogger::new(client, auth);
11882/// // You can configure optional parameters by calling the respective setters at will, and
11883/// // execute the final call using `doit()`.
11884/// // Values shown here are possibly random and not representative !
11885/// let result = hub.posts().publish("blogId", "postId")
11886/// .publish_date("aliquyam")
11887/// .doit().await;
11888/// # }
11889/// ```
11890pub struct PostPublishCall<'a, C>
11891where
11892 C: 'a,
11893{
11894 hub: &'a Blogger<C>,
11895 _blog_id: String,
11896 _post_id: String,
11897 _publish_date: Option<String>,
11898 _delegate: Option<&'a mut dyn common::Delegate>,
11899 _additional_params: HashMap<String, String>,
11900 _scopes: BTreeSet<String>,
11901}
11902
11903impl<'a, C> common::CallBuilder for PostPublishCall<'a, C> {}
11904
11905impl<'a, C> PostPublishCall<'a, C>
11906where
11907 C: common::Connector,
11908{
11909 /// Perform the operation you have build so far.
11910 pub async fn doit(mut self) -> common::Result<(common::Response, Post)> {
11911 use std::borrow::Cow;
11912 use std::io::{Read, Seek};
11913
11914 use common::{url::Params, ToParts};
11915 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11916
11917 let mut dd = common::DefaultDelegate;
11918 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11919 dlg.begin(common::MethodInfo {
11920 id: "blogger.posts.publish",
11921 http_method: hyper::Method::POST,
11922 });
11923
11924 for &field in ["alt", "blogId", "postId", "publishDate"].iter() {
11925 if self._additional_params.contains_key(field) {
11926 dlg.finished(false);
11927 return Err(common::Error::FieldClash(field));
11928 }
11929 }
11930
11931 let mut params = Params::with_capacity(5 + self._additional_params.len());
11932 params.push("blogId", self._blog_id);
11933 params.push("postId", self._post_id);
11934 if let Some(value) = self._publish_date.as_ref() {
11935 params.push("publishDate", value);
11936 }
11937
11938 params.extend(self._additional_params.iter());
11939
11940 params.push("alt", "json");
11941 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}/publish";
11942 if self._scopes.is_empty() {
11943 self._scopes.insert(Scope::Full.as_ref().to_string());
11944 }
11945
11946 #[allow(clippy::single_element_loop)]
11947 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{postId}", "postId")].iter() {
11948 url = params.uri_replacement(url, param_name, find_this, false);
11949 }
11950 {
11951 let to_remove = ["postId", "blogId"];
11952 params.remove_params(&to_remove);
11953 }
11954
11955 let url = params.parse_with_url(&url);
11956
11957 loop {
11958 let token = match self
11959 .hub
11960 .auth
11961 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11962 .await
11963 {
11964 Ok(token) => token,
11965 Err(e) => match dlg.token(e) {
11966 Ok(token) => token,
11967 Err(e) => {
11968 dlg.finished(false);
11969 return Err(common::Error::MissingToken(e));
11970 }
11971 },
11972 };
11973 let mut req_result = {
11974 let client = &self.hub.client;
11975 dlg.pre_request();
11976 let mut req_builder = hyper::Request::builder()
11977 .method(hyper::Method::POST)
11978 .uri(url.as_str())
11979 .header(USER_AGENT, self.hub._user_agent.clone());
11980
11981 if let Some(token) = token.as_ref() {
11982 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11983 }
11984
11985 let request = req_builder
11986 .header(CONTENT_LENGTH, 0_u64)
11987 .body(common::to_body::<String>(None));
11988
11989 client.request(request.unwrap()).await
11990 };
11991
11992 match req_result {
11993 Err(err) => {
11994 if let common::Retry::After(d) = dlg.http_error(&err) {
11995 sleep(d).await;
11996 continue;
11997 }
11998 dlg.finished(false);
11999 return Err(common::Error::HttpError(err));
12000 }
12001 Ok(res) => {
12002 let (mut parts, body) = res.into_parts();
12003 let mut body = common::Body::new(body);
12004 if !parts.status.is_success() {
12005 let bytes = common::to_bytes(body).await.unwrap_or_default();
12006 let error = serde_json::from_str(&common::to_string(&bytes));
12007 let response = common::to_response(parts, bytes.into());
12008
12009 if let common::Retry::After(d) =
12010 dlg.http_failure(&response, error.as_ref().ok())
12011 {
12012 sleep(d).await;
12013 continue;
12014 }
12015
12016 dlg.finished(false);
12017
12018 return Err(match error {
12019 Ok(value) => common::Error::BadRequest(value),
12020 _ => common::Error::Failure(response),
12021 });
12022 }
12023 let response = {
12024 let bytes = common::to_bytes(body).await.unwrap_or_default();
12025 let encoded = common::to_string(&bytes);
12026 match serde_json::from_str(&encoded) {
12027 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12028 Err(error) => {
12029 dlg.response_json_decode_error(&encoded, &error);
12030 return Err(common::Error::JsonDecodeError(
12031 encoded.to_string(),
12032 error,
12033 ));
12034 }
12035 }
12036 };
12037
12038 dlg.finished(true);
12039 return Ok(response);
12040 }
12041 }
12042 }
12043 }
12044
12045 ///
12046 /// Sets the *blog id* path property to the given value.
12047 ///
12048 /// Even though the property as already been set when instantiating this call,
12049 /// we provide this method for API completeness.
12050 pub fn blog_id(mut self, new_value: &str) -> PostPublishCall<'a, C> {
12051 self._blog_id = new_value.to_string();
12052 self
12053 }
12054 ///
12055 /// Sets the *post id* path property to the given value.
12056 ///
12057 /// Even though the property as already been set when instantiating this call,
12058 /// we provide this method for API completeness.
12059 pub fn post_id(mut self, new_value: &str) -> PostPublishCall<'a, C> {
12060 self._post_id = new_value.to_string();
12061 self
12062 }
12063 ///
12064 /// Sets the *publish date* query property to the given value.
12065 pub fn publish_date(mut self, new_value: &str) -> PostPublishCall<'a, C> {
12066 self._publish_date = Some(new_value.to_string());
12067 self
12068 }
12069 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12070 /// while executing the actual API request.
12071 ///
12072 /// ````text
12073 /// It should be used to handle progress information, and to implement a certain level of resilience.
12074 /// ````
12075 ///
12076 /// Sets the *delegate* property to the given value.
12077 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostPublishCall<'a, C> {
12078 self._delegate = Some(new_value);
12079 self
12080 }
12081
12082 /// Set any additional parameter of the query string used in the request.
12083 /// It should be used to set parameters which are not yet available through their own
12084 /// setters.
12085 ///
12086 /// Please note that this method must not be used to set any of the known parameters
12087 /// which have their own setter method. If done anyway, the request will fail.
12088 ///
12089 /// # Additional Parameters
12090 ///
12091 /// * *$.xgafv* (query-string) - V1 error format.
12092 /// * *access_token* (query-string) - OAuth access token.
12093 /// * *alt* (query-string) - Data format for response.
12094 /// * *callback* (query-string) - JSONP
12095 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12096 /// * *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.
12097 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12098 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12099 /// * *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.
12100 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12101 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12102 pub fn param<T>(mut self, name: T, value: T) -> PostPublishCall<'a, C>
12103 where
12104 T: AsRef<str>,
12105 {
12106 self._additional_params
12107 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12108 self
12109 }
12110
12111 /// Identifies the authorization scope for the method you are building.
12112 ///
12113 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12114 /// [`Scope::Full`].
12115 ///
12116 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12117 /// tokens for more than one scope.
12118 ///
12119 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12120 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12121 /// sufficient, a read-write scope will do as well.
12122 pub fn add_scope<St>(mut self, scope: St) -> PostPublishCall<'a, C>
12123 where
12124 St: AsRef<str>,
12125 {
12126 self._scopes.insert(String::from(scope.as_ref()));
12127 self
12128 }
12129 /// Identifies the authorization scope(s) for the method you are building.
12130 ///
12131 /// See [`Self::add_scope()`] for details.
12132 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostPublishCall<'a, C>
12133 where
12134 I: IntoIterator<Item = St>,
12135 St: AsRef<str>,
12136 {
12137 self._scopes
12138 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12139 self
12140 }
12141
12142 /// Removes all scopes, and no default scope will be used either.
12143 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12144 /// for details).
12145 pub fn clear_scopes(mut self) -> PostPublishCall<'a, C> {
12146 self._scopes.clear();
12147 self
12148 }
12149}
12150
12151/// Reverts a published or scheduled post to draft state.
12152///
12153/// A builder for the *revert* method supported by a *post* resource.
12154/// It is not used directly, but through a [`PostMethods`] instance.
12155///
12156/// # Example
12157///
12158/// Instantiate a resource method builder
12159///
12160/// ```test_harness,no_run
12161/// # extern crate hyper;
12162/// # extern crate hyper_rustls;
12163/// # extern crate google_blogger3 as blogger3;
12164/// # async fn dox() {
12165/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12166///
12167/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12168/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12169/// # .with_native_roots()
12170/// # .unwrap()
12171/// # .https_only()
12172/// # .enable_http2()
12173/// # .build();
12174///
12175/// # let executor = hyper_util::rt::TokioExecutor::new();
12176/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12177/// # secret,
12178/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12179/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12180/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12181/// # ),
12182/// # ).build().await.unwrap();
12183///
12184/// # let client = hyper_util::client::legacy::Client::builder(
12185/// # hyper_util::rt::TokioExecutor::new()
12186/// # )
12187/// # .build(
12188/// # hyper_rustls::HttpsConnectorBuilder::new()
12189/// # .with_native_roots()
12190/// # .unwrap()
12191/// # .https_or_http()
12192/// # .enable_http2()
12193/// # .build()
12194/// # );
12195/// # let mut hub = Blogger::new(client, auth);
12196/// // You can configure optional parameters by calling the respective setters at will, and
12197/// // execute the final call using `doit()`.
12198/// // Values shown here are possibly random and not representative !
12199/// let result = hub.posts().revert("blogId", "postId")
12200/// .doit().await;
12201/// # }
12202/// ```
12203pub struct PostRevertCall<'a, C>
12204where
12205 C: 'a,
12206{
12207 hub: &'a Blogger<C>,
12208 _blog_id: String,
12209 _post_id: String,
12210 _delegate: Option<&'a mut dyn common::Delegate>,
12211 _additional_params: HashMap<String, String>,
12212 _scopes: BTreeSet<String>,
12213}
12214
12215impl<'a, C> common::CallBuilder for PostRevertCall<'a, C> {}
12216
12217impl<'a, C> PostRevertCall<'a, C>
12218where
12219 C: common::Connector,
12220{
12221 /// Perform the operation you have build so far.
12222 pub async fn doit(mut self) -> common::Result<(common::Response, Post)> {
12223 use std::borrow::Cow;
12224 use std::io::{Read, Seek};
12225
12226 use common::{url::Params, ToParts};
12227 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12228
12229 let mut dd = common::DefaultDelegate;
12230 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12231 dlg.begin(common::MethodInfo {
12232 id: "blogger.posts.revert",
12233 http_method: hyper::Method::POST,
12234 });
12235
12236 for &field in ["alt", "blogId", "postId"].iter() {
12237 if self._additional_params.contains_key(field) {
12238 dlg.finished(false);
12239 return Err(common::Error::FieldClash(field));
12240 }
12241 }
12242
12243 let mut params = Params::with_capacity(4 + self._additional_params.len());
12244 params.push("blogId", self._blog_id);
12245 params.push("postId", self._post_id);
12246
12247 params.extend(self._additional_params.iter());
12248
12249 params.push("alt", "json");
12250 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}/revert";
12251 if self._scopes.is_empty() {
12252 self._scopes.insert(Scope::Full.as_ref().to_string());
12253 }
12254
12255 #[allow(clippy::single_element_loop)]
12256 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{postId}", "postId")].iter() {
12257 url = params.uri_replacement(url, param_name, find_this, false);
12258 }
12259 {
12260 let to_remove = ["postId", "blogId"];
12261 params.remove_params(&to_remove);
12262 }
12263
12264 let url = params.parse_with_url(&url);
12265
12266 loop {
12267 let token = match self
12268 .hub
12269 .auth
12270 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12271 .await
12272 {
12273 Ok(token) => token,
12274 Err(e) => match dlg.token(e) {
12275 Ok(token) => token,
12276 Err(e) => {
12277 dlg.finished(false);
12278 return Err(common::Error::MissingToken(e));
12279 }
12280 },
12281 };
12282 let mut req_result = {
12283 let client = &self.hub.client;
12284 dlg.pre_request();
12285 let mut req_builder = hyper::Request::builder()
12286 .method(hyper::Method::POST)
12287 .uri(url.as_str())
12288 .header(USER_AGENT, self.hub._user_agent.clone());
12289
12290 if let Some(token) = token.as_ref() {
12291 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12292 }
12293
12294 let request = req_builder
12295 .header(CONTENT_LENGTH, 0_u64)
12296 .body(common::to_body::<String>(None));
12297
12298 client.request(request.unwrap()).await
12299 };
12300
12301 match req_result {
12302 Err(err) => {
12303 if let common::Retry::After(d) = dlg.http_error(&err) {
12304 sleep(d).await;
12305 continue;
12306 }
12307 dlg.finished(false);
12308 return Err(common::Error::HttpError(err));
12309 }
12310 Ok(res) => {
12311 let (mut parts, body) = res.into_parts();
12312 let mut body = common::Body::new(body);
12313 if !parts.status.is_success() {
12314 let bytes = common::to_bytes(body).await.unwrap_or_default();
12315 let error = serde_json::from_str(&common::to_string(&bytes));
12316 let response = common::to_response(parts, bytes.into());
12317
12318 if let common::Retry::After(d) =
12319 dlg.http_failure(&response, error.as_ref().ok())
12320 {
12321 sleep(d).await;
12322 continue;
12323 }
12324
12325 dlg.finished(false);
12326
12327 return Err(match error {
12328 Ok(value) => common::Error::BadRequest(value),
12329 _ => common::Error::Failure(response),
12330 });
12331 }
12332 let response = {
12333 let bytes = common::to_bytes(body).await.unwrap_or_default();
12334 let encoded = common::to_string(&bytes);
12335 match serde_json::from_str(&encoded) {
12336 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12337 Err(error) => {
12338 dlg.response_json_decode_error(&encoded, &error);
12339 return Err(common::Error::JsonDecodeError(
12340 encoded.to_string(),
12341 error,
12342 ));
12343 }
12344 }
12345 };
12346
12347 dlg.finished(true);
12348 return Ok(response);
12349 }
12350 }
12351 }
12352 }
12353
12354 ///
12355 /// Sets the *blog id* path property to the given value.
12356 ///
12357 /// Even though the property as already been set when instantiating this call,
12358 /// we provide this method for API completeness.
12359 pub fn blog_id(mut self, new_value: &str) -> PostRevertCall<'a, C> {
12360 self._blog_id = new_value.to_string();
12361 self
12362 }
12363 ///
12364 /// Sets the *post id* path property to the given value.
12365 ///
12366 /// Even though the property as already been set when instantiating this call,
12367 /// we provide this method for API completeness.
12368 pub fn post_id(mut self, new_value: &str) -> PostRevertCall<'a, C> {
12369 self._post_id = new_value.to_string();
12370 self
12371 }
12372 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12373 /// while executing the actual API request.
12374 ///
12375 /// ````text
12376 /// It should be used to handle progress information, and to implement a certain level of resilience.
12377 /// ````
12378 ///
12379 /// Sets the *delegate* property to the given value.
12380 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostRevertCall<'a, C> {
12381 self._delegate = Some(new_value);
12382 self
12383 }
12384
12385 /// Set any additional parameter of the query string used in the request.
12386 /// It should be used to set parameters which are not yet available through their own
12387 /// setters.
12388 ///
12389 /// Please note that this method must not be used to set any of the known parameters
12390 /// which have their own setter method. If done anyway, the request will fail.
12391 ///
12392 /// # Additional Parameters
12393 ///
12394 /// * *$.xgafv* (query-string) - V1 error format.
12395 /// * *access_token* (query-string) - OAuth access token.
12396 /// * *alt* (query-string) - Data format for response.
12397 /// * *callback* (query-string) - JSONP
12398 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12399 /// * *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.
12400 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12401 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12402 /// * *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.
12403 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12404 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12405 pub fn param<T>(mut self, name: T, value: T) -> PostRevertCall<'a, C>
12406 where
12407 T: AsRef<str>,
12408 {
12409 self._additional_params
12410 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12411 self
12412 }
12413
12414 /// Identifies the authorization scope for the method you are building.
12415 ///
12416 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12417 /// [`Scope::Full`].
12418 ///
12419 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12420 /// tokens for more than one scope.
12421 ///
12422 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12423 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12424 /// sufficient, a read-write scope will do as well.
12425 pub fn add_scope<St>(mut self, scope: St) -> PostRevertCall<'a, C>
12426 where
12427 St: AsRef<str>,
12428 {
12429 self._scopes.insert(String::from(scope.as_ref()));
12430 self
12431 }
12432 /// Identifies the authorization scope(s) for the method you are building.
12433 ///
12434 /// See [`Self::add_scope()`] for details.
12435 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostRevertCall<'a, C>
12436 where
12437 I: IntoIterator<Item = St>,
12438 St: AsRef<str>,
12439 {
12440 self._scopes
12441 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12442 self
12443 }
12444
12445 /// Removes all scopes, and no default scope will be used either.
12446 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12447 /// for details).
12448 pub fn clear_scopes(mut self) -> PostRevertCall<'a, C> {
12449 self._scopes.clear();
12450 self
12451 }
12452}
12453
12454/// Searches for posts matching given query terms in the specified blog.
12455///
12456/// A builder for the *search* method supported by a *post* resource.
12457/// It is not used directly, but through a [`PostMethods`] instance.
12458///
12459/// # Example
12460///
12461/// Instantiate a resource method builder
12462///
12463/// ```test_harness,no_run
12464/// # extern crate hyper;
12465/// # extern crate hyper_rustls;
12466/// # extern crate google_blogger3 as blogger3;
12467/// # async fn dox() {
12468/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12469///
12470/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12471/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12472/// # .with_native_roots()
12473/// # .unwrap()
12474/// # .https_only()
12475/// # .enable_http2()
12476/// # .build();
12477///
12478/// # let executor = hyper_util::rt::TokioExecutor::new();
12479/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12480/// # secret,
12481/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12482/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12483/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12484/// # ),
12485/// # ).build().await.unwrap();
12486///
12487/// # let client = hyper_util::client::legacy::Client::builder(
12488/// # hyper_util::rt::TokioExecutor::new()
12489/// # )
12490/// # .build(
12491/// # hyper_rustls::HttpsConnectorBuilder::new()
12492/// # .with_native_roots()
12493/// # .unwrap()
12494/// # .https_or_http()
12495/// # .enable_http2()
12496/// # .build()
12497/// # );
12498/// # let mut hub = Blogger::new(client, auth);
12499/// // You can configure optional parameters by calling the respective setters at will, and
12500/// // execute the final call using `doit()`.
12501/// // Values shown here are possibly random and not representative !
12502/// let result = hub.posts().search("blogId", "q")
12503/// .order_by("gubergren")
12504/// .fetch_bodies(true)
12505/// .doit().await;
12506/// # }
12507/// ```
12508pub struct PostSearchCall<'a, C>
12509where
12510 C: 'a,
12511{
12512 hub: &'a Blogger<C>,
12513 _blog_id: String,
12514 _q: String,
12515 _order_by: Option<String>,
12516 _fetch_bodies: Option<bool>,
12517 _delegate: Option<&'a mut dyn common::Delegate>,
12518 _additional_params: HashMap<String, String>,
12519 _scopes: BTreeSet<String>,
12520}
12521
12522impl<'a, C> common::CallBuilder for PostSearchCall<'a, C> {}
12523
12524impl<'a, C> PostSearchCall<'a, C>
12525where
12526 C: common::Connector,
12527{
12528 /// Perform the operation you have build so far.
12529 pub async fn doit(mut self) -> common::Result<(common::Response, PostList)> {
12530 use std::borrow::Cow;
12531 use std::io::{Read, Seek};
12532
12533 use common::{url::Params, ToParts};
12534 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12535
12536 let mut dd = common::DefaultDelegate;
12537 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12538 dlg.begin(common::MethodInfo {
12539 id: "blogger.posts.search",
12540 http_method: hyper::Method::GET,
12541 });
12542
12543 for &field in ["alt", "blogId", "q", "orderBy", "fetchBodies"].iter() {
12544 if self._additional_params.contains_key(field) {
12545 dlg.finished(false);
12546 return Err(common::Error::FieldClash(field));
12547 }
12548 }
12549
12550 let mut params = Params::with_capacity(6 + self._additional_params.len());
12551 params.push("blogId", self._blog_id);
12552 params.push("q", self._q);
12553 if let Some(value) = self._order_by.as_ref() {
12554 params.push("orderBy", value);
12555 }
12556 if let Some(value) = self._fetch_bodies.as_ref() {
12557 params.push("fetchBodies", value.to_string());
12558 }
12559
12560 params.extend(self._additional_params.iter());
12561
12562 params.push("alt", "json");
12563 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/search";
12564 if self._scopes.is_empty() {
12565 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12566 }
12567
12568 #[allow(clippy::single_element_loop)]
12569 for &(find_this, param_name) in [("{blogId}", "blogId")].iter() {
12570 url = params.uri_replacement(url, param_name, find_this, false);
12571 }
12572 {
12573 let to_remove = ["blogId"];
12574 params.remove_params(&to_remove);
12575 }
12576
12577 let url = params.parse_with_url(&url);
12578
12579 loop {
12580 let token = match self
12581 .hub
12582 .auth
12583 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12584 .await
12585 {
12586 Ok(token) => token,
12587 Err(e) => match dlg.token(e) {
12588 Ok(token) => token,
12589 Err(e) => {
12590 dlg.finished(false);
12591 return Err(common::Error::MissingToken(e));
12592 }
12593 },
12594 };
12595 let mut req_result = {
12596 let client = &self.hub.client;
12597 dlg.pre_request();
12598 let mut req_builder = hyper::Request::builder()
12599 .method(hyper::Method::GET)
12600 .uri(url.as_str())
12601 .header(USER_AGENT, self.hub._user_agent.clone());
12602
12603 if let Some(token) = token.as_ref() {
12604 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12605 }
12606
12607 let request = req_builder
12608 .header(CONTENT_LENGTH, 0_u64)
12609 .body(common::to_body::<String>(None));
12610
12611 client.request(request.unwrap()).await
12612 };
12613
12614 match req_result {
12615 Err(err) => {
12616 if let common::Retry::After(d) = dlg.http_error(&err) {
12617 sleep(d).await;
12618 continue;
12619 }
12620 dlg.finished(false);
12621 return Err(common::Error::HttpError(err));
12622 }
12623 Ok(res) => {
12624 let (mut parts, body) = res.into_parts();
12625 let mut body = common::Body::new(body);
12626 if !parts.status.is_success() {
12627 let bytes = common::to_bytes(body).await.unwrap_or_default();
12628 let error = serde_json::from_str(&common::to_string(&bytes));
12629 let response = common::to_response(parts, bytes.into());
12630
12631 if let common::Retry::After(d) =
12632 dlg.http_failure(&response, error.as_ref().ok())
12633 {
12634 sleep(d).await;
12635 continue;
12636 }
12637
12638 dlg.finished(false);
12639
12640 return Err(match error {
12641 Ok(value) => common::Error::BadRequest(value),
12642 _ => common::Error::Failure(response),
12643 });
12644 }
12645 let response = {
12646 let bytes = common::to_bytes(body).await.unwrap_or_default();
12647 let encoded = common::to_string(&bytes);
12648 match serde_json::from_str(&encoded) {
12649 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12650 Err(error) => {
12651 dlg.response_json_decode_error(&encoded, &error);
12652 return Err(common::Error::JsonDecodeError(
12653 encoded.to_string(),
12654 error,
12655 ));
12656 }
12657 }
12658 };
12659
12660 dlg.finished(true);
12661 return Ok(response);
12662 }
12663 }
12664 }
12665 }
12666
12667 ///
12668 /// Sets the *blog id* path property to the given value.
12669 ///
12670 /// Even though the property as already been set when instantiating this call,
12671 /// we provide this method for API completeness.
12672 pub fn blog_id(mut self, new_value: &str) -> PostSearchCall<'a, C> {
12673 self._blog_id = new_value.to_string();
12674 self
12675 }
12676 ///
12677 /// Sets the *q* query property to the given value.
12678 ///
12679 /// Even though the property as already been set when instantiating this call,
12680 /// we provide this method for API completeness.
12681 pub fn q(mut self, new_value: &str) -> PostSearchCall<'a, C> {
12682 self._q = new_value.to_string();
12683 self
12684 }
12685 ///
12686 /// Sets the *order by* query property to the given value.
12687 pub fn order_by(mut self, new_value: &str) -> PostSearchCall<'a, C> {
12688 self._order_by = Some(new_value.to_string());
12689 self
12690 }
12691 ///
12692 /// Sets the *fetch bodies* query property to the given value.
12693 pub fn fetch_bodies(mut self, new_value: bool) -> PostSearchCall<'a, C> {
12694 self._fetch_bodies = Some(new_value);
12695 self
12696 }
12697 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12698 /// while executing the actual API request.
12699 ///
12700 /// ````text
12701 /// It should be used to handle progress information, and to implement a certain level of resilience.
12702 /// ````
12703 ///
12704 /// Sets the *delegate* property to the given value.
12705 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostSearchCall<'a, C> {
12706 self._delegate = Some(new_value);
12707 self
12708 }
12709
12710 /// Set any additional parameter of the query string used in the request.
12711 /// It should be used to set parameters which are not yet available through their own
12712 /// setters.
12713 ///
12714 /// Please note that this method must not be used to set any of the known parameters
12715 /// which have their own setter method. If done anyway, the request will fail.
12716 ///
12717 /// # Additional Parameters
12718 ///
12719 /// * *$.xgafv* (query-string) - V1 error format.
12720 /// * *access_token* (query-string) - OAuth access token.
12721 /// * *alt* (query-string) - Data format for response.
12722 /// * *callback* (query-string) - JSONP
12723 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12724 /// * *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.
12725 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12726 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12727 /// * *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.
12728 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12729 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12730 pub fn param<T>(mut self, name: T, value: T) -> PostSearchCall<'a, C>
12731 where
12732 T: AsRef<str>,
12733 {
12734 self._additional_params
12735 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12736 self
12737 }
12738
12739 /// Identifies the authorization scope for the method you are building.
12740 ///
12741 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12742 /// [`Scope::Readonly`].
12743 ///
12744 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12745 /// tokens for more than one scope.
12746 ///
12747 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12748 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12749 /// sufficient, a read-write scope will do as well.
12750 pub fn add_scope<St>(mut self, scope: St) -> PostSearchCall<'a, C>
12751 where
12752 St: AsRef<str>,
12753 {
12754 self._scopes.insert(String::from(scope.as_ref()));
12755 self
12756 }
12757 /// Identifies the authorization scope(s) for the method you are building.
12758 ///
12759 /// See [`Self::add_scope()`] for details.
12760 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostSearchCall<'a, C>
12761 where
12762 I: IntoIterator<Item = St>,
12763 St: AsRef<str>,
12764 {
12765 self._scopes
12766 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12767 self
12768 }
12769
12770 /// Removes all scopes, and no default scope will be used either.
12771 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12772 /// for details).
12773 pub fn clear_scopes(mut self) -> PostSearchCall<'a, C> {
12774 self._scopes.clear();
12775 self
12776 }
12777}
12778
12779/// Updates a post by blog id and post id.
12780///
12781/// A builder for the *update* method supported by a *post* resource.
12782/// It is not used directly, but through a [`PostMethods`] instance.
12783///
12784/// # Example
12785///
12786/// Instantiate a resource method builder
12787///
12788/// ```test_harness,no_run
12789/// # extern crate hyper;
12790/// # extern crate hyper_rustls;
12791/// # extern crate google_blogger3 as blogger3;
12792/// use blogger3::api::Post;
12793/// # async fn dox() {
12794/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12795///
12796/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12797/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12798/// # .with_native_roots()
12799/// # .unwrap()
12800/// # .https_only()
12801/// # .enable_http2()
12802/// # .build();
12803///
12804/// # let executor = hyper_util::rt::TokioExecutor::new();
12805/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12806/// # secret,
12807/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12808/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12809/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12810/// # ),
12811/// # ).build().await.unwrap();
12812///
12813/// # let client = hyper_util::client::legacy::Client::builder(
12814/// # hyper_util::rt::TokioExecutor::new()
12815/// # )
12816/// # .build(
12817/// # hyper_rustls::HttpsConnectorBuilder::new()
12818/// # .with_native_roots()
12819/// # .unwrap()
12820/// # .https_or_http()
12821/// # .enable_http2()
12822/// # .build()
12823/// # );
12824/// # let mut hub = Blogger::new(client, auth);
12825/// // As the method needs a request, you would usually fill it with the desired information
12826/// // into the respective structure. Some of the parts shown here might not be applicable !
12827/// // Values shown here are possibly random and not representative !
12828/// let mut req = Post::default();
12829///
12830/// // You can configure optional parameters by calling the respective setters at will, and
12831/// // execute the final call using `doit()`.
12832/// // Values shown here are possibly random and not representative !
12833/// let result = hub.posts().update(req, "blogId", "postId")
12834/// .revert(true)
12835/// .publish(false)
12836/// .max_comments(39)
12837/// .fetch_images(true)
12838/// .fetch_body(true)
12839/// .doit().await;
12840/// # }
12841/// ```
12842pub struct PostUpdateCall<'a, C>
12843where
12844 C: 'a,
12845{
12846 hub: &'a Blogger<C>,
12847 _request: Post,
12848 _blog_id: String,
12849 _post_id: String,
12850 _revert: Option<bool>,
12851 _publish: Option<bool>,
12852 _max_comments: Option<u32>,
12853 _fetch_images: Option<bool>,
12854 _fetch_body: Option<bool>,
12855 _delegate: Option<&'a mut dyn common::Delegate>,
12856 _additional_params: HashMap<String, String>,
12857 _scopes: BTreeSet<String>,
12858}
12859
12860impl<'a, C> common::CallBuilder for PostUpdateCall<'a, C> {}
12861
12862impl<'a, C> PostUpdateCall<'a, C>
12863where
12864 C: common::Connector,
12865{
12866 /// Perform the operation you have build so far.
12867 pub async fn doit(mut self) -> common::Result<(common::Response, Post)> {
12868 use std::borrow::Cow;
12869 use std::io::{Read, Seek};
12870
12871 use common::{url::Params, ToParts};
12872 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12873
12874 let mut dd = common::DefaultDelegate;
12875 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12876 dlg.begin(common::MethodInfo {
12877 id: "blogger.posts.update",
12878 http_method: hyper::Method::PUT,
12879 });
12880
12881 for &field in [
12882 "alt",
12883 "blogId",
12884 "postId",
12885 "revert",
12886 "publish",
12887 "maxComments",
12888 "fetchImages",
12889 "fetchBody",
12890 ]
12891 .iter()
12892 {
12893 if self._additional_params.contains_key(field) {
12894 dlg.finished(false);
12895 return Err(common::Error::FieldClash(field));
12896 }
12897 }
12898
12899 let mut params = Params::with_capacity(10 + self._additional_params.len());
12900 params.push("blogId", self._blog_id);
12901 params.push("postId", self._post_id);
12902 if let Some(value) = self._revert.as_ref() {
12903 params.push("revert", value.to_string());
12904 }
12905 if let Some(value) = self._publish.as_ref() {
12906 params.push("publish", value.to_string());
12907 }
12908 if let Some(value) = self._max_comments.as_ref() {
12909 params.push("maxComments", value.to_string());
12910 }
12911 if let Some(value) = self._fetch_images.as_ref() {
12912 params.push("fetchImages", value.to_string());
12913 }
12914 if let Some(value) = self._fetch_body.as_ref() {
12915 params.push("fetchBody", value.to_string());
12916 }
12917
12918 params.extend(self._additional_params.iter());
12919
12920 params.push("alt", "json");
12921 let mut url = self.hub._base_url.clone() + "v3/blogs/{blogId}/posts/{postId}";
12922 if self._scopes.is_empty() {
12923 self._scopes.insert(Scope::Full.as_ref().to_string());
12924 }
12925
12926 #[allow(clippy::single_element_loop)]
12927 for &(find_this, param_name) in [("{blogId}", "blogId"), ("{postId}", "postId")].iter() {
12928 url = params.uri_replacement(url, param_name, find_this, false);
12929 }
12930 {
12931 let to_remove = ["postId", "blogId"];
12932 params.remove_params(&to_remove);
12933 }
12934
12935 let url = params.parse_with_url(&url);
12936
12937 let mut json_mime_type = mime::APPLICATION_JSON;
12938 let mut request_value_reader = {
12939 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12940 common::remove_json_null_values(&mut value);
12941 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12942 serde_json::to_writer(&mut dst, &value).unwrap();
12943 dst
12944 };
12945 let request_size = request_value_reader
12946 .seek(std::io::SeekFrom::End(0))
12947 .unwrap();
12948 request_value_reader
12949 .seek(std::io::SeekFrom::Start(0))
12950 .unwrap();
12951
12952 loop {
12953 let token = match self
12954 .hub
12955 .auth
12956 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12957 .await
12958 {
12959 Ok(token) => token,
12960 Err(e) => match dlg.token(e) {
12961 Ok(token) => token,
12962 Err(e) => {
12963 dlg.finished(false);
12964 return Err(common::Error::MissingToken(e));
12965 }
12966 },
12967 };
12968 request_value_reader
12969 .seek(std::io::SeekFrom::Start(0))
12970 .unwrap();
12971 let mut req_result = {
12972 let client = &self.hub.client;
12973 dlg.pre_request();
12974 let mut req_builder = hyper::Request::builder()
12975 .method(hyper::Method::PUT)
12976 .uri(url.as_str())
12977 .header(USER_AGENT, self.hub._user_agent.clone());
12978
12979 if let Some(token) = token.as_ref() {
12980 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12981 }
12982
12983 let request = req_builder
12984 .header(CONTENT_TYPE, json_mime_type.to_string())
12985 .header(CONTENT_LENGTH, request_size as u64)
12986 .body(common::to_body(
12987 request_value_reader.get_ref().clone().into(),
12988 ));
12989
12990 client.request(request.unwrap()).await
12991 };
12992
12993 match req_result {
12994 Err(err) => {
12995 if let common::Retry::After(d) = dlg.http_error(&err) {
12996 sleep(d).await;
12997 continue;
12998 }
12999 dlg.finished(false);
13000 return Err(common::Error::HttpError(err));
13001 }
13002 Ok(res) => {
13003 let (mut parts, body) = res.into_parts();
13004 let mut body = common::Body::new(body);
13005 if !parts.status.is_success() {
13006 let bytes = common::to_bytes(body).await.unwrap_or_default();
13007 let error = serde_json::from_str(&common::to_string(&bytes));
13008 let response = common::to_response(parts, bytes.into());
13009
13010 if let common::Retry::After(d) =
13011 dlg.http_failure(&response, error.as_ref().ok())
13012 {
13013 sleep(d).await;
13014 continue;
13015 }
13016
13017 dlg.finished(false);
13018
13019 return Err(match error {
13020 Ok(value) => common::Error::BadRequest(value),
13021 _ => common::Error::Failure(response),
13022 });
13023 }
13024 let response = {
13025 let bytes = common::to_bytes(body).await.unwrap_or_default();
13026 let encoded = common::to_string(&bytes);
13027 match serde_json::from_str(&encoded) {
13028 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13029 Err(error) => {
13030 dlg.response_json_decode_error(&encoded, &error);
13031 return Err(common::Error::JsonDecodeError(
13032 encoded.to_string(),
13033 error,
13034 ));
13035 }
13036 }
13037 };
13038
13039 dlg.finished(true);
13040 return Ok(response);
13041 }
13042 }
13043 }
13044 }
13045
13046 ///
13047 /// Sets the *request* property to the given value.
13048 ///
13049 /// Even though the property as already been set when instantiating this call,
13050 /// we provide this method for API completeness.
13051 pub fn request(mut self, new_value: Post) -> PostUpdateCall<'a, C> {
13052 self._request = new_value;
13053 self
13054 }
13055 ///
13056 /// Sets the *blog id* path property to the given value.
13057 ///
13058 /// Even though the property as already been set when instantiating this call,
13059 /// we provide this method for API completeness.
13060 pub fn blog_id(mut self, new_value: &str) -> PostUpdateCall<'a, C> {
13061 self._blog_id = new_value.to_string();
13062 self
13063 }
13064 ///
13065 /// Sets the *post id* path property to the given value.
13066 ///
13067 /// Even though the property as already been set when instantiating this call,
13068 /// we provide this method for API completeness.
13069 pub fn post_id(mut self, new_value: &str) -> PostUpdateCall<'a, C> {
13070 self._post_id = new_value.to_string();
13071 self
13072 }
13073 ///
13074 /// Sets the *revert* query property to the given value.
13075 pub fn revert(mut self, new_value: bool) -> PostUpdateCall<'a, C> {
13076 self._revert = Some(new_value);
13077 self
13078 }
13079 ///
13080 /// Sets the *publish* query property to the given value.
13081 pub fn publish(mut self, new_value: bool) -> PostUpdateCall<'a, C> {
13082 self._publish = Some(new_value);
13083 self
13084 }
13085 ///
13086 /// Sets the *max comments* query property to the given value.
13087 pub fn max_comments(mut self, new_value: u32) -> PostUpdateCall<'a, C> {
13088 self._max_comments = Some(new_value);
13089 self
13090 }
13091 ///
13092 /// Sets the *fetch images* query property to the given value.
13093 pub fn fetch_images(mut self, new_value: bool) -> PostUpdateCall<'a, C> {
13094 self._fetch_images = Some(new_value);
13095 self
13096 }
13097 ///
13098 /// Sets the *fetch body* query property to the given value.
13099 pub fn fetch_body(mut self, new_value: bool) -> PostUpdateCall<'a, C> {
13100 self._fetch_body = Some(new_value);
13101 self
13102 }
13103 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13104 /// while executing the actual API request.
13105 ///
13106 /// ````text
13107 /// It should be used to handle progress information, and to implement a certain level of resilience.
13108 /// ````
13109 ///
13110 /// Sets the *delegate* property to the given value.
13111 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostUpdateCall<'a, C> {
13112 self._delegate = Some(new_value);
13113 self
13114 }
13115
13116 /// Set any additional parameter of the query string used in the request.
13117 /// It should be used to set parameters which are not yet available through their own
13118 /// setters.
13119 ///
13120 /// Please note that this method must not be used to set any of the known parameters
13121 /// which have their own setter method. If done anyway, the request will fail.
13122 ///
13123 /// # Additional Parameters
13124 ///
13125 /// * *$.xgafv* (query-string) - V1 error format.
13126 /// * *access_token* (query-string) - OAuth access token.
13127 /// * *alt* (query-string) - Data format for response.
13128 /// * *callback* (query-string) - JSONP
13129 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13130 /// * *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.
13131 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13132 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13133 /// * *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.
13134 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13135 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13136 pub fn param<T>(mut self, name: T, value: T) -> PostUpdateCall<'a, C>
13137 where
13138 T: AsRef<str>,
13139 {
13140 self._additional_params
13141 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13142 self
13143 }
13144
13145 /// Identifies the authorization scope for the method you are building.
13146 ///
13147 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13148 /// [`Scope::Full`].
13149 ///
13150 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13151 /// tokens for more than one scope.
13152 ///
13153 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13154 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13155 /// sufficient, a read-write scope will do as well.
13156 pub fn add_scope<St>(mut self, scope: St) -> PostUpdateCall<'a, C>
13157 where
13158 St: AsRef<str>,
13159 {
13160 self._scopes.insert(String::from(scope.as_ref()));
13161 self
13162 }
13163 /// Identifies the authorization scope(s) for the method you are building.
13164 ///
13165 /// See [`Self::add_scope()`] for details.
13166 pub fn add_scopes<I, St>(mut self, scopes: I) -> PostUpdateCall<'a, C>
13167 where
13168 I: IntoIterator<Item = St>,
13169 St: AsRef<str>,
13170 {
13171 self._scopes
13172 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13173 self
13174 }
13175
13176 /// Removes all scopes, and no default scope will be used either.
13177 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13178 /// for details).
13179 pub fn clear_scopes(mut self) -> PostUpdateCall<'a, C> {
13180 self._scopes.clear();
13181 self
13182 }
13183}
13184
13185/// Gets one user by user_id.
13186///
13187/// A builder for the *get* method supported by a *user* resource.
13188/// It is not used directly, but through a [`UserMethods`] instance.
13189///
13190/// # Example
13191///
13192/// Instantiate a resource method builder
13193///
13194/// ```test_harness,no_run
13195/// # extern crate hyper;
13196/// # extern crate hyper_rustls;
13197/// # extern crate google_blogger3 as blogger3;
13198/// # async fn dox() {
13199/// # use blogger3::{Blogger, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13200///
13201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13202/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13203/// # .with_native_roots()
13204/// # .unwrap()
13205/// # .https_only()
13206/// # .enable_http2()
13207/// # .build();
13208///
13209/// # let executor = hyper_util::rt::TokioExecutor::new();
13210/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13211/// # secret,
13212/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13213/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13214/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13215/// # ),
13216/// # ).build().await.unwrap();
13217///
13218/// # let client = hyper_util::client::legacy::Client::builder(
13219/// # hyper_util::rt::TokioExecutor::new()
13220/// # )
13221/// # .build(
13222/// # hyper_rustls::HttpsConnectorBuilder::new()
13223/// # .with_native_roots()
13224/// # .unwrap()
13225/// # .https_or_http()
13226/// # .enable_http2()
13227/// # .build()
13228/// # );
13229/// # let mut hub = Blogger::new(client, auth);
13230/// // You can configure optional parameters by calling the respective setters at will, and
13231/// // execute the final call using `doit()`.
13232/// // Values shown here are possibly random and not representative !
13233/// let result = hub.users().get("userId")
13234/// .doit().await;
13235/// # }
13236/// ```
13237pub struct UserGetCall<'a, C>
13238where
13239 C: 'a,
13240{
13241 hub: &'a Blogger<C>,
13242 _user_id: String,
13243 _delegate: Option<&'a mut dyn common::Delegate>,
13244 _additional_params: HashMap<String, String>,
13245 _scopes: BTreeSet<String>,
13246}
13247
13248impl<'a, C> common::CallBuilder for UserGetCall<'a, C> {}
13249
13250impl<'a, C> UserGetCall<'a, C>
13251where
13252 C: common::Connector,
13253{
13254 /// Perform the operation you have build so far.
13255 pub async fn doit(mut self) -> common::Result<(common::Response, User)> {
13256 use std::borrow::Cow;
13257 use std::io::{Read, Seek};
13258
13259 use common::{url::Params, ToParts};
13260 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13261
13262 let mut dd = common::DefaultDelegate;
13263 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13264 dlg.begin(common::MethodInfo {
13265 id: "blogger.users.get",
13266 http_method: hyper::Method::GET,
13267 });
13268
13269 for &field in ["alt", "userId"].iter() {
13270 if self._additional_params.contains_key(field) {
13271 dlg.finished(false);
13272 return Err(common::Error::FieldClash(field));
13273 }
13274 }
13275
13276 let mut params = Params::with_capacity(3 + self._additional_params.len());
13277 params.push("userId", self._user_id);
13278
13279 params.extend(self._additional_params.iter());
13280
13281 params.push("alt", "json");
13282 let mut url = self.hub._base_url.clone() + "v3/users/{userId}";
13283 if self._scopes.is_empty() {
13284 self._scopes.insert(Scope::Readonly.as_ref().to_string());
13285 }
13286
13287 #[allow(clippy::single_element_loop)]
13288 for &(find_this, param_name) in [("{userId}", "userId")].iter() {
13289 url = params.uri_replacement(url, param_name, find_this, false);
13290 }
13291 {
13292 let to_remove = ["userId"];
13293 params.remove_params(&to_remove);
13294 }
13295
13296 let url = params.parse_with_url(&url);
13297
13298 loop {
13299 let token = match self
13300 .hub
13301 .auth
13302 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13303 .await
13304 {
13305 Ok(token) => token,
13306 Err(e) => match dlg.token(e) {
13307 Ok(token) => token,
13308 Err(e) => {
13309 dlg.finished(false);
13310 return Err(common::Error::MissingToken(e));
13311 }
13312 },
13313 };
13314 let mut req_result = {
13315 let client = &self.hub.client;
13316 dlg.pre_request();
13317 let mut req_builder = hyper::Request::builder()
13318 .method(hyper::Method::GET)
13319 .uri(url.as_str())
13320 .header(USER_AGENT, self.hub._user_agent.clone());
13321
13322 if let Some(token) = token.as_ref() {
13323 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13324 }
13325
13326 let request = req_builder
13327 .header(CONTENT_LENGTH, 0_u64)
13328 .body(common::to_body::<String>(None));
13329
13330 client.request(request.unwrap()).await
13331 };
13332
13333 match req_result {
13334 Err(err) => {
13335 if let common::Retry::After(d) = dlg.http_error(&err) {
13336 sleep(d).await;
13337 continue;
13338 }
13339 dlg.finished(false);
13340 return Err(common::Error::HttpError(err));
13341 }
13342 Ok(res) => {
13343 let (mut parts, body) = res.into_parts();
13344 let mut body = common::Body::new(body);
13345 if !parts.status.is_success() {
13346 let bytes = common::to_bytes(body).await.unwrap_or_default();
13347 let error = serde_json::from_str(&common::to_string(&bytes));
13348 let response = common::to_response(parts, bytes.into());
13349
13350 if let common::Retry::After(d) =
13351 dlg.http_failure(&response, error.as_ref().ok())
13352 {
13353 sleep(d).await;
13354 continue;
13355 }
13356
13357 dlg.finished(false);
13358
13359 return Err(match error {
13360 Ok(value) => common::Error::BadRequest(value),
13361 _ => common::Error::Failure(response),
13362 });
13363 }
13364 let response = {
13365 let bytes = common::to_bytes(body).await.unwrap_or_default();
13366 let encoded = common::to_string(&bytes);
13367 match serde_json::from_str(&encoded) {
13368 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13369 Err(error) => {
13370 dlg.response_json_decode_error(&encoded, &error);
13371 return Err(common::Error::JsonDecodeError(
13372 encoded.to_string(),
13373 error,
13374 ));
13375 }
13376 }
13377 };
13378
13379 dlg.finished(true);
13380 return Ok(response);
13381 }
13382 }
13383 }
13384 }
13385
13386 ///
13387 /// Sets the *user id* path property to the given value.
13388 ///
13389 /// Even though the property as already been set when instantiating this call,
13390 /// we provide this method for API completeness.
13391 pub fn user_id(mut self, new_value: &str) -> UserGetCall<'a, C> {
13392 self._user_id = new_value.to_string();
13393 self
13394 }
13395 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13396 /// while executing the actual API request.
13397 ///
13398 /// ````text
13399 /// It should be used to handle progress information, and to implement a certain level of resilience.
13400 /// ````
13401 ///
13402 /// Sets the *delegate* property to the given value.
13403 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserGetCall<'a, C> {
13404 self._delegate = Some(new_value);
13405 self
13406 }
13407
13408 /// Set any additional parameter of the query string used in the request.
13409 /// It should be used to set parameters which are not yet available through their own
13410 /// setters.
13411 ///
13412 /// Please note that this method must not be used to set any of the known parameters
13413 /// which have their own setter method. If done anyway, the request will fail.
13414 ///
13415 /// # Additional Parameters
13416 ///
13417 /// * *$.xgafv* (query-string) - V1 error format.
13418 /// * *access_token* (query-string) - OAuth access token.
13419 /// * *alt* (query-string) - Data format for response.
13420 /// * *callback* (query-string) - JSONP
13421 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13422 /// * *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.
13423 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13424 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13425 /// * *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.
13426 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13427 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13428 pub fn param<T>(mut self, name: T, value: T) -> UserGetCall<'a, C>
13429 where
13430 T: AsRef<str>,
13431 {
13432 self._additional_params
13433 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13434 self
13435 }
13436
13437 /// Identifies the authorization scope for the method you are building.
13438 ///
13439 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13440 /// [`Scope::Readonly`].
13441 ///
13442 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13443 /// tokens for more than one scope.
13444 ///
13445 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13446 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13447 /// sufficient, a read-write scope will do as well.
13448 pub fn add_scope<St>(mut self, scope: St) -> UserGetCall<'a, C>
13449 where
13450 St: AsRef<str>,
13451 {
13452 self._scopes.insert(String::from(scope.as_ref()));
13453 self
13454 }
13455 /// Identifies the authorization scope(s) for the method you are building.
13456 ///
13457 /// See [`Self::add_scope()`] for details.
13458 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserGetCall<'a, C>
13459 where
13460 I: IntoIterator<Item = St>,
13461 St: AsRef<str>,
13462 {
13463 self._scopes
13464 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13465 self
13466 }
13467
13468 /// Removes all scopes, and no default scope will be used either.
13469 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13470 /// for details).
13471 pub fn clear_scopes(mut self) -> UserGetCall<'a, C> {
13472 self._scopes.clear();
13473 self
13474 }
13475}