gsuite_api/tokens.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct Tokens {
5 pub client: Client,
6}
7
8impl Tokens {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Tokens { client }
12 }
13
14 /**
15 * This function performs a `GET` to the `/admin/directory/v1/users/{userKey}/tokens` endpoint.
16 *
17 * Returns the set of tokens specified user has issued to 3rd party applications.
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::Tokens>> {
27 let url = self.client.url(
28 &format!(
29 "/admin/directory/v1/users/{}/tokens",
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 `GET` to the `/admin/directory/v1/users/{userKey}/tokens/{clientId}` endpoint.
46 *
47 * Gets information about an access token issued by a user.
48 *
49 * **Parameters:**
50 *
51 * * `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.
52 * * `client_id: &str` -- The Client ID of the application the token is issued to.
53 */
54 pub async fn get(
55 &self,
56 user_key: &str,
57 client_id: &str,
58 ) -> ClientResult<crate::Response<crate::types::Token>> {
59 let url = self.client.url(
60 &format!(
61 "/admin/directory/v1/users/{}/tokens/{}",
62 crate::progenitor_support::encode_path(user_key),
63 crate::progenitor_support::encode_path(client_id),
64 ),
65 None,
66 );
67 self.client
68 .get(
69 &url,
70 crate::Message {
71 body: None,
72 content_type: None,
73 },
74 )
75 .await
76 }
77 /**
78 * This function performs a `DELETE` to the `/admin/directory/v1/users/{userKey}/tokens/{clientId}` endpoint.
79 *
80 * Deletes all access tokens issued by a user for an application.
81 *
82 * **Parameters:**
83 *
84 * * `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.
85 * * `client_id: &str` -- The Client ID of the application the token is issued to.
86 */
87 pub async fn delete(
88 &self,
89 user_key: &str,
90 client_id: &str,
91 ) -> ClientResult<crate::Response<()>> {
92 let url = self.client.url(
93 &format!(
94 "/admin/directory/v1/users/{}/tokens/{}",
95 crate::progenitor_support::encode_path(user_key),
96 crate::progenitor_support::encode_path(client_id),
97 ),
98 None,
99 );
100 self.client
101 .delete(
102 &url,
103 crate::Message {
104 body: None,
105 content_type: None,
106 },
107 )
108 .await
109 }
110}