1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum UserServiceCreateUserError {
22 DefaultResponse(models::GooglerpcStatus),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum UserServiceCreateUserAccessTokenError {
30 DefaultResponse(models::GooglerpcStatus),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum UserServiceDeleteUserError {
38 DefaultResponse(models::GooglerpcStatus),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum UserServiceDeleteUserAccessTokenError {
46 DefaultResponse(models::GooglerpcStatus),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum UserServiceGetUserError {
54 DefaultResponse(models::GooglerpcStatus),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum UserServiceGetUserAvatarBinaryError {
62 DefaultResponse(models::GooglerpcStatus),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum UserServiceGetUserSettingError {
70 DefaultResponse(models::GooglerpcStatus),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum UserServiceListUserAccessTokensError {
78 DefaultResponse(models::GooglerpcStatus),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum UserServiceListUsersError {
86 DefaultResponse(models::GooglerpcStatus),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum UserServiceSearchUsersError {
94 DefaultResponse(models::GooglerpcStatus),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum UserServiceUpdateUserError {
102 DefaultResponse(models::GooglerpcStatus),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum UserServiceUpdateUserSettingError {
110 DefaultResponse(models::GooglerpcStatus),
111 UnknownValue(serde_json::Value),
112}
113
114
115pub fn user_service_create_user(configuration: &configuration::Configuration, user: models::V1User) -> Result<models::V1User, Error<UserServiceCreateUserError>> {
116 let local_var_configuration = configuration;
117
118 let local_var_client = &local_var_configuration.client;
119
120 let local_var_uri_str = format!("{}/api/v1/users", local_var_configuration.base_path);
121 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
122
123 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
124 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
125 }
126 local_var_req_builder = local_var_req_builder.json(&user);
127
128 let local_var_req = local_var_req_builder.build()?;
129 let local_var_resp = local_var_client.execute(local_var_req)?;
130
131 let local_var_status = local_var_resp.status();
132 let local_var_content = local_var_resp.text()?;
133
134 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
135 serde_json::from_str(&local_var_content).map_err(Error::from)
136 } else {
137 let local_var_entity: Option<UserServiceCreateUserError> = serde_json::from_str(&local_var_content).ok();
138 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
139 Err(Error::ResponseError(local_var_error))
140 }
141}
142
143pub fn user_service_create_user_access_token(configuration: &configuration::Configuration, name: &str, body: models::UserServiceCreateUserAccessTokenBody) -> Result<models::V1UserAccessToken, Error<UserServiceCreateUserAccessTokenError>> {
144 let local_var_configuration = configuration;
145
146 let local_var_client = &local_var_configuration.client;
147
148 let local_var_uri_str = format!("{}/api/v1/{name}/access_tokens", local_var_configuration.base_path, name=crate::apis::urlencode(name));
149 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
150
151 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
152 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
153 }
154 local_var_req_builder = local_var_req_builder.json(&body);
155
156 let local_var_req = local_var_req_builder.build()?;
157 let local_var_resp = local_var_client.execute(local_var_req)?;
158
159 let local_var_status = local_var_resp.status();
160 let local_var_content = local_var_resp.text()?;
161
162 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
163 serde_json::from_str(&local_var_content).map_err(Error::from)
164 } else {
165 let local_var_entity: Option<UserServiceCreateUserAccessTokenError> = serde_json::from_str(&local_var_content).ok();
166 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
167 Err(Error::ResponseError(local_var_error))
168 }
169}
170
171pub fn user_service_delete_user(configuration: &configuration::Configuration, name: &str) -> Result<serde_json::Value, Error<UserServiceDeleteUserError>> {
172 let local_var_configuration = configuration;
173
174 let local_var_client = &local_var_configuration.client;
175
176 let local_var_uri_str = format!("{}/api/v1/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
177 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
178
179 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
180 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
181 }
182
183 let local_var_req = local_var_req_builder.build()?;
184 let local_var_resp = local_var_client.execute(local_var_req)?;
185
186 let local_var_status = local_var_resp.status();
187 let local_var_content = local_var_resp.text()?;
188
189 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
190 serde_json::from_str(&local_var_content).map_err(Error::from)
191 } else {
192 let local_var_entity: Option<UserServiceDeleteUserError> = serde_json::from_str(&local_var_content).ok();
193 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
194 Err(Error::ResponseError(local_var_error))
195 }
196}
197
198pub fn user_service_delete_user_access_token(configuration: &configuration::Configuration, name: &str, access_token: &str) -> Result<serde_json::Value, Error<UserServiceDeleteUserAccessTokenError>> {
199 let local_var_configuration = configuration;
200
201 let local_var_client = &local_var_configuration.client;
202
203 let local_var_uri_str = format!("{}/api/v1/{name}/access_tokens/{accessToken}", local_var_configuration.base_path, name=crate::apis::urlencode(name), accessToken=crate::apis::urlencode(access_token));
204 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
205
206 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
207 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
208 }
209
210 let local_var_req = local_var_req_builder.build()?;
211 let local_var_resp = local_var_client.execute(local_var_req)?;
212
213 let local_var_status = local_var_resp.status();
214 let local_var_content = local_var_resp.text()?;
215
216 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
217 serde_json::from_str(&local_var_content).map_err(Error::from)
218 } else {
219 let local_var_entity: Option<UserServiceDeleteUserAccessTokenError> = serde_json::from_str(&local_var_content).ok();
220 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
221 Err(Error::ResponseError(local_var_error))
222 }
223}
224
225pub fn user_service_get_user(configuration: &configuration::Configuration, name_1: &str) -> Result<models::V1User, Error<UserServiceGetUserError>> {
226 let local_var_configuration = configuration;
227
228 let local_var_client = &local_var_configuration.client;
229
230 let local_var_uri_str = format!("{}/api/v1/{name_1}", local_var_configuration.base_path, name_1=crate::apis::urlencode(name_1));
231 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
232
233 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
234 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
235 }
236
237 let local_var_req = local_var_req_builder.build()?;
238 let local_var_resp = local_var_client.execute(local_var_req)?;
239
240 let local_var_status = local_var_resp.status();
241 let local_var_content = local_var_resp.text()?;
242
243 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
244 serde_json::from_str(&local_var_content).map_err(Error::from)
245 } else {
246 let local_var_entity: Option<UserServiceGetUserError> = serde_json::from_str(&local_var_content).ok();
247 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
248 Err(Error::ResponseError(local_var_error))
249 }
250}
251
252pub fn user_service_get_user_avatar_binary(configuration: &configuration::Configuration, name: &str, http_body_period_content_type: Option<&str>, http_body_period_data: Option<String>) -> Result<models::ApiHttpBody, Error<UserServiceGetUserAvatarBinaryError>> {
253 let local_var_configuration = configuration;
254
255 let local_var_client = &local_var_configuration.client;
256
257 let local_var_uri_str = format!("{}/file/{name}/avatar", local_var_configuration.base_path, name=crate::apis::urlencode(name));
258 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
259
260 if let Some(ref local_var_str) = http_body_period_content_type {
261 local_var_req_builder = local_var_req_builder.query(&[("httpBody.contentType", &local_var_str.to_string())]);
262 }
263 if let Some(ref local_var_str) = http_body_period_data {
264 local_var_req_builder = local_var_req_builder.query(&[("httpBody.data", &local_var_str.to_string())]);
265 }
266 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
268 }
269
270 let local_var_req = local_var_req_builder.build()?;
271 let local_var_resp = local_var_client.execute(local_var_req)?;
272
273 let local_var_status = local_var_resp.status();
274 let local_var_content = local_var_resp.text()?;
275
276 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
277 serde_json::from_str(&local_var_content).map_err(Error::from)
278 } else {
279 let local_var_entity: Option<UserServiceGetUserAvatarBinaryError> = serde_json::from_str(&local_var_content).ok();
280 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
281 Err(Error::ResponseError(local_var_error))
282 }
283}
284
285pub fn user_service_get_user_setting(configuration: &configuration::Configuration, name: &str) -> Result<models::Apiv1UserSetting, Error<UserServiceGetUserSettingError>> {
286 let local_var_configuration = configuration;
287
288 let local_var_client = &local_var_configuration.client;
289
290 let local_var_uri_str = format!("{}/api/v1/{name}/setting", local_var_configuration.base_path, name=crate::apis::urlencode(name));
291 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
292
293 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
294 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
295 }
296
297 let local_var_req = local_var_req_builder.build()?;
298 let local_var_resp = local_var_client.execute(local_var_req)?;
299
300 let local_var_status = local_var_resp.status();
301 let local_var_content = local_var_resp.text()?;
302
303 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
304 serde_json::from_str(&local_var_content).map_err(Error::from)
305 } else {
306 let local_var_entity: Option<UserServiceGetUserSettingError> = serde_json::from_str(&local_var_content).ok();
307 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
308 Err(Error::ResponseError(local_var_error))
309 }
310}
311
312pub fn user_service_list_user_access_tokens(configuration: &configuration::Configuration, name: &str) -> Result<models::V1ListUserAccessTokensResponse, Error<UserServiceListUserAccessTokensError>> {
313 let local_var_configuration = configuration;
314
315 let local_var_client = &local_var_configuration.client;
316
317 let local_var_uri_str = format!("{}/api/v1/{name}/access_tokens", local_var_configuration.base_path, name=crate::apis::urlencode(name));
318 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
319
320 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
321 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
322 }
323
324 let local_var_req = local_var_req_builder.build()?;
325 let local_var_resp = local_var_client.execute(local_var_req)?;
326
327 let local_var_status = local_var_resp.status();
328 let local_var_content = local_var_resp.text()?;
329
330 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
331 serde_json::from_str(&local_var_content).map_err(Error::from)
332 } else {
333 let local_var_entity: Option<UserServiceListUserAccessTokensError> = serde_json::from_str(&local_var_content).ok();
334 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
335 Err(Error::ResponseError(local_var_error))
336 }
337}
338
339pub fn user_service_list_users(configuration: &configuration::Configuration, ) -> Result<models::V1ListUsersResponse, Error<UserServiceListUsersError>> {
340 let local_var_configuration = configuration;
341
342 let local_var_client = &local_var_configuration.client;
343
344 let local_var_uri_str = format!("{}/api/v1/users", local_var_configuration.base_path);
345 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
346
347 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
348 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
349 }
350
351 let local_var_req = local_var_req_builder.build()?;
352 let local_var_resp = local_var_client.execute(local_var_req)?;
353
354 let local_var_status = local_var_resp.status();
355 let local_var_content = local_var_resp.text()?;
356
357 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
358 serde_json::from_str(&local_var_content).map_err(Error::from)
359 } else {
360 let local_var_entity: Option<UserServiceListUsersError> = serde_json::from_str(&local_var_content).ok();
361 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
362 Err(Error::ResponseError(local_var_error))
363 }
364}
365
366pub fn user_service_search_users(configuration: &configuration::Configuration, filter: Option<&str>) -> Result<models::V1SearchUsersResponse, Error<UserServiceSearchUsersError>> {
367 let local_var_configuration = configuration;
368
369 let local_var_client = &local_var_configuration.client;
370
371 let local_var_uri_str = format!("{}/api/v1/users:search", local_var_configuration.base_path);
372 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
373
374 if let Some(ref local_var_str) = filter {
375 local_var_req_builder = local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
376 }
377 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
378 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
379 }
380
381 let local_var_req = local_var_req_builder.build()?;
382 let local_var_resp = local_var_client.execute(local_var_req)?;
383
384 let local_var_status = local_var_resp.status();
385 let local_var_content = local_var_resp.text()?;
386
387 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
388 serde_json::from_str(&local_var_content).map_err(Error::from)
389 } else {
390 let local_var_entity: Option<UserServiceSearchUsersError> = serde_json::from_str(&local_var_content).ok();
391 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
392 Err(Error::ResponseError(local_var_error))
393 }
394}
395
396pub fn user_service_update_user(configuration: &configuration::Configuration, user_name: &str, user: models::UserServiceUpdateUserRequest) -> Result<models::V1User, Error<UserServiceUpdateUserError>> {
397 let local_var_configuration = configuration;
398
399 let local_var_client = &local_var_configuration.client;
400
401 let local_var_uri_str = format!("{}/api/v1/{user_name}", local_var_configuration.base_path, user_name=crate::apis::urlencode(user_name));
402 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
403
404 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
405 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
406 }
407 local_var_req_builder = local_var_req_builder.json(&user);
408
409 let local_var_req = local_var_req_builder.build()?;
410 let local_var_resp = local_var_client.execute(local_var_req)?;
411
412 let local_var_status = local_var_resp.status();
413 let local_var_content = local_var_resp.text()?;
414
415 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
416 serde_json::from_str(&local_var_content).map_err(Error::from)
417 } else {
418 let local_var_entity: Option<UserServiceUpdateUserError> = serde_json::from_str(&local_var_content).ok();
419 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
420 Err(Error::ResponseError(local_var_error))
421 }
422}
423
424pub fn user_service_update_user_setting(configuration: &configuration::Configuration, setting_name: &str, setting: models::UserServiceUpdateUserSettingRequest) -> Result<models::Apiv1UserSetting, Error<UserServiceUpdateUserSettingError>> {
425 let local_var_configuration = configuration;
426
427 let local_var_client = &local_var_configuration.client;
428
429 let local_var_uri_str = format!("{}/api/v1/{setting_name}", local_var_configuration.base_path, setting_name=crate::apis::urlencode(setting_name));
430 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
431
432 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
433 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
434 }
435 local_var_req_builder = local_var_req_builder.json(&setting);
436
437 let local_var_req = local_var_req_builder.build()?;
438 let local_var_resp = local_var_client.execute(local_var_req)?;
439
440 let local_var_status = local_var_resp.status();
441 let local_var_content = local_var_resp.text()?;
442
443 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
444 serde_json::from_str(&local_var_content).map_err(Error::from)
445 } else {
446 let local_var_entity: Option<UserServiceUpdateUserSettingError> = serde_json::from_str(&local_var_content).ok();
447 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
448 Err(Error::ResponseError(local_var_error))
449 }
450}
451