google_groupssettings1/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 /// View and manage the settings of a G Suite group
17 AppGroupSetting,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::AppGroupSetting => "https://www.googleapis.com/auth/apps.groups.settings",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::AppGroupSetting
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all Groupssettings related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_groupssettings1 as groupssettings1;
49/// use groupssettings1::api::Groups;
50/// use groupssettings1::{Result, Error};
51/// # async fn dox() {
52/// use groupssettings1::{Groupssettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = Groupssettings::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Groups::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.groups().patch(req, "groupUniqueId")
88/// .doit().await;
89///
90/// match result {
91/// Err(e) => match e {
92/// // The Error enum provides details about what exactly happened.
93/// // You can also just use its `Debug`, `Display` or `Error` traits
94/// Error::HttpError(_)
95/// |Error::Io(_)
96/// |Error::MissingAPIKey
97/// |Error::MissingToken(_)
98/// |Error::Cancelled
99/// |Error::UploadSizeLimitExceeded(_, _)
100/// |Error::Failure(_)
101/// |Error::BadRequest(_)
102/// |Error::FieldClash(_)
103/// |Error::JsonDecodeError(_, _) => println!("{}", e),
104/// },
105/// Ok(res) => println!("Success: {:?}", res),
106/// }
107/// # }
108/// ```
109#[derive(Clone)]
110pub struct Groupssettings<C> {
111 pub client: common::Client<C>,
112 pub auth: Box<dyn common::GetToken>,
113 _user_agent: String,
114 _base_url: String,
115 _root_url: String,
116}
117
118impl<C> common::Hub for Groupssettings<C> {}
119
120impl<'a, C> Groupssettings<C> {
121 pub fn new<A: 'static + common::GetToken>(
122 client: common::Client<C>,
123 auth: A,
124 ) -> Groupssettings<C> {
125 Groupssettings {
126 client,
127 auth: Box::new(auth),
128 _user_agent: "google-api-rust-client/6.0.0".to_string(),
129 _base_url: "https://www.googleapis.com/groups/v1/groups/".to_string(),
130 _root_url: "https://www.googleapis.com/".to_string(),
131 }
132 }
133
134 pub fn groups(&'a self) -> GroupMethods<'a, C> {
135 GroupMethods { hub: self }
136 }
137
138 /// Set the user-agent header field to use in all requests to the server.
139 /// It defaults to `google-api-rust-client/6.0.0`.
140 ///
141 /// Returns the previously set user-agent.
142 pub fn user_agent(&mut self, agent_name: String) -> String {
143 std::mem::replace(&mut self._user_agent, agent_name)
144 }
145
146 /// Set the base url to use in all requests to the server.
147 /// It defaults to `https://www.googleapis.com/groups/v1/groups/`.
148 ///
149 /// Returns the previously set base url.
150 pub fn base_url(&mut self, new_base_url: String) -> String {
151 std::mem::replace(&mut self._base_url, new_base_url)
152 }
153
154 /// Set the root url to use in all requests to the server.
155 /// It defaults to `https://www.googleapis.com/`.
156 ///
157 /// Returns the previously set root url.
158 pub fn root_url(&mut self, new_root_url: String) -> String {
159 std::mem::replace(&mut self._root_url, new_root_url)
160 }
161}
162
163// ############
164// SCHEMAS ###
165// ##########
166/// JSON template for Group resource
167///
168/// # Activities
169///
170/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
171/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
172///
173/// * [get groups](GroupGetCall) (response)
174/// * [patch groups](GroupPatchCall) (request|response)
175/// * [update groups](GroupUpdateCall) (request|response)
176#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
177#[serde_with::serde_as]
178#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
179pub struct Groups {
180 /// Identifies whether members external to your organization can join the group. Possible values are:
181 /// - true: G Suite users external to your organization can become members of this group.
182 /// - false: Users not belonging to the organization are not allowed to become members of this group.
183 #[serde(rename = "allowExternalMembers")]
184 pub allow_external_members: Option<String>,
185 /// Deprecated. Allows Google to contact administrator of the group.
186 /// - true: Allow Google to contact managers of this group. Occasionally Google may send updates on the latest features, ask for input on new features, or ask for permission to highlight your group.
187 /// - false: Google can not contact managers of this group.
188 #[serde(rename = "allowGoogleCommunication")]
189 pub allow_google_communication: Option<String>,
190 /// Allows posting from web. Possible values are:
191 /// - true: Allows any member to post to the group forum.
192 /// - false: Members only use Gmail to communicate with the group.
193 #[serde(rename = "allowWebPosting")]
194 pub allow_web_posting: Option<String>,
195 /// Allows the group to be archived only. Possible values are:
196 /// - true: Group is archived and the group is inactive. New messages to this group are rejected. The older archived messages are browseable and searchable.
197 /// - If true, the whoCanPostMessage property is set to NONE_CAN_POST.
198 /// - If reverted from true to false, whoCanPostMessages is set to ALL_MANAGERS_CAN_POST.
199 /// - false: The group is active and can receive messages.
200 /// - When false, updating whoCanPostMessage to NONE_CAN_POST, results in an error.
201 #[serde(rename = "archiveOnly")]
202 pub archive_only: Option<String>,
203 /// Set the content of custom footer text. The maximum number of characters is 1,000.
204 #[serde(rename = "customFooterText")]
205 pub custom_footer_text: Option<String>,
206 /// An email address used when replying to a message if the replyTo property is set to REPLY_TO_CUSTOM. This address is defined by an account administrator.
207 /// - When the group's ReplyTo property is set to REPLY_TO_CUSTOM, the customReplyTo property holds a custom email address used when replying to a message.
208 /// - If the group's ReplyTo property is set to REPLY_TO_CUSTOM, the customReplyTo property must have a text value or an error is returned.
209 #[serde(rename = "customReplyTo")]
210 pub custom_reply_to: Option<String>,
211 /// Specifies whether the group has a custom role that's included in one of the settings being merged. This field is read-only and update/patch requests to it are ignored. Possible values are:
212 /// - true
213 /// - false
214 #[serde(rename = "customRolesEnabledForSettingsToBeMerged")]
215 pub custom_roles_enabled_for_settings_to_be_merged: Option<String>,
216 /// When a message is rejected, this is text for the rejection notification sent to the message's author. By default, this property is empty and has no value in the API's response body. The maximum notification text size is 10,000 characters. Note: Requires sendMessageDenyNotification property to be true.
217 #[serde(rename = "defaultMessageDenyNotificationText")]
218 pub default_message_deny_notification_text: Option<String>,
219 /// Default sender for members who can post messages as the group. Possible values are: - `DEFAULT_SELF`: By default messages will be sent from the user - `GROUP`: By default messages will be sent from the group
220 pub default_sender: Option<String>,
221 /// Description of the group. This property value may be an empty string if no group description has been entered. If entered, the maximum group description is no more than 300 characters.
222 pub description: Option<String>,
223 /// The group's email address. This property can be updated using the Directory API. Note: Only a group owner can change a group's email address. A group manager can't do this.
224 /// When you change your group's address using the Directory API or the control panel, you are changing the address your subscribers use to send email and the web address people use to access your group. People can't reach your group by visiting the old address.
225 pub email: Option<String>,
226 /// Specifies whether a collaborative inbox will remain turned on for the group. Possible values are:
227 /// - true
228 /// - false
229 #[serde(rename = "enableCollaborativeInbox")]
230 pub enable_collaborative_inbox: Option<String>,
231 /// Indicates if favorite replies should be displayed above other replies.
232 /// - true: Favorite replies will be displayed above other replies.
233 /// - false: Favorite replies will not be displayed above other replies.
234 #[serde(rename = "favoriteRepliesOnTop")]
235 pub favorite_replies_on_top: Option<String>,
236 /// Whether to include custom footer. Possible values are:
237 /// - true
238 /// - false
239 #[serde(rename = "includeCustomFooter")]
240 pub include_custom_footer: Option<String>,
241 /// Enables the group to be included in the Global Address List. For more information, see the help center. Possible values are:
242 /// - true: Group is included in the Global Address List.
243 /// - false: Group is not included in the Global Address List.
244 #[serde(rename = "includeInGlobalAddressList")]
245 pub include_in_global_address_list: Option<String>,
246 /// Allows the Group contents to be archived. Possible values are:
247 /// - true: Archive messages sent to the group.
248 /// - false: Do not keep an archive of messages sent to this group. If false, previously archived messages remain in the archive.
249 #[serde(rename = "isArchived")]
250 pub is_archived: Option<String>,
251 /// The type of the resource. It is always groupsSettings#groups.
252 pub kind: Option<String>,
253 /// Deprecated. The maximum size of a message is 25Mb.
254 #[serde(rename = "maxMessageBytes")]
255 pub max_message_bytes: Option<i32>,
256 /// Enables members to post messages as the group. Possible values are:
257 /// - true: Group member can post messages using the group's email address instead of their own email address. Message appear to originate from the group itself. Note: When true, any message moderation settings on individual users or new members do not apply to posts made on behalf of the group.
258 /// - false: Members can not post in behalf of the group's email address.
259 #[serde(rename = "membersCanPostAsTheGroup")]
260 pub members_can_post_as_the_group: Option<String>,
261 /// Deprecated. The default message display font always has a value of "DEFAULT_FONT".
262 #[serde(rename = "messageDisplayFont")]
263 pub message_display_font: Option<String>,
264 /// Moderation level of incoming messages. Possible values are:
265 /// - MODERATE_ALL_MESSAGES: All messages are sent to the group owner's email address for approval. If approved, the message is sent to the group.
266 /// - MODERATE_NON_MEMBERS: All messages from non group members are sent to the group owner's email address for approval. If approved, the message is sent to the group.
267 /// - MODERATE_NEW_MEMBERS: All messages from new members are sent to the group owner's email address for approval. If approved, the message is sent to the group.
268 /// - MODERATE_NONE: No moderator approval is required. Messages are delivered directly to the group. Note: When the whoCanPostMessage is set to ANYONE_CAN_POST, we recommend the messageModerationLevel be set to MODERATE_NON_MEMBERS to protect the group from possible spam.
269 /// When memberCanPostAsTheGroup is true, any message moderation settings on individual users or new members will not apply to posts made on behalf of the group.
270 #[serde(rename = "messageModerationLevel")]
271 pub message_moderation_level: Option<String>,
272 /// Name of the group, which has a maximum size of 75 characters.
273 pub name: Option<String>,
274 /// The primary language for group. For a group's primary language use the language tags from the G Suite languages found at G Suite Email Settings API Email Language Tags.
275 #[serde(rename = "primaryLanguage")]
276 pub primary_language: Option<String>,
277 /// Specifies who receives the default reply. Possible values are:
278 /// - REPLY_TO_CUSTOM: For replies to messages, use the group's custom email address.
279 /// When the group's ReplyTo property is set to REPLY_TO_CUSTOM, the customReplyTo property holds the custom email address used when replying to a message. If the group's ReplyTo property is set to REPLY_TO_CUSTOM, the customReplyTo property must have a value. Otherwise an error is returned.
280 ///
281 /// - REPLY_TO_SENDER: The reply sent to author of message.
282 /// - REPLY_TO_LIST: This reply message is sent to the group.
283 /// - REPLY_TO_OWNER: The reply is sent to the owner(s) of the group. This does not include the group's managers.
284 /// - REPLY_TO_IGNORE: Group users individually decide where the message reply is sent.
285 /// - REPLY_TO_MANAGERS: This reply message is sent to the group's managers, which includes all managers and the group owner.
286 #[serde(rename = "replyTo")]
287 pub reply_to: Option<String>,
288 /// Allows a member to be notified if the member's message to the group is denied by the group owner. Possible values are:
289 /// - true: When a message is rejected, send the deny message notification to the message author.
290 /// The defaultMessageDenyNotificationText property is dependent on the sendMessageDenyNotification property being true.
291 ///
292 /// - false: When a message is rejected, no notification is sent.
293 #[serde(rename = "sendMessageDenyNotification")]
294 pub send_message_deny_notification: Option<String>,
295 /// Deprecated. This is merged into the new whoCanDiscoverGroup setting. Allows the group to be visible in the Groups Directory. Possible values are:
296 /// - true: All groups in the account are listed in the Groups directory.
297 /// - false: All groups in the account are not listed in the directory.
298 #[serde(rename = "showInGroupDirectory")]
299 pub show_in_group_directory: Option<String>,
300 /// Specifies moderation levels for messages detected as spam. Possible values are:
301 /// - ALLOW: Post the message to the group.
302 /// - MODERATE: Send the message to the moderation queue. This is the default.
303 /// - SILENTLY_MODERATE: Send the message to the moderation queue, but do not send notification to moderators.
304 /// - REJECT: Immediately reject the message.
305 #[serde(rename = "spamModerationLevel")]
306 pub spam_moderation_level: Option<String>,
307 /// Deprecated. This is merged into the new whoCanModerateMembers setting. Permissions to add members. Possible values are:
308 /// - ALL_MEMBERS_CAN_ADD: Managers and members can directly add new members.
309 /// - ALL_MANAGERS_CAN_ADD: Only managers can directly add new members. this includes the group's owner.
310 /// - ALL_OWNERS_CAN_ADD: Only owners can directly add new members.
311 /// - NONE_CAN_ADD: No one can directly add new members.
312 #[serde(rename = "whoCanAdd")]
313 pub who_can_add: Option<String>,
314 /// Deprecated. This functionality is no longer supported in the Google Groups UI. The value is always "NONE".
315 #[serde(rename = "whoCanAddReferences")]
316 pub who_can_add_references: Option<String>,
317 /// Specifies who can approve members who ask to join groups. This permission will be deprecated once it is merged into the new whoCanModerateMembers setting. Possible values are:
318 /// - ALL_MEMBERS_CAN_APPROVE
319 /// - ALL_MANAGERS_CAN_APPROVE
320 /// - ALL_OWNERS_CAN_APPROVE
321 /// - NONE_CAN_APPROVE
322 #[serde(rename = "whoCanApproveMembers")]
323 pub who_can_approve_members: Option<String>,
324 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can approve pending messages in the moderation queue. Possible values are:
325 /// - ALL_MEMBERS
326 /// - OWNERS_AND_MANAGERS
327 /// - OWNERS_ONLY
328 /// - NONE
329 #[serde(rename = "whoCanApproveMessages")]
330 pub who_can_approve_messages: Option<String>,
331 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to assign topics in a forum to another user. Possible values are:
332 /// - ALL_MEMBERS
333 /// - OWNERS_AND_MANAGERS
334 /// - MANAGERS_ONLY
335 /// - OWNERS_ONLY
336 /// - NONE
337 #[serde(rename = "whoCanAssignTopics")]
338 pub who_can_assign_topics: Option<String>,
339 /// Specifies who can moderate metadata. Possible values are:
340 /// - ALL_MEMBERS
341 /// - OWNERS_AND_MANAGERS
342 /// - MANAGERS_ONLY
343 /// - OWNERS_ONLY
344 /// - NONE
345 #[serde(rename = "whoCanAssistContent")]
346 pub who_can_assist_content: Option<String>,
347 /// Specifies who can deny membership to users. This permission will be deprecated once it is merged into the new whoCanModerateMembers setting. Possible values are:
348 /// - ALL_MEMBERS
349 /// - OWNERS_AND_MANAGERS
350 /// - OWNERS_ONLY
351 /// - NONE
352 #[serde(rename = "whoCanBanUsers")]
353 pub who_can_ban_users: Option<String>,
354 /// Permission to contact owner of the group via web UI. Possible values are:
355 /// - ALL_IN_DOMAIN_CAN_CONTACT
356 /// - ALL_MANAGERS_CAN_CONTACT
357 /// - ALL_MEMBERS_CAN_CONTACT
358 /// - ANYONE_CAN_CONTACT
359 /// - ALL_OWNERS_CAN_CONTACT
360 #[serde(rename = "whoCanContactOwner")]
361 pub who_can_contact_owner: Option<String>,
362 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can delete replies to topics. (Authors can always delete their own posts). Possible values are:
363 /// - ALL_MEMBERS
364 /// - OWNERS_AND_MANAGERS
365 /// - OWNERS_ONLY
366 /// - NONE
367 #[serde(rename = "whoCanDeleteAnyPost")]
368 pub who_can_delete_any_post: Option<String>,
369 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can delete topics. Possible values are:
370 /// - ALL_MEMBERS
371 /// - OWNERS_AND_MANAGERS
372 /// - OWNERS_ONLY
373 /// - NONE
374 #[serde(rename = "whoCanDeleteTopics")]
375 pub who_can_delete_topics: Option<String>,
376 /// Specifies the set of users for whom this group is discoverable. Possible values are:
377 /// - ANYONE_CAN_DISCOVER
378 /// - ALL_IN_DOMAIN_CAN_DISCOVER
379 /// - ALL_MEMBERS_CAN_DISCOVER
380 #[serde(rename = "whoCanDiscoverGroup")]
381 pub who_can_discover_group: Option<String>,
382 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to enter free form tags for topics in a forum. Possible values are:
383 /// - ALL_MEMBERS
384 /// - OWNERS_AND_MANAGERS
385 /// - MANAGERS_ONLY
386 /// - OWNERS_ONLY
387 /// - NONE
388 #[serde(rename = "whoCanEnterFreeFormTags")]
389 pub who_can_enter_free_form_tags: Option<String>,
390 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can hide posts by reporting them as abuse. Possible values are:
391 /// - ALL_MEMBERS
392 /// - OWNERS_AND_MANAGERS
393 /// - OWNERS_ONLY
394 /// - NONE
395 #[serde(rename = "whoCanHideAbuse")]
396 pub who_can_hide_abuse: Option<String>,
397 /// Deprecated. This is merged into the new whoCanModerateMembers setting. Permissions to invite new members. Possible values are:
398 /// - ALL_MEMBERS_CAN_INVITE: Managers and members can invite a new member candidate.
399 /// - ALL_MANAGERS_CAN_INVITE: Only managers can invite a new member. This includes the group's owner.
400 /// - ALL_OWNERS_CAN_INVITE: Only owners can invite a new member.
401 /// - NONE_CAN_INVITE: No one can invite a new member candidate.
402 #[serde(rename = "whoCanInvite")]
403 pub who_can_invite: Option<String>,
404 /// Permission to join group. Possible values are:
405 /// - ANYONE_CAN_JOIN: Any Internet user who is outside your domain can access your Google Groups service and view the list of groups in your Groups directory. Warning: Group owners can add external addresses, outside of the domain to their groups. They can also allow people outside your domain to join their groups. If you later disable this option, any external addresses already added to users' groups remain in those groups.
406 /// - ALL_IN_DOMAIN_CAN_JOIN: Anyone in the account domain can join. This includes accounts with multiple domains.
407 /// - INVITED_CAN_JOIN: Candidates for membership can be invited to join.
408 /// - CAN_REQUEST_TO_JOIN: Non members can request an invitation to join.
409 #[serde(rename = "whoCanJoin")]
410 pub who_can_join: Option<String>,
411 /// Permission to leave the group. Possible values are:
412 /// - ALL_MANAGERS_CAN_LEAVE
413 /// - ALL_MEMBERS_CAN_LEAVE
414 /// - NONE_CAN_LEAVE
415 #[serde(rename = "whoCanLeaveGroup")]
416 pub who_can_leave_group: Option<String>,
417 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can prevent users from posting replies to topics. Possible values are:
418 /// - ALL_MEMBERS
419 /// - OWNERS_AND_MANAGERS
420 /// - OWNERS_ONLY
421 /// - NONE
422 #[serde(rename = "whoCanLockTopics")]
423 pub who_can_lock_topics: Option<String>,
424 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can make topics appear at the top of the topic list. Possible values are:
425 /// - ALL_MEMBERS
426 /// - OWNERS_AND_MANAGERS
427 /// - OWNERS_ONLY
428 /// - NONE
429 #[serde(rename = "whoCanMakeTopicsSticky")]
430 pub who_can_make_topics_sticky: Option<String>,
431 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to mark a topic as a duplicate of another topic. Possible values are:
432 /// - ALL_MEMBERS
433 /// - OWNERS_AND_MANAGERS
434 /// - MANAGERS_ONLY
435 /// - OWNERS_ONLY
436 /// - NONE
437 #[serde(rename = "whoCanMarkDuplicate")]
438 pub who_can_mark_duplicate: Option<String>,
439 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to mark any other user's post as a favorite reply. Possible values are:
440 /// - ALL_MEMBERS
441 /// - OWNERS_AND_MANAGERS
442 /// - MANAGERS_ONLY
443 /// - OWNERS_ONLY
444 /// - NONE
445 #[serde(rename = "whoCanMarkFavoriteReplyOnAnyTopic")]
446 pub who_can_mark_favorite_reply_on_any_topic: Option<String>,
447 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to mark a post for a topic they started as a favorite reply. Possible values are:
448 /// - ALL_MEMBERS
449 /// - OWNERS_AND_MANAGERS
450 /// - MANAGERS_ONLY
451 /// - OWNERS_ONLY
452 /// - NONE
453 #[serde(rename = "whoCanMarkFavoriteReplyOnOwnTopic")]
454 pub who_can_mark_favorite_reply_on_own_topic: Option<String>,
455 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to mark a topic as not needing a response. Possible values are:
456 /// - ALL_MEMBERS
457 /// - OWNERS_AND_MANAGERS
458 /// - MANAGERS_ONLY
459 /// - OWNERS_ONLY
460 /// - NONE
461 #[serde(rename = "whoCanMarkNoResponseNeeded")]
462 pub who_can_mark_no_response_needed: Option<String>,
463 /// Specifies who can moderate content. Possible values are:
464 /// - ALL_MEMBERS
465 /// - OWNERS_AND_MANAGERS
466 /// - OWNERS_ONLY
467 /// - NONE
468 #[serde(rename = "whoCanModerateContent")]
469 pub who_can_moderate_content: Option<String>,
470 /// Specifies who can manage members. Possible values are:
471 /// - ALL_MEMBERS
472 /// - OWNERS_AND_MANAGERS
473 /// - OWNERS_ONLY
474 /// - NONE
475 #[serde(rename = "whoCanModerateMembers")]
476 pub who_can_moderate_members: Option<String>,
477 /// Deprecated. This is merged into the new whoCanModerateMembers setting. Specifies who can change group members' roles. Possible values are:
478 /// - ALL_MEMBERS
479 /// - OWNERS_AND_MANAGERS
480 /// - OWNERS_ONLY
481 /// - NONE
482 #[serde(rename = "whoCanModifyMembers")]
483 pub who_can_modify_members: Option<String>,
484 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to change tags and categories. Possible values are:
485 /// - ALL_MEMBERS
486 /// - OWNERS_AND_MANAGERS
487 /// - MANAGERS_ONLY
488 /// - OWNERS_ONLY
489 /// - NONE
490 #[serde(rename = "whoCanModifyTagsAndCategories")]
491 pub who_can_modify_tags_and_categories: Option<String>,
492 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can move topics into the group or forum. Possible values are:
493 /// - ALL_MEMBERS
494 /// - OWNERS_AND_MANAGERS
495 /// - OWNERS_ONLY
496 /// - NONE
497 #[serde(rename = "whoCanMoveTopicsIn")]
498 pub who_can_move_topics_in: Option<String>,
499 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can move topics out of the group or forum. Possible values are:
500 /// - ALL_MEMBERS
501 /// - OWNERS_AND_MANAGERS
502 /// - OWNERS_ONLY
503 /// - NONE
504 #[serde(rename = "whoCanMoveTopicsOut")]
505 pub who_can_move_topics_out: Option<String>,
506 /// Deprecated. This is merged into the new whoCanModerateContent setting. Specifies who can post announcements, a special topic type. Possible values are:
507 /// - ALL_MEMBERS
508 /// - OWNERS_AND_MANAGERS
509 /// - OWNERS_ONLY
510 /// - NONE
511 #[serde(rename = "whoCanPostAnnouncements")]
512 pub who_can_post_announcements: Option<String>,
513 /// Permissions to post messages. Possible values are:
514 /// - NONE_CAN_POST: The group is disabled and archived. No one can post a message to this group.
515 /// - When archiveOnly is false, updating whoCanPostMessage to NONE_CAN_POST, results in an error.
516 /// - If archiveOnly is reverted from true to false, whoCanPostMessages is set to ALL_MANAGERS_CAN_POST.
517 /// - ALL_MANAGERS_CAN_POST: Managers, including group owners, can post messages.
518 /// - ALL_MEMBERS_CAN_POST: Any group member can post a message.
519 /// - ALL_OWNERS_CAN_POST: Only group owners can post a message.
520 /// - ALL_IN_DOMAIN_CAN_POST: Anyone in the account can post a message.
521 /// - ANYONE_CAN_POST: Any Internet user who outside your account can access your Google Groups service and post a message. Note: When whoCanPostMessage is set to ANYONE_CAN_POST, we recommend the messageModerationLevel be set to MODERATE_NON_MEMBERS to protect the group from possible spam.
522 #[serde(rename = "whoCanPostMessage")]
523 pub who_can_post_message: Option<String>,
524 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to take topics in a forum. Possible values are:
525 /// - ALL_MEMBERS
526 /// - OWNERS_AND_MANAGERS
527 /// - MANAGERS_ONLY
528 /// - OWNERS_ONLY
529 /// - NONE
530 #[serde(rename = "whoCanTakeTopics")]
531 pub who_can_take_topics: Option<String>,
532 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to unassign any topic in a forum. Possible values are:
533 /// - ALL_MEMBERS
534 /// - OWNERS_AND_MANAGERS
535 /// - MANAGERS_ONLY
536 /// - OWNERS_ONLY
537 /// - NONE
538 #[serde(rename = "whoCanUnassignTopic")]
539 pub who_can_unassign_topic: Option<String>,
540 /// Deprecated. This is merged into the new whoCanAssistContent setting. Permission to unmark any post from a favorite reply. Possible values are:
541 /// - ALL_MEMBERS
542 /// - OWNERS_AND_MANAGERS
543 /// - MANAGERS_ONLY
544 /// - OWNERS_ONLY
545 /// - NONE
546 #[serde(rename = "whoCanUnmarkFavoriteReplyOnAnyTopic")]
547 pub who_can_unmark_favorite_reply_on_any_topic: Option<String>,
548 /// Permissions to view group messages. Possible values are:
549 /// - ANYONE_CAN_VIEW: Any Internet user can view the group's messages.
550 /// - ALL_IN_DOMAIN_CAN_VIEW: Anyone in your account can view this group's messages.
551 /// - ALL_MEMBERS_CAN_VIEW: All group members can view the group's messages.
552 /// - ALL_MANAGERS_CAN_VIEW: Any group manager can view this group's messages.
553 #[serde(rename = "whoCanViewGroup")]
554 pub who_can_view_group: Option<String>,
555 /// Permissions to view membership. Possible values are:
556 /// - ALL_IN_DOMAIN_CAN_VIEW: Anyone in the account can view the group members list.
557 /// If a group already has external members, those members can still send email to this group.
558 ///
559 /// - ALL_MEMBERS_CAN_VIEW: The group members can view the group members list.
560 /// - ALL_MANAGERS_CAN_VIEW: The group managers can view group members list.
561 #[serde(rename = "whoCanViewMembership")]
562 pub who_can_view_membership: Option<String>,
563}
564
565impl common::RequestValue for Groups {}
566impl common::ResponseResult for Groups {}
567
568// ###################
569// MethodBuilders ###
570// #################
571
572/// A builder providing access to all methods supported on *group* resources.
573/// It is not used directly, but through the [`Groupssettings`] hub.
574///
575/// # Example
576///
577/// Instantiate a resource builder
578///
579/// ```test_harness,no_run
580/// extern crate hyper;
581/// extern crate hyper_rustls;
582/// extern crate google_groupssettings1 as groupssettings1;
583///
584/// # async fn dox() {
585/// use groupssettings1::{Groupssettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
586///
587/// let secret: yup_oauth2::ApplicationSecret = Default::default();
588/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
589/// secret,
590/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
591/// ).build().await.unwrap();
592///
593/// let client = hyper_util::client::legacy::Client::builder(
594/// hyper_util::rt::TokioExecutor::new()
595/// )
596/// .build(
597/// hyper_rustls::HttpsConnectorBuilder::new()
598/// .with_native_roots()
599/// .unwrap()
600/// .https_or_http()
601/// .enable_http1()
602/// .build()
603/// );
604/// let mut hub = Groupssettings::new(client, auth);
605/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
606/// // like `get(...)`, `patch(...)` and `update(...)`
607/// // to build up your call.
608/// let rb = hub.groups();
609/// # }
610/// ```
611pub struct GroupMethods<'a, C>
612where
613 C: 'a,
614{
615 hub: &'a Groupssettings<C>,
616}
617
618impl<'a, C> common::MethodsBuilder for GroupMethods<'a, C> {}
619
620impl<'a, C> GroupMethods<'a, C> {
621 /// Create a builder to help you perform the following task:
622 ///
623 /// Gets one resource by id.
624 ///
625 /// # Arguments
626 ///
627 /// * `groupUniqueId` - The group's email address.
628 pub fn get(&self, group_unique_id: &str) -> GroupGetCall<'a, C> {
629 GroupGetCall {
630 hub: self.hub,
631 _group_unique_id: group_unique_id.to_string(),
632 _delegate: Default::default(),
633 _additional_params: Default::default(),
634 _scopes: Default::default(),
635 }
636 }
637
638 /// Create a builder to help you perform the following task:
639 ///
640 /// Updates an existing resource. This method supports patch semantics.
641 ///
642 /// # Arguments
643 ///
644 /// * `request` - No description provided.
645 /// * `groupUniqueId` - The group's email address.
646 pub fn patch(&self, request: Groups, group_unique_id: &str) -> GroupPatchCall<'a, C> {
647 GroupPatchCall {
648 hub: self.hub,
649 _request: request,
650 _group_unique_id: group_unique_id.to_string(),
651 _delegate: Default::default(),
652 _additional_params: Default::default(),
653 _scopes: Default::default(),
654 }
655 }
656
657 /// Create a builder to help you perform the following task:
658 ///
659 /// Updates an existing resource.
660 ///
661 /// # Arguments
662 ///
663 /// * `request` - No description provided.
664 /// * `groupUniqueId` - The group's email address.
665 pub fn update(&self, request: Groups, group_unique_id: &str) -> GroupUpdateCall<'a, C> {
666 GroupUpdateCall {
667 hub: self.hub,
668 _request: request,
669 _group_unique_id: group_unique_id.to_string(),
670 _delegate: Default::default(),
671 _additional_params: Default::default(),
672 _scopes: Default::default(),
673 }
674 }
675}
676
677// ###################
678// CallBuilders ###
679// #################
680
681/// Gets one resource by id.
682///
683/// A builder for the *get* method supported by a *group* resource.
684/// It is not used directly, but through a [`GroupMethods`] instance.
685///
686/// # Example
687///
688/// Instantiate a resource method builder
689///
690/// ```test_harness,no_run
691/// # extern crate hyper;
692/// # extern crate hyper_rustls;
693/// # extern crate google_groupssettings1 as groupssettings1;
694/// # async fn dox() {
695/// # use groupssettings1::{Groupssettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
696///
697/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
698/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
699/// # secret,
700/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
701/// # ).build().await.unwrap();
702///
703/// # let client = hyper_util::client::legacy::Client::builder(
704/// # hyper_util::rt::TokioExecutor::new()
705/// # )
706/// # .build(
707/// # hyper_rustls::HttpsConnectorBuilder::new()
708/// # .with_native_roots()
709/// # .unwrap()
710/// # .https_or_http()
711/// # .enable_http1()
712/// # .build()
713/// # );
714/// # let mut hub = Groupssettings::new(client, auth);
715/// // You can configure optional parameters by calling the respective setters at will, and
716/// // execute the final call using `doit()`.
717/// // Values shown here are possibly random and not representative !
718/// let result = hub.groups().get("groupUniqueId")
719/// .doit().await;
720/// # }
721/// ```
722pub struct GroupGetCall<'a, C>
723where
724 C: 'a,
725{
726 hub: &'a Groupssettings<C>,
727 _group_unique_id: String,
728 _delegate: Option<&'a mut dyn common::Delegate>,
729 _additional_params: HashMap<String, String>,
730 _scopes: BTreeSet<String>,
731}
732
733impl<'a, C> common::CallBuilder for GroupGetCall<'a, C> {}
734
735impl<'a, C> GroupGetCall<'a, C>
736where
737 C: common::Connector,
738{
739 /// Perform the operation you have build so far.
740 pub async fn doit(mut self) -> common::Result<(common::Response, Groups)> {
741 use std::borrow::Cow;
742 use std::io::{Read, Seek};
743
744 use common::{url::Params, ToParts};
745 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
746
747 let mut dd = common::DefaultDelegate;
748 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
749 dlg.begin(common::MethodInfo {
750 id: "groupsSettings.groups.get",
751 http_method: hyper::Method::GET,
752 });
753
754 for &field in ["alt", "groupUniqueId"].iter() {
755 if self._additional_params.contains_key(field) {
756 dlg.finished(false);
757 return Err(common::Error::FieldClash(field));
758 }
759 }
760
761 let mut params = Params::with_capacity(3 + self._additional_params.len());
762 params.push("groupUniqueId", self._group_unique_id);
763
764 params.extend(self._additional_params.iter());
765
766 params.push("alt", "json");
767 let mut url = self.hub._base_url.clone() + "{groupUniqueId}";
768 if self._scopes.is_empty() {
769 self._scopes
770 .insert(Scope::AppGroupSetting.as_ref().to_string());
771 }
772
773 #[allow(clippy::single_element_loop)]
774 for &(find_this, param_name) in [("{groupUniqueId}", "groupUniqueId")].iter() {
775 url = params.uri_replacement(url, param_name, find_this, false);
776 }
777 {
778 let to_remove = ["groupUniqueId"];
779 params.remove_params(&to_remove);
780 }
781
782 let url = params.parse_with_url(&url);
783
784 loop {
785 let token = match self
786 .hub
787 .auth
788 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
789 .await
790 {
791 Ok(token) => token,
792 Err(e) => match dlg.token(e) {
793 Ok(token) => token,
794 Err(e) => {
795 dlg.finished(false);
796 return Err(common::Error::MissingToken(e));
797 }
798 },
799 };
800 let mut req_result = {
801 let client = &self.hub.client;
802 dlg.pre_request();
803 let mut req_builder = hyper::Request::builder()
804 .method(hyper::Method::GET)
805 .uri(url.as_str())
806 .header(USER_AGENT, self.hub._user_agent.clone());
807
808 if let Some(token) = token.as_ref() {
809 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
810 }
811
812 let request = req_builder
813 .header(CONTENT_LENGTH, 0_u64)
814 .body(common::to_body::<String>(None));
815
816 client.request(request.unwrap()).await
817 };
818
819 match req_result {
820 Err(err) => {
821 if let common::Retry::After(d) = dlg.http_error(&err) {
822 sleep(d).await;
823 continue;
824 }
825 dlg.finished(false);
826 return Err(common::Error::HttpError(err));
827 }
828 Ok(res) => {
829 let (mut parts, body) = res.into_parts();
830 let mut body = common::Body::new(body);
831 if !parts.status.is_success() {
832 let bytes = common::to_bytes(body).await.unwrap_or_default();
833 let error = serde_json::from_str(&common::to_string(&bytes));
834 let response = common::to_response(parts, bytes.into());
835
836 if let common::Retry::After(d) =
837 dlg.http_failure(&response, error.as_ref().ok())
838 {
839 sleep(d).await;
840 continue;
841 }
842
843 dlg.finished(false);
844
845 return Err(match error {
846 Ok(value) => common::Error::BadRequest(value),
847 _ => common::Error::Failure(response),
848 });
849 }
850 let response = {
851 let bytes = common::to_bytes(body).await.unwrap_or_default();
852 let encoded = common::to_string(&bytes);
853 match serde_json::from_str(&encoded) {
854 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
855 Err(error) => {
856 dlg.response_json_decode_error(&encoded, &error);
857 return Err(common::Error::JsonDecodeError(
858 encoded.to_string(),
859 error,
860 ));
861 }
862 }
863 };
864
865 dlg.finished(true);
866 return Ok(response);
867 }
868 }
869 }
870 }
871
872 /// The group's email address.
873 ///
874 /// Sets the *group unique id* path property to the given value.
875 ///
876 /// Even though the property as already been set when instantiating this call,
877 /// we provide this method for API completeness.
878 pub fn group_unique_id(mut self, new_value: &str) -> GroupGetCall<'a, C> {
879 self._group_unique_id = new_value.to_string();
880 self
881 }
882 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
883 /// while executing the actual API request.
884 ///
885 /// ````text
886 /// It should be used to handle progress information, and to implement a certain level of resilience.
887 /// ````
888 ///
889 /// Sets the *delegate* property to the given value.
890 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> GroupGetCall<'a, C> {
891 self._delegate = Some(new_value);
892 self
893 }
894
895 /// Set any additional parameter of the query string used in the request.
896 /// It should be used to set parameters which are not yet available through their own
897 /// setters.
898 ///
899 /// Please note that this method must not be used to set any of the known parameters
900 /// which have their own setter method. If done anyway, the request will fail.
901 ///
902 /// # Additional Parameters
903 ///
904 /// * *alt* (query-string) - Data format for the response.
905 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
906 /// * *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.
907 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
908 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
909 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
910 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
911 pub fn param<T>(mut self, name: T, value: T) -> GroupGetCall<'a, C>
912 where
913 T: AsRef<str>,
914 {
915 self._additional_params
916 .insert(name.as_ref().to_string(), value.as_ref().to_string());
917 self
918 }
919
920 /// Identifies the authorization scope for the method you are building.
921 ///
922 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
923 /// [`Scope::AppGroupSetting`].
924 ///
925 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
926 /// tokens for more than one scope.
927 ///
928 /// Usually there is more than one suitable scope to authorize an operation, some of which may
929 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
930 /// sufficient, a read-write scope will do as well.
931 pub fn add_scope<St>(mut self, scope: St) -> GroupGetCall<'a, C>
932 where
933 St: AsRef<str>,
934 {
935 self._scopes.insert(String::from(scope.as_ref()));
936 self
937 }
938 /// Identifies the authorization scope(s) for the method you are building.
939 ///
940 /// See [`Self::add_scope()`] for details.
941 pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupGetCall<'a, C>
942 where
943 I: IntoIterator<Item = St>,
944 St: AsRef<str>,
945 {
946 self._scopes
947 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
948 self
949 }
950
951 /// Removes all scopes, and no default scope will be used either.
952 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
953 /// for details).
954 pub fn clear_scopes(mut self) -> GroupGetCall<'a, C> {
955 self._scopes.clear();
956 self
957 }
958}
959
960/// Updates an existing resource. This method supports patch semantics.
961///
962/// A builder for the *patch* method supported by a *group* resource.
963/// It is not used directly, but through a [`GroupMethods`] instance.
964///
965/// # Example
966///
967/// Instantiate a resource method builder
968///
969/// ```test_harness,no_run
970/// # extern crate hyper;
971/// # extern crate hyper_rustls;
972/// # extern crate google_groupssettings1 as groupssettings1;
973/// use groupssettings1::api::Groups;
974/// # async fn dox() {
975/// # use groupssettings1::{Groupssettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
976///
977/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
978/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
979/// # secret,
980/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
981/// # ).build().await.unwrap();
982///
983/// # let client = hyper_util::client::legacy::Client::builder(
984/// # hyper_util::rt::TokioExecutor::new()
985/// # )
986/// # .build(
987/// # hyper_rustls::HttpsConnectorBuilder::new()
988/// # .with_native_roots()
989/// # .unwrap()
990/// # .https_or_http()
991/// # .enable_http1()
992/// # .build()
993/// # );
994/// # let mut hub = Groupssettings::new(client, auth);
995/// // As the method needs a request, you would usually fill it with the desired information
996/// // into the respective structure. Some of the parts shown here might not be applicable !
997/// // Values shown here are possibly random and not representative !
998/// let mut req = Groups::default();
999///
1000/// // You can configure optional parameters by calling the respective setters at will, and
1001/// // execute the final call using `doit()`.
1002/// // Values shown here are possibly random and not representative !
1003/// let result = hub.groups().patch(req, "groupUniqueId")
1004/// .doit().await;
1005/// # }
1006/// ```
1007pub struct GroupPatchCall<'a, C>
1008where
1009 C: 'a,
1010{
1011 hub: &'a Groupssettings<C>,
1012 _request: Groups,
1013 _group_unique_id: String,
1014 _delegate: Option<&'a mut dyn common::Delegate>,
1015 _additional_params: HashMap<String, String>,
1016 _scopes: BTreeSet<String>,
1017}
1018
1019impl<'a, C> common::CallBuilder for GroupPatchCall<'a, C> {}
1020
1021impl<'a, C> GroupPatchCall<'a, C>
1022where
1023 C: common::Connector,
1024{
1025 /// Perform the operation you have build so far.
1026 pub async fn doit(mut self) -> common::Result<(common::Response, Groups)> {
1027 use std::borrow::Cow;
1028 use std::io::{Read, Seek};
1029
1030 use common::{url::Params, ToParts};
1031 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1032
1033 let mut dd = common::DefaultDelegate;
1034 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1035 dlg.begin(common::MethodInfo {
1036 id: "groupsSettings.groups.patch",
1037 http_method: hyper::Method::PATCH,
1038 });
1039
1040 for &field in ["alt", "groupUniqueId"].iter() {
1041 if self._additional_params.contains_key(field) {
1042 dlg.finished(false);
1043 return Err(common::Error::FieldClash(field));
1044 }
1045 }
1046
1047 let mut params = Params::with_capacity(4 + self._additional_params.len());
1048 params.push("groupUniqueId", self._group_unique_id);
1049
1050 params.extend(self._additional_params.iter());
1051
1052 params.push("alt", "json");
1053 let mut url = self.hub._base_url.clone() + "{groupUniqueId}";
1054 if self._scopes.is_empty() {
1055 self._scopes
1056 .insert(Scope::AppGroupSetting.as_ref().to_string());
1057 }
1058
1059 #[allow(clippy::single_element_loop)]
1060 for &(find_this, param_name) in [("{groupUniqueId}", "groupUniqueId")].iter() {
1061 url = params.uri_replacement(url, param_name, find_this, false);
1062 }
1063 {
1064 let to_remove = ["groupUniqueId"];
1065 params.remove_params(&to_remove);
1066 }
1067
1068 let url = params.parse_with_url(&url);
1069
1070 let mut json_mime_type = mime::APPLICATION_JSON;
1071 let mut request_value_reader = {
1072 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1073 common::remove_json_null_values(&mut value);
1074 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1075 serde_json::to_writer(&mut dst, &value).unwrap();
1076 dst
1077 };
1078 let request_size = request_value_reader
1079 .seek(std::io::SeekFrom::End(0))
1080 .unwrap();
1081 request_value_reader
1082 .seek(std::io::SeekFrom::Start(0))
1083 .unwrap();
1084
1085 loop {
1086 let token = match self
1087 .hub
1088 .auth
1089 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1090 .await
1091 {
1092 Ok(token) => token,
1093 Err(e) => match dlg.token(e) {
1094 Ok(token) => token,
1095 Err(e) => {
1096 dlg.finished(false);
1097 return Err(common::Error::MissingToken(e));
1098 }
1099 },
1100 };
1101 request_value_reader
1102 .seek(std::io::SeekFrom::Start(0))
1103 .unwrap();
1104 let mut req_result = {
1105 let client = &self.hub.client;
1106 dlg.pre_request();
1107 let mut req_builder = hyper::Request::builder()
1108 .method(hyper::Method::PATCH)
1109 .uri(url.as_str())
1110 .header(USER_AGENT, self.hub._user_agent.clone());
1111
1112 if let Some(token) = token.as_ref() {
1113 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1114 }
1115
1116 let request = req_builder
1117 .header(CONTENT_TYPE, json_mime_type.to_string())
1118 .header(CONTENT_LENGTH, request_size as u64)
1119 .body(common::to_body(
1120 request_value_reader.get_ref().clone().into(),
1121 ));
1122
1123 client.request(request.unwrap()).await
1124 };
1125
1126 match req_result {
1127 Err(err) => {
1128 if let common::Retry::After(d) = dlg.http_error(&err) {
1129 sleep(d).await;
1130 continue;
1131 }
1132 dlg.finished(false);
1133 return Err(common::Error::HttpError(err));
1134 }
1135 Ok(res) => {
1136 let (mut parts, body) = res.into_parts();
1137 let mut body = common::Body::new(body);
1138 if !parts.status.is_success() {
1139 let bytes = common::to_bytes(body).await.unwrap_or_default();
1140 let error = serde_json::from_str(&common::to_string(&bytes));
1141 let response = common::to_response(parts, bytes.into());
1142
1143 if let common::Retry::After(d) =
1144 dlg.http_failure(&response, error.as_ref().ok())
1145 {
1146 sleep(d).await;
1147 continue;
1148 }
1149
1150 dlg.finished(false);
1151
1152 return Err(match error {
1153 Ok(value) => common::Error::BadRequest(value),
1154 _ => common::Error::Failure(response),
1155 });
1156 }
1157 let response = {
1158 let bytes = common::to_bytes(body).await.unwrap_or_default();
1159 let encoded = common::to_string(&bytes);
1160 match serde_json::from_str(&encoded) {
1161 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1162 Err(error) => {
1163 dlg.response_json_decode_error(&encoded, &error);
1164 return Err(common::Error::JsonDecodeError(
1165 encoded.to_string(),
1166 error,
1167 ));
1168 }
1169 }
1170 };
1171
1172 dlg.finished(true);
1173 return Ok(response);
1174 }
1175 }
1176 }
1177 }
1178
1179 ///
1180 /// Sets the *request* property to the given value.
1181 ///
1182 /// Even though the property as already been set when instantiating this call,
1183 /// we provide this method for API completeness.
1184 pub fn request(mut self, new_value: Groups) -> GroupPatchCall<'a, C> {
1185 self._request = new_value;
1186 self
1187 }
1188 /// The group's email address.
1189 ///
1190 /// Sets the *group unique id* path property to the given value.
1191 ///
1192 /// Even though the property as already been set when instantiating this call,
1193 /// we provide this method for API completeness.
1194 pub fn group_unique_id(mut self, new_value: &str) -> GroupPatchCall<'a, C> {
1195 self._group_unique_id = new_value.to_string();
1196 self
1197 }
1198 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1199 /// while executing the actual API request.
1200 ///
1201 /// ````text
1202 /// It should be used to handle progress information, and to implement a certain level of resilience.
1203 /// ````
1204 ///
1205 /// Sets the *delegate* property to the given value.
1206 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> GroupPatchCall<'a, C> {
1207 self._delegate = Some(new_value);
1208 self
1209 }
1210
1211 /// Set any additional parameter of the query string used in the request.
1212 /// It should be used to set parameters which are not yet available through their own
1213 /// setters.
1214 ///
1215 /// Please note that this method must not be used to set any of the known parameters
1216 /// which have their own setter method. If done anyway, the request will fail.
1217 ///
1218 /// # Additional Parameters
1219 ///
1220 /// * *alt* (query-string) - Data format for the response.
1221 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1222 /// * *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.
1223 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1224 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1225 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1226 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1227 pub fn param<T>(mut self, name: T, value: T) -> GroupPatchCall<'a, C>
1228 where
1229 T: AsRef<str>,
1230 {
1231 self._additional_params
1232 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1233 self
1234 }
1235
1236 /// Identifies the authorization scope for the method you are building.
1237 ///
1238 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1239 /// [`Scope::AppGroupSetting`].
1240 ///
1241 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1242 /// tokens for more than one scope.
1243 ///
1244 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1245 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1246 /// sufficient, a read-write scope will do as well.
1247 pub fn add_scope<St>(mut self, scope: St) -> GroupPatchCall<'a, C>
1248 where
1249 St: AsRef<str>,
1250 {
1251 self._scopes.insert(String::from(scope.as_ref()));
1252 self
1253 }
1254 /// Identifies the authorization scope(s) for the method you are building.
1255 ///
1256 /// See [`Self::add_scope()`] for details.
1257 pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupPatchCall<'a, C>
1258 where
1259 I: IntoIterator<Item = St>,
1260 St: AsRef<str>,
1261 {
1262 self._scopes
1263 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1264 self
1265 }
1266
1267 /// Removes all scopes, and no default scope will be used either.
1268 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1269 /// for details).
1270 pub fn clear_scopes(mut self) -> GroupPatchCall<'a, C> {
1271 self._scopes.clear();
1272 self
1273 }
1274}
1275
1276/// Updates an existing resource.
1277///
1278/// A builder for the *update* method supported by a *group* resource.
1279/// It is not used directly, but through a [`GroupMethods`] instance.
1280///
1281/// # Example
1282///
1283/// Instantiate a resource method builder
1284///
1285/// ```test_harness,no_run
1286/// # extern crate hyper;
1287/// # extern crate hyper_rustls;
1288/// # extern crate google_groupssettings1 as groupssettings1;
1289/// use groupssettings1::api::Groups;
1290/// # async fn dox() {
1291/// # use groupssettings1::{Groupssettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1292///
1293/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1294/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1295/// # secret,
1296/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1297/// # ).build().await.unwrap();
1298///
1299/// # let client = hyper_util::client::legacy::Client::builder(
1300/// # hyper_util::rt::TokioExecutor::new()
1301/// # )
1302/// # .build(
1303/// # hyper_rustls::HttpsConnectorBuilder::new()
1304/// # .with_native_roots()
1305/// # .unwrap()
1306/// # .https_or_http()
1307/// # .enable_http1()
1308/// # .build()
1309/// # );
1310/// # let mut hub = Groupssettings::new(client, auth);
1311/// // As the method needs a request, you would usually fill it with the desired information
1312/// // into the respective structure. Some of the parts shown here might not be applicable !
1313/// // Values shown here are possibly random and not representative !
1314/// let mut req = Groups::default();
1315///
1316/// // You can configure optional parameters by calling the respective setters at will, and
1317/// // execute the final call using `doit()`.
1318/// // Values shown here are possibly random and not representative !
1319/// let result = hub.groups().update(req, "groupUniqueId")
1320/// .doit().await;
1321/// # }
1322/// ```
1323pub struct GroupUpdateCall<'a, C>
1324where
1325 C: 'a,
1326{
1327 hub: &'a Groupssettings<C>,
1328 _request: Groups,
1329 _group_unique_id: String,
1330 _delegate: Option<&'a mut dyn common::Delegate>,
1331 _additional_params: HashMap<String, String>,
1332 _scopes: BTreeSet<String>,
1333}
1334
1335impl<'a, C> common::CallBuilder for GroupUpdateCall<'a, C> {}
1336
1337impl<'a, C> GroupUpdateCall<'a, C>
1338where
1339 C: common::Connector,
1340{
1341 /// Perform the operation you have build so far.
1342 pub async fn doit(mut self) -> common::Result<(common::Response, Groups)> {
1343 use std::borrow::Cow;
1344 use std::io::{Read, Seek};
1345
1346 use common::{url::Params, ToParts};
1347 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1348
1349 let mut dd = common::DefaultDelegate;
1350 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1351 dlg.begin(common::MethodInfo {
1352 id: "groupsSettings.groups.update",
1353 http_method: hyper::Method::PUT,
1354 });
1355
1356 for &field in ["alt", "groupUniqueId"].iter() {
1357 if self._additional_params.contains_key(field) {
1358 dlg.finished(false);
1359 return Err(common::Error::FieldClash(field));
1360 }
1361 }
1362
1363 let mut params = Params::with_capacity(4 + self._additional_params.len());
1364 params.push("groupUniqueId", self._group_unique_id);
1365
1366 params.extend(self._additional_params.iter());
1367
1368 params.push("alt", "json");
1369 let mut url = self.hub._base_url.clone() + "{groupUniqueId}";
1370 if self._scopes.is_empty() {
1371 self._scopes
1372 .insert(Scope::AppGroupSetting.as_ref().to_string());
1373 }
1374
1375 #[allow(clippy::single_element_loop)]
1376 for &(find_this, param_name) in [("{groupUniqueId}", "groupUniqueId")].iter() {
1377 url = params.uri_replacement(url, param_name, find_this, false);
1378 }
1379 {
1380 let to_remove = ["groupUniqueId"];
1381 params.remove_params(&to_remove);
1382 }
1383
1384 let url = params.parse_with_url(&url);
1385
1386 let mut json_mime_type = mime::APPLICATION_JSON;
1387 let mut request_value_reader = {
1388 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1389 common::remove_json_null_values(&mut value);
1390 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1391 serde_json::to_writer(&mut dst, &value).unwrap();
1392 dst
1393 };
1394 let request_size = request_value_reader
1395 .seek(std::io::SeekFrom::End(0))
1396 .unwrap();
1397 request_value_reader
1398 .seek(std::io::SeekFrom::Start(0))
1399 .unwrap();
1400
1401 loop {
1402 let token = match self
1403 .hub
1404 .auth
1405 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1406 .await
1407 {
1408 Ok(token) => token,
1409 Err(e) => match dlg.token(e) {
1410 Ok(token) => token,
1411 Err(e) => {
1412 dlg.finished(false);
1413 return Err(common::Error::MissingToken(e));
1414 }
1415 },
1416 };
1417 request_value_reader
1418 .seek(std::io::SeekFrom::Start(0))
1419 .unwrap();
1420 let mut req_result = {
1421 let client = &self.hub.client;
1422 dlg.pre_request();
1423 let mut req_builder = hyper::Request::builder()
1424 .method(hyper::Method::PUT)
1425 .uri(url.as_str())
1426 .header(USER_AGENT, self.hub._user_agent.clone());
1427
1428 if let Some(token) = token.as_ref() {
1429 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1430 }
1431
1432 let request = req_builder
1433 .header(CONTENT_TYPE, json_mime_type.to_string())
1434 .header(CONTENT_LENGTH, request_size as u64)
1435 .body(common::to_body(
1436 request_value_reader.get_ref().clone().into(),
1437 ));
1438
1439 client.request(request.unwrap()).await
1440 };
1441
1442 match req_result {
1443 Err(err) => {
1444 if let common::Retry::After(d) = dlg.http_error(&err) {
1445 sleep(d).await;
1446 continue;
1447 }
1448 dlg.finished(false);
1449 return Err(common::Error::HttpError(err));
1450 }
1451 Ok(res) => {
1452 let (mut parts, body) = res.into_parts();
1453 let mut body = common::Body::new(body);
1454 if !parts.status.is_success() {
1455 let bytes = common::to_bytes(body).await.unwrap_or_default();
1456 let error = serde_json::from_str(&common::to_string(&bytes));
1457 let response = common::to_response(parts, bytes.into());
1458
1459 if let common::Retry::After(d) =
1460 dlg.http_failure(&response, error.as_ref().ok())
1461 {
1462 sleep(d).await;
1463 continue;
1464 }
1465
1466 dlg.finished(false);
1467
1468 return Err(match error {
1469 Ok(value) => common::Error::BadRequest(value),
1470 _ => common::Error::Failure(response),
1471 });
1472 }
1473 let response = {
1474 let bytes = common::to_bytes(body).await.unwrap_or_default();
1475 let encoded = common::to_string(&bytes);
1476 match serde_json::from_str(&encoded) {
1477 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1478 Err(error) => {
1479 dlg.response_json_decode_error(&encoded, &error);
1480 return Err(common::Error::JsonDecodeError(
1481 encoded.to_string(),
1482 error,
1483 ));
1484 }
1485 }
1486 };
1487
1488 dlg.finished(true);
1489 return Ok(response);
1490 }
1491 }
1492 }
1493 }
1494
1495 ///
1496 /// Sets the *request* property to the given value.
1497 ///
1498 /// Even though the property as already been set when instantiating this call,
1499 /// we provide this method for API completeness.
1500 pub fn request(mut self, new_value: Groups) -> GroupUpdateCall<'a, C> {
1501 self._request = new_value;
1502 self
1503 }
1504 /// The group's email address.
1505 ///
1506 /// Sets the *group unique id* path property to the given value.
1507 ///
1508 /// Even though the property as already been set when instantiating this call,
1509 /// we provide this method for API completeness.
1510 pub fn group_unique_id(mut self, new_value: &str) -> GroupUpdateCall<'a, C> {
1511 self._group_unique_id = new_value.to_string();
1512 self
1513 }
1514 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1515 /// while executing the actual API request.
1516 ///
1517 /// ````text
1518 /// It should be used to handle progress information, and to implement a certain level of resilience.
1519 /// ````
1520 ///
1521 /// Sets the *delegate* property to the given value.
1522 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> GroupUpdateCall<'a, C> {
1523 self._delegate = Some(new_value);
1524 self
1525 }
1526
1527 /// Set any additional parameter of the query string used in the request.
1528 /// It should be used to set parameters which are not yet available through their own
1529 /// setters.
1530 ///
1531 /// Please note that this method must not be used to set any of the known parameters
1532 /// which have their own setter method. If done anyway, the request will fail.
1533 ///
1534 /// # Additional Parameters
1535 ///
1536 /// * *alt* (query-string) - Data format for the response.
1537 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1538 /// * *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.
1539 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1540 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1541 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1542 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1543 pub fn param<T>(mut self, name: T, value: T) -> GroupUpdateCall<'a, C>
1544 where
1545 T: AsRef<str>,
1546 {
1547 self._additional_params
1548 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1549 self
1550 }
1551
1552 /// Identifies the authorization scope for the method you are building.
1553 ///
1554 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1555 /// [`Scope::AppGroupSetting`].
1556 ///
1557 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1558 /// tokens for more than one scope.
1559 ///
1560 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1561 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1562 /// sufficient, a read-write scope will do as well.
1563 pub fn add_scope<St>(mut self, scope: St) -> GroupUpdateCall<'a, C>
1564 where
1565 St: AsRef<str>,
1566 {
1567 self._scopes.insert(String::from(scope.as_ref()));
1568 self
1569 }
1570 /// Identifies the authorization scope(s) for the method you are building.
1571 ///
1572 /// See [`Self::add_scope()`] for details.
1573 pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupUpdateCall<'a, C>
1574 where
1575 I: IntoIterator<Item = St>,
1576 St: AsRef<str>,
1577 {
1578 self._scopes
1579 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1580 self
1581 }
1582
1583 /// Removes all scopes, and no default scope will be used either.
1584 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1585 /// for details).
1586 pub fn clear_scopes(mut self) -> GroupUpdateCall<'a, C> {
1587 self._scopes.clear();
1588 self
1589 }
1590}