gsuite_api/verification_codes.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct VerificationCodes {
5 pub client: Client,
6}
7
8impl VerificationCodes {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 VerificationCodes { client }
12 }
13
14 /**
15 * This function performs a `GET` to the `/admin/directory/v1/users/{userKey}/verificationCodes` endpoint.
16 *
17 * Returns the current set of valid backup verification codes for the specified user.
18 *
19 * **Parameters:**
20 *
21 * * `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.
22 */
23 pub async fn list(
24 &self,
25 user_key: &str,
26 ) -> ClientResult<crate::Response<crate::types::VerificationCodes>> {
27 let url = self.client.url(
28 &format!(
29 "/admin/directory/v1/users/{}/verificationCodes",
30 crate::progenitor_support::encode_path(user_key),
31 ),
32 None,
33 );
34 self.client
35 .get(
36 &url,
37 crate::Message {
38 body: None,
39 content_type: None,
40 },
41 )
42 .await
43 }
44 /**
45 * This function performs a `POST` to the `/admin/directory/v1/users/{userKey}/verificationCodes/generate` endpoint.
46 *
47 * Generates new backup verification codes for the user.
48 *
49 * **Parameters:**
50 *
51 * * `user_key: &str` -- Email or immutable ID of the user.
52 */
53 pub async fn generate(&self, user_key: &str) -> ClientResult<crate::Response<()>> {
54 let url = self.client.url(
55 &format!(
56 "/admin/directory/v1/users/{}/verificationCodes/generate",
57 crate::progenitor_support::encode_path(user_key),
58 ),
59 None,
60 );
61 self.client
62 .post(
63 &url,
64 crate::Message {
65 body: None,
66 content_type: None,
67 },
68 )
69 .await
70 }
71 /**
72 * This function performs a `POST` to the `/admin/directory/v1/users/{userKey}/verificationCodes/invalidate` endpoint.
73 *
74 * Invalidates the current backup verification codes for the user.
75 *
76 * **Parameters:**
77 *
78 * * `user_key: &str` -- Email or immutable ID of the user.
79 */
80 pub async fn invalidate(&self, user_key: &str) -> ClientResult<crate::Response<()>> {
81 let url = self.client.url(
82 &format!(
83 "/admin/directory/v1/users/{}/verificationCodes/invalidate",
84 crate::progenitor_support::encode_path(user_key),
85 ),
86 None,
87 );
88 self.client
89 .post(
90 &url,
91 crate::Message {
92 body: None,
93 content_type: None,
94 },
95 )
96 .await
97 }
98}