gsuite_api/
users.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Users {
5    pub client: Client,
6}
7
8impl Users {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Users { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/admin/directory/v1/users` endpoint.
16     *
17     * Retrieves a paginated list of either deleted users or all users in a domain.
18     *
19     * **Parameters:**
20     *
21     * * `custom_field_mask: &str` -- A comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when `projection=custom`.
22     * * `customer: &str` -- The unique ID for the customer's Google Workspace account. In case of a multi-domain account, to fetch all groups for a customer, fill this field instead of domain. You can also use the `my_customer` alias to represent your account's `customerId`. The `customerId` is also returned as part of the [Users resource](/admin-sdk/directory/v1/reference/users). Either the `customer` or the `domain` parameter must be provided.
23     * * `domain: &str` -- The domain name. Use this field to get fields from only one domain. To return all domains for a customer account, use the `customer` query parameter instead. Either the `customer` or the `domain` parameter must be provided.
24     * * `event: crate::types::Event` -- Event on which subscription is intended (if subscribing).
25     * * `max_results: i64` -- Maximum number of results to return.
26     * * `order_by: crate::types::DirectoryUsersListOrderBy` -- Property to use for sorting results.
27     * * `page_token: &str` -- Token to specify next page in the list.
28     * * `projection: crate::types::DirectoryUsersListProjection` -- What subset of fields to fetch for this user.
29     * * `query: &str` -- Query string for searching user fields. For more information on constructing user queries, see [Search for Users](/admin-sdk/directory/v1/guides/search-users).
30     * * `show_deleted: &str` -- If set to `true`, retrieves the list of deleted users. (Default: `false`).
31     * * `sort_order: crate::types::SortOrder` -- Whether to return results in ascending or descending order. Must be used with the `orderBy` parameter.
32     * * `view_type: crate::types::ViewType` -- Whether to fetch the administrator-only or domain-wide public view of the user. For more information, see [Retrieve a user as a non-administrator](/admin-sdk/directory/v1/guides/manage-users#retrieve_users_non_admin).
33     */
34    pub async fn list(
35        &self,
36        customer: &str,
37        domain: &str,
38        event: crate::types::Event,
39        max_results: i64,
40        order_by: crate::types::DirectoryUsersListOrderBy,
41        page_token: &str,
42        projection: crate::types::DirectoryUsersListProjection,
43        query: &str,
44        show_deleted: &str,
45        sort_order: crate::types::SortOrder,
46        view_type: crate::types::ViewType,
47    ) -> ClientResult<crate::Response<Vec<crate::types::User>>> {
48        let mut query_args: Vec<(String, String)> = Default::default();
49        if !customer.is_empty() {
50            query_args.push(("customer".to_string(), customer.to_string()));
51        }
52        if !domain.is_empty() {
53            query_args.push(("domain".to_string(), domain.to_string()));
54        }
55        if !event.to_string().is_empty() {
56            query_args.push(("event".to_string(), event.to_string()));
57        }
58        if max_results > 0 {
59            query_args.push(("maxResults".to_string(), max_results.to_string()));
60        }
61        if !order_by.to_string().is_empty() {
62            query_args.push(("orderBy".to_string(), order_by.to_string()));
63        }
64        if !page_token.is_empty() {
65            query_args.push(("pageToken".to_string(), page_token.to_string()));
66        }
67        if !projection.to_string().is_empty() {
68            query_args.push(("projection".to_string(), projection.to_string()));
69        }
70        if !query.is_empty() {
71            query_args.push(("query".to_string(), query.to_string()));
72        }
73        if !show_deleted.is_empty() {
74            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
75        }
76        if !sort_order.to_string().is_empty() {
77            query_args.push(("sortOrder".to_string(), sort_order.to_string()));
78        }
79        if !view_type.to_string().is_empty() {
80            query_args.push(("viewType".to_string(), view_type.to_string()));
81        }
82        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
83        let url = self
84            .client
85            .url(&format!("/admin/directory/v1/users?{}", query_), None);
86        let resp: crate::Response<crate::types::Users> = self
87            .client
88            .get(
89                &url,
90                crate::Message {
91                    body: None,
92                    content_type: None,
93                },
94            )
95            .await?;
96
97        // Return our response data.
98        Ok(crate::Response::new(
99            resp.status,
100            resp.headers,
101            resp.body.users.to_vec(),
102        ))
103    }
104    /**
105     * This function performs a `GET` to the `/admin/directory/v1/users` endpoint.
106     *
107     * As opposed to `list`, this function returns all the pages of the request at once.
108     *
109     * Retrieves a paginated list of either deleted users or all users in a domain.
110     */
111    pub async fn list_all(
112        &self,
113        customer: &str,
114        domain: &str,
115        event: crate::types::Event,
116        order_by: crate::types::DirectoryUsersListOrderBy,
117        projection: crate::types::DirectoryUsersListProjection,
118        query: &str,
119        show_deleted: &str,
120        sort_order: crate::types::SortOrder,
121        view_type: crate::types::ViewType,
122    ) -> ClientResult<crate::Response<Vec<crate::types::User>>> {
123        let mut query_args: Vec<(String, String)> = Default::default();
124        if !customer.is_empty() {
125            query_args.push(("customer".to_string(), customer.to_string()));
126        }
127        if !domain.is_empty() {
128            query_args.push(("domain".to_string(), domain.to_string()));
129        }
130        if !event.to_string().is_empty() {
131            query_args.push(("event".to_string(), event.to_string()));
132        }
133        if !order_by.to_string().is_empty() {
134            query_args.push(("orderBy".to_string(), order_by.to_string()));
135        }
136        if !projection.to_string().is_empty() {
137            query_args.push(("projection".to_string(), projection.to_string()));
138        }
139        if !query.is_empty() {
140            query_args.push(("query".to_string(), query.to_string()));
141        }
142        if !show_deleted.is_empty() {
143            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
144        }
145        if !sort_order.to_string().is_empty() {
146            query_args.push(("sortOrder".to_string(), sort_order.to_string()));
147        }
148        if !view_type.to_string().is_empty() {
149            query_args.push(("viewType".to_string(), view_type.to_string()));
150        }
151        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
152        let url = self
153            .client
154            .url(&format!("/admin/directory/v1/users?{}", query_), None);
155        let crate::Response::<crate::types::Users> {
156            mut status,
157            mut headers,
158            mut body,
159        } = self
160            .client
161            .get(
162                &url,
163                crate::Message {
164                    body: None,
165                    content_type: None,
166                },
167            )
168            .await?;
169
170        let mut users = body.users;
171        let mut page = body.next_page_token;
172
173        // Paginate if we should.
174        while !page.is_empty() {
175            if !url.contains('?') {
176                crate::Response::<crate::types::Users> {
177                    status,
178                    headers,
179                    body,
180                } = self
181                    .client
182                    .get(
183                        &format!("{}?pageToken={}", url, page),
184                        crate::Message {
185                            body: None,
186                            content_type: None,
187                        },
188                    )
189                    .await?;
190            } else {
191                crate::Response::<crate::types::Users> {
192                    status,
193                    headers,
194                    body,
195                } = self
196                    .client
197                    .get(
198                        &format!("{}&pageToken={}", url, page),
199                        crate::Message {
200                            body: None,
201                            content_type: None,
202                        },
203                    )
204                    .await?;
205            }
206
207            users.append(&mut body.users);
208
209            if !body.next_page_token.is_empty() && body.next_page_token != page {
210                page = body.next_page_token.to_string();
211            } else {
212                page = "".to_string();
213            }
214        }
215
216        // Return our response data.
217        Ok(crate::Response::new(status, headers, users))
218    }
219    /**
220     * This function performs a `POST` to the `/admin/directory/v1/users` endpoint.
221     *
222     * Creates a user.
223     */
224    pub async fn insert(
225        &self,
226        body: &crate::types::User,
227    ) -> ClientResult<crate::Response<crate::types::User>> {
228        let url = self.client.url("/admin/directory/v1/users", None);
229        self.client
230            .post(
231                &url,
232                crate::Message {
233                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
234                    content_type: Some("application/json".to_string()),
235                },
236            )
237            .await
238    }
239    /**
240     * This function performs a `POST` to the `/admin/directory/v1/users/watch` endpoint.
241     *
242     * Watches for changes in users list.
243     *
244     * **Parameters:**
245     *
246     * * `custom_field_mask: &str` -- Comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom.
247     * * `customer: &str` -- Immutable ID of the Google Workspace account. In case of multi-domain, to fetch all users for a customer, fill this field instead of domain.
248     * * `domain: &str` -- Name of the domain. Fill this field to get users from only this domain. To return all users in a multi-domain fill customer field instead.".
249     * * `event: crate::types::Event` -- Event on which subscription is intended (if subscribing).
250     * * `max_results: i64` -- Maximum number of results to return.
251     * * `order_by: crate::types::DirectoryUsersListOrderBy` -- Property to use for sorting results.
252     * * `page_token: &str` -- Token to specify next page in the list.
253     * * `projection: crate::types::DirectoryUsersListProjection` -- What subset of fields to fetch for this user.
254     * * `query: &str` -- Query string search. Should be of the form "". Complete documentation is at https: //developers.google.com/admin-sdk/directory/v1/guides/search-users.
255     * * `show_deleted: &str` -- If set to true, retrieves the list of deleted users. (Default: false).
256     * * `sort_order: crate::types::SortOrder` -- Whether to return results in ascending or descending order. Must be used with the `orderBy` parameter.
257     * * `view_type: crate::types::ViewType` -- Whether to fetch the administrator-only or domain-wide public view of the user. For more information, see [Retrieve a user as a non-administrator](/admin-sdk/directory/v1/guides/manage-users#retrieve_users_non_admin).
258     */
259    pub async fn watch(
260        &self,
261        customer: &str,
262        domain: &str,
263        event: crate::types::Event,
264        max_results: i64,
265        order_by: crate::types::DirectoryUsersListOrderBy,
266        page_token: &str,
267        projection: crate::types::DirectoryUsersListProjection,
268        query: &str,
269        show_deleted: &str,
270        sort_order: crate::types::SortOrder,
271        view_type: crate::types::ViewType,
272        body: &crate::types::Channel,
273    ) -> ClientResult<crate::Response<crate::types::Channel>> {
274        let mut query_args: Vec<(String, String)> = Default::default();
275        if !customer.is_empty() {
276            query_args.push(("customer".to_string(), customer.to_string()));
277        }
278        if !domain.is_empty() {
279            query_args.push(("domain".to_string(), domain.to_string()));
280        }
281        if !event.to_string().is_empty() {
282            query_args.push(("event".to_string(), event.to_string()));
283        }
284        if max_results > 0 {
285            query_args.push(("maxResults".to_string(), max_results.to_string()));
286        }
287        if !order_by.to_string().is_empty() {
288            query_args.push(("orderBy".to_string(), order_by.to_string()));
289        }
290        if !page_token.is_empty() {
291            query_args.push(("pageToken".to_string(), page_token.to_string()));
292        }
293        if !projection.to_string().is_empty() {
294            query_args.push(("projection".to_string(), projection.to_string()));
295        }
296        if !query.is_empty() {
297            query_args.push(("query".to_string(), query.to_string()));
298        }
299        if !show_deleted.is_empty() {
300            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
301        }
302        if !sort_order.to_string().is_empty() {
303            query_args.push(("sortOrder".to_string(), sort_order.to_string()));
304        }
305        if !view_type.to_string().is_empty() {
306            query_args.push(("viewType".to_string(), view_type.to_string()));
307        }
308        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
309        let url = self
310            .client
311            .url(&format!("/admin/directory/v1/users/watch?{}", query_), None);
312        self.client
313            .post(
314                &url,
315                crate::Message {
316                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
317                    content_type: Some("application/json".to_string()),
318                },
319            )
320            .await
321    }
322    /**
323     * This function performs a `GET` to the `/admin/directory/v1/users/{userKey}` endpoint.
324     *
325     * Retrieves a user.
326     *
327     * **Parameters:**
328     *
329     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
330     * * `custom_field_mask: &str` -- A comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when `projection=custom`.
331     * * `projection: crate::types::DirectoryUsersListProjection` -- What subset of fields to fetch for this user.
332     * * `view_type: crate::types::ViewType` -- Whether to fetch the administrator-only or domain-wide public view of the user. For more information, see [Retrieve a user as a non-administrator](/admin-sdk/directory/v1/guides/manage-users#retrieve_users_non_admin).
333     */
334    pub async fn get(
335        &self,
336        user_key: &str,
337        projection: crate::types::DirectoryUsersListProjection,
338        view_type: crate::types::ViewType,
339    ) -> ClientResult<crate::Response<crate::types::User>> {
340        let mut query_args: Vec<(String, String)> = Default::default();
341        if !projection.to_string().is_empty() {
342            query_args.push(("projection".to_string(), projection.to_string()));
343        }
344        if !view_type.to_string().is_empty() {
345            query_args.push(("viewType".to_string(), view_type.to_string()));
346        }
347        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
348        let url = self.client.url(
349            &format!(
350                "/admin/directory/v1/users/{}?{}",
351                crate::progenitor_support::encode_path(user_key),
352                query_
353            ),
354            None,
355        );
356        self.client
357            .get(
358                &url,
359                crate::Message {
360                    body: None,
361                    content_type: None,
362                },
363            )
364            .await
365    }
366    /**
367     * This function performs a `PUT` to the `/admin/directory/v1/users/{userKey}` endpoint.
368     *
369     * Updates a user. This method supports patch semantics, meaning you only need to include the fields you wish to update. Fields that are not present in the request will be preserved, and fields set to `null` will be cleared.
370     *
371     * **Parameters:**
372     *
373     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
374     */
375    pub async fn update(
376        &self,
377        user_key: &str,
378        body: &crate::types::User,
379    ) -> ClientResult<crate::Response<crate::types::User>> {
380        let url = self.client.url(
381            &format!(
382                "/admin/directory/v1/users/{}",
383                crate::progenitor_support::encode_path(user_key),
384            ),
385            None,
386        );
387        self.client
388            .put(
389                &url,
390                crate::Message {
391                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
392                    content_type: Some("application/json".to_string()),
393                },
394            )
395            .await
396    }
397    /**
398     * This function performs a `DELETE` to the `/admin/directory/v1/users/{userKey}` endpoint.
399     *
400     * Deletes a user.
401     *
402     * **Parameters:**
403     *
404     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
405     */
406    pub async fn delete(&self, user_key: &str) -> ClientResult<crate::Response<()>> {
407        let url = self.client.url(
408            &format!(
409                "/admin/directory/v1/users/{}",
410                crate::progenitor_support::encode_path(user_key),
411            ),
412            None,
413        );
414        self.client
415            .delete(
416                &url,
417                crate::Message {
418                    body: None,
419                    content_type: None,
420                },
421            )
422            .await
423    }
424    /**
425     * This function performs a `PATCH` to the `/admin/directory/v1/users/{userKey}` endpoint.
426     *
427     * Updates a user using patch semantics. The update method should be used instead, since it also supports patch semantics and has better performance. This method is unable to clear fields that contain repeated objects (`addresses`, `phones`, etc). Use the update method instead.
428     *
429     * **Parameters:**
430     *
431     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
432     */
433    pub async fn patch(
434        &self,
435        user_key: &str,
436        body: &crate::types::User,
437    ) -> ClientResult<crate::Response<crate::types::User>> {
438        let url = self.client.url(
439            &format!(
440                "/admin/directory/v1/users/{}",
441                crate::progenitor_support::encode_path(user_key),
442            ),
443            None,
444        );
445        self.client
446            .patch(
447                &url,
448                crate::Message {
449                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
450                    content_type: Some("application/json".to_string()),
451                },
452            )
453            .await
454    }
455    /**
456     * This function performs a `GET` to the `/admin/directory/v1/users/{userKey}/aliases` endpoint.
457     *
458     * Lists all aliases for a user.
459     *
460     * **Parameters:**
461     *
462     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
463     * * `event: crate::types::DirectoryUsersAliasesListEvent` -- Events to watch for.
464     */
465    pub async fn aliases_list(
466        &self,
467        user_key: &str,
468        event: crate::types::DirectoryUsersAliasesListEvent,
469    ) -> ClientResult<crate::Response<crate::types::Aliases>> {
470        let mut query_args: Vec<(String, String)> = Default::default();
471        if !event.to_string().is_empty() {
472            query_args.push(("event".to_string(), event.to_string()));
473        }
474        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
475        let url = self.client.url(
476            &format!(
477                "/admin/directory/v1/users/{}/aliases?{}",
478                crate::progenitor_support::encode_path(user_key),
479                query_
480            ),
481            None,
482        );
483        self.client
484            .get(
485                &url,
486                crate::Message {
487                    body: None,
488                    content_type: None,
489                },
490            )
491            .await
492    }
493    /**
494     * This function performs a `POST` to the `/admin/directory/v1/users/{userKey}/aliases` endpoint.
495     *
496     * Adds an alias.
497     *
498     * **Parameters:**
499     *
500     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
501     */
502    pub async fn aliases_insert(
503        &self,
504        user_key: &str,
505        body: &crate::types::Alias,
506    ) -> ClientResult<crate::Response<crate::types::Alias>> {
507        let url = self.client.url(
508            &format!(
509                "/admin/directory/v1/users/{}/aliases",
510                crate::progenitor_support::encode_path(user_key),
511            ),
512            None,
513        );
514        self.client
515            .post(
516                &url,
517                crate::Message {
518                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
519                    content_type: Some("application/json".to_string()),
520                },
521            )
522            .await
523    }
524    /**
525     * This function performs a `POST` to the `/admin/directory/v1/users/{userKey}/aliases/watch` endpoint.
526     *
527     * Watches for changes in users list.
528     *
529     * **Parameters:**
530     *
531     * * `user_key: &str` -- Email or immutable ID of the user.
532     * * `event: crate::types::DirectoryUsersAliasesListEvent` -- Events to watch for.
533     */
534    pub async fn aliases_watch(
535        &self,
536        user_key: &str,
537        event: crate::types::DirectoryUsersAliasesListEvent,
538        body: &crate::types::Channel,
539    ) -> ClientResult<crate::Response<crate::types::Channel>> {
540        let mut query_args: Vec<(String, String)> = Default::default();
541        if !event.to_string().is_empty() {
542            query_args.push(("event".to_string(), event.to_string()));
543        }
544        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
545        let url = self.client.url(
546            &format!(
547                "/admin/directory/v1/users/{}/aliases/watch?{}",
548                crate::progenitor_support::encode_path(user_key),
549                query_
550            ),
551            None,
552        );
553        self.client
554            .post(
555                &url,
556                crate::Message {
557                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
558                    content_type: Some("application/json".to_string()),
559                },
560            )
561            .await
562    }
563    /**
564     * This function performs a `DELETE` to the `/admin/directory/v1/users/{userKey}/aliases/{alias}` endpoint.
565     *
566     * Removes an alias.
567     *
568     * **Parameters:**
569     *
570     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
571     * * `alias: &str` -- The alias to be removed.
572     */
573    pub async fn aliases_delete(
574        &self,
575        user_key: &str,
576        alias: &str,
577    ) -> ClientResult<crate::Response<()>> {
578        let url = self.client.url(
579            &format!(
580                "/admin/directory/v1/users/{}/aliases/{}",
581                crate::progenitor_support::encode_path(user_key),
582                crate::progenitor_support::encode_path(alias),
583            ),
584            None,
585        );
586        self.client
587            .delete(
588                &url,
589                crate::Message {
590                    body: None,
591                    content_type: None,
592                },
593            )
594            .await
595    }
596    /**
597     * This function performs a `POST` to the `/admin/directory/v1/users/{userKey}/makeAdmin` endpoint.
598     *
599     * Makes a user a super administrator.
600     *
601     * **Parameters:**
602     *
603     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
604     */
605    pub async fn make_admin(
606        &self,
607        user_key: &str,
608        body: &crate::types::UserMakeAdmin,
609    ) -> ClientResult<crate::Response<()>> {
610        let url = self.client.url(
611            &format!(
612                "/admin/directory/v1/users/{}/makeAdmin",
613                crate::progenitor_support::encode_path(user_key),
614            ),
615            None,
616        );
617        self.client
618            .post(
619                &url,
620                crate::Message {
621                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
622                    content_type: Some("application/json".to_string()),
623                },
624            )
625            .await
626    }
627    /**
628     * This function performs a `GET` to the `/admin/directory/v1/users/{userKey}/photos/thumbnail` endpoint.
629     *
630     * Retrieves the user's photo.
631     *
632     * **Parameters:**
633     *
634     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
635     */
636    pub async fn photos_get(
637        &self,
638        user_key: &str,
639    ) -> ClientResult<crate::Response<crate::types::UserPhoto>> {
640        let url = self.client.url(
641            &format!(
642                "/admin/directory/v1/users/{}/photos/thumbnail",
643                crate::progenitor_support::encode_path(user_key),
644            ),
645            None,
646        );
647        self.client
648            .get(
649                &url,
650                crate::Message {
651                    body: None,
652                    content_type: None,
653                },
654            )
655            .await
656    }
657    /**
658     * This function performs a `PUT` to the `/admin/directory/v1/users/{userKey}/photos/thumbnail` endpoint.
659     *
660     * Adds a photo for the user.
661     *
662     * **Parameters:**
663     *
664     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
665     */
666    pub async fn photos_update(
667        &self,
668        user_key: &str,
669        body: &crate::types::UserPhoto,
670    ) -> ClientResult<crate::Response<crate::types::UserPhoto>> {
671        let url = self.client.url(
672            &format!(
673                "/admin/directory/v1/users/{}/photos/thumbnail",
674                crate::progenitor_support::encode_path(user_key),
675            ),
676            None,
677        );
678        self.client
679            .put(
680                &url,
681                crate::Message {
682                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
683                    content_type: Some("application/json".to_string()),
684                },
685            )
686            .await
687    }
688    /**
689     * This function performs a `DELETE` to the `/admin/directory/v1/users/{userKey}/photos/thumbnail` endpoint.
690     *
691     * Removes the user's photo.
692     *
693     * **Parameters:**
694     *
695     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
696     */
697    pub async fn photos_delete(&self, user_key: &str) -> ClientResult<crate::Response<()>> {
698        let url = self.client.url(
699            &format!(
700                "/admin/directory/v1/users/{}/photos/thumbnail",
701                crate::progenitor_support::encode_path(user_key),
702            ),
703            None,
704        );
705        self.client
706            .delete(
707                &url,
708                crate::Message {
709                    body: None,
710                    content_type: None,
711                },
712            )
713            .await
714    }
715    /**
716     * This function performs a `PATCH` to the `/admin/directory/v1/users/{userKey}/photos/thumbnail` endpoint.
717     *
718     * Adds a photo for the user. This method supports [patch semantics](/admin-sdk/directory/v1/guides/performance#patch).
719     *
720     * **Parameters:**
721     *
722     * * `user_key: &str` -- Identifies the user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
723     */
724    pub async fn photos_patch(
725        &self,
726        user_key: &str,
727        body: &crate::types::UserPhoto,
728    ) -> ClientResult<crate::Response<crate::types::UserPhoto>> {
729        let url = self.client.url(
730            &format!(
731                "/admin/directory/v1/users/{}/photos/thumbnail",
732                crate::progenitor_support::encode_path(user_key),
733            ),
734            None,
735        );
736        self.client
737            .patch(
738                &url,
739                crate::Message {
740                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
741                    content_type: Some("application/json".to_string()),
742                },
743            )
744            .await
745    }
746    /**
747     * This function performs a `POST` to the `/admin/directory/v1/users/{userKey}/signOut` endpoint.
748     *
749     * Signs a user out of all web and device sessions and reset their sign-in cookies. User will have to sign in by authenticating again.
750     *
751     * **Parameters:**
752     *
753     * * `user_key: &str` -- Identifies the target user in the API request. The value can be the user's primary email address, alias email address, or unique user ID.
754     */
755    pub async fn sign_out(&self, user_key: &str) -> ClientResult<crate::Response<()>> {
756        let url = self.client.url(
757            &format!(
758                "/admin/directory/v1/users/{}/signOut",
759                crate::progenitor_support::encode_path(user_key),
760            ),
761            None,
762        );
763        self.client
764            .post(
765                &url,
766                crate::Message {
767                    body: None,
768                    content_type: None,
769                },
770            )
771            .await
772    }
773    /**
774     * This function performs a `POST` to the `/admin/directory/v1/users/{userKey}/undelete` endpoint.
775     *
776     * Undeletes a deleted user.
777     *
778     * **Parameters:**
779     *
780     * * `user_key: &str` -- The immutable id of the user.
781     */
782    pub async fn undelete(
783        &self,
784        user_key: &str,
785        body: &crate::types::UserUndelete,
786    ) -> ClientResult<crate::Response<()>> {
787        let url = self.client.url(
788            &format!(
789                "/admin/directory/v1/users/{}/undelete",
790                crate::progenitor_support::encode_path(user_key),
791            ),
792            None,
793        );
794        self.client
795            .post(
796                &url,
797                crate::Message {
798                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
799                    content_type: Some("application/json".to_string()),
800                },
801            )
802            .await
803    }
804}