gsuite_api/
schemas.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Schemas {
5    pub client: Client,
6}
7
8impl Schemas {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Schemas { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/admin/directory/v1/customer/{customerId}/schemas` endpoint.
16     *
17     * Retrieves all schemas for a customer.
18     *
19     * **Parameters:**
20     *
21     * * `customer_id: &str` -- Immutable ID of the Google Workspace account.
22     */
23    pub async fn list(
24        &self,
25        customer_id: &str,
26    ) -> ClientResult<crate::Response<crate::types::Schemas>> {
27        let url = self.client.url(
28            &format!(
29                "/admin/directory/v1/customer/{}/schemas",
30                crate::progenitor_support::encode_path(customer_id),
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/customer/{customerId}/schemas` endpoint.
46     *
47     * Creates a schema.
48     *
49     * **Parameters:**
50     *
51     * * `customer_id: &str` -- Immutable ID of the Google Workspace account.
52     */
53    pub async fn insert(
54        &self,
55        customer_id: &str,
56        body: &crate::types::Schema,
57    ) -> ClientResult<crate::Response<crate::types::Schema>> {
58        let url = self.client.url(
59            &format!(
60                "/admin/directory/v1/customer/{}/schemas",
61                crate::progenitor_support::encode_path(customer_id),
62            ),
63            None,
64        );
65        self.client
66            .post(
67                &url,
68                crate::Message {
69                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
70                    content_type: Some("application/json".to_string()),
71                },
72            )
73            .await
74    }
75    /**
76     * This function performs a `GET` to the `/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}` endpoint.
77     *
78     * Retrieves a schema.
79     *
80     * **Parameters:**
81     *
82     * * `customer_id: &str` -- Immutable ID of the Google Workspace account.
83     * * `schema_key: &str` -- Name or immutable ID of the schema.
84     */
85    pub async fn get(
86        &self,
87        customer_id: &str,
88        schema_key: &str,
89    ) -> ClientResult<crate::Response<crate::types::Schema>> {
90        let url = self.client.url(
91            &format!(
92                "/admin/directory/v1/customer/{}/schemas/{}",
93                crate::progenitor_support::encode_path(customer_id),
94                crate::progenitor_support::encode_path(schema_key),
95            ),
96            None,
97        );
98        self.client
99            .get(
100                &url,
101                crate::Message {
102                    body: None,
103                    content_type: None,
104                },
105            )
106            .await
107    }
108    /**
109     * This function performs a `PUT` to the `/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}` endpoint.
110     *
111     * Updates a schema.
112     *
113     * **Parameters:**
114     *
115     * * `customer_id: &str` -- Immutable ID of the Google Workspace account.
116     * * `schema_key: &str` -- Name or immutable ID of the schema.
117     */
118    pub async fn update(
119        &self,
120        customer_id: &str,
121        schema_key: &str,
122        body: &crate::types::Schema,
123    ) -> ClientResult<crate::Response<crate::types::Schema>> {
124        let url = self.client.url(
125            &format!(
126                "/admin/directory/v1/customer/{}/schemas/{}",
127                crate::progenitor_support::encode_path(customer_id),
128                crate::progenitor_support::encode_path(schema_key),
129            ),
130            None,
131        );
132        self.client
133            .put(
134                &url,
135                crate::Message {
136                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
137                    content_type: Some("application/json".to_string()),
138                },
139            )
140            .await
141    }
142    /**
143     * This function performs a `DELETE` to the `/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}` endpoint.
144     *
145     * Deletes a schema.
146     *
147     * **Parameters:**
148     *
149     * * `customer_id: &str` -- Immutable ID of the Google Workspace account.
150     * * `schema_key: &str` -- Name or immutable ID of the schema.
151     */
152    pub async fn delete(
153        &self,
154        customer_id: &str,
155        schema_key: &str,
156    ) -> ClientResult<crate::Response<()>> {
157        let url = self.client.url(
158            &format!(
159                "/admin/directory/v1/customer/{}/schemas/{}",
160                crate::progenitor_support::encode_path(customer_id),
161                crate::progenitor_support::encode_path(schema_key),
162            ),
163            None,
164        );
165        self.client
166            .delete(
167                &url,
168                crate::Message {
169                    body: None,
170                    content_type: None,
171                },
172            )
173            .await
174    }
175    /**
176     * This function performs a `PATCH` to the `/admin/directory/v1/customer/{customerId}/schemas/{schemaKey}` endpoint.
177     *
178     * Patches a schema.
179     *
180     * **Parameters:**
181     *
182     * * `customer_id: &str` -- Immutable ID of the Google Workspace account.
183     * * `schema_key: &str` -- Name or immutable ID of the schema.
184     */
185    pub async fn patch(
186        &self,
187        customer_id: &str,
188        schema_key: &str,
189        body: &crate::types::Schema,
190    ) -> ClientResult<crate::Response<crate::types::Schema>> {
191        let url = self.client.url(
192            &format!(
193                "/admin/directory/v1/customer/{}/schemas/{}",
194                crate::progenitor_support::encode_path(customer_id),
195                crate::progenitor_support::encode_path(schema_key),
196            ),
197            None,
198        );
199        self.client
200            .patch(
201                &url,
202                crate::Message {
203                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
204                    content_type: Some("application/json".to_string()),
205                },
206            )
207            .await
208    }
209}