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