harbor_api/apis/
user_api.rs

1/*
2 * Harbor API
3 *
4 * These APIs provide services for manipulating Harbor project.
5 *
6 * The version of the OpenAPI document: 2.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_user`]
18#[derive(Clone, Debug)]
19pub struct CreateUserParams {
20    /// The new user
21    pub user_req: models::UserCreationReq,
22    /// An unique ID for the request
23    pub x_request_id: Option<String>
24}
25
26/// struct for passing parameters to the method [`delete_user`]
27#[derive(Clone, Debug)]
28pub struct DeleteUserParams {
29    /// User ID for marking as to be removed.
30    pub user_id: i32,
31    /// An unique ID for the request
32    pub x_request_id: Option<String>
33}
34
35/// struct for passing parameters to the method [`get_current_user_info`]
36#[derive(Clone, Debug)]
37pub struct GetCurrentUserInfoParams {
38    /// An unique ID for the request
39    pub x_request_id: Option<String>
40}
41
42/// struct for passing parameters to the method [`get_current_user_permissions`]
43#[derive(Clone, Debug)]
44pub struct GetCurrentUserPermissionsParams {
45    /// An unique ID for the request
46    pub x_request_id: Option<String>,
47    /// The scope for the permission
48    pub scope: Option<String>,
49    /// If true, the resources in the response are relative to the scope, eg for resource '/project/1/repository' if relative is 'true' then the resource in response will be 'repository'. 
50    pub relative: Option<bool>
51}
52
53/// struct for passing parameters to the method [`get_user`]
54#[derive(Clone, Debug)]
55pub struct GetUserParams {
56    pub user_id: i32,
57    /// An unique ID for the request
58    pub x_request_id: Option<String>
59}
60
61/// struct for passing parameters to the method [`list_users`]
62#[derive(Clone, Debug)]
63pub struct ListUsersParams {
64    /// An unique ID for the request
65    pub x_request_id: Option<String>,
66    /// Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max]
67    pub q: Option<String>,
68    /// Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending order and field2 in descending order with \"sort=field1,-field2\"
69    pub sort: Option<String>,
70    /// The page number
71    pub page: Option<i64>,
72    /// The size of per page
73    pub page_size: Option<i64>
74}
75
76/// struct for passing parameters to the method [`search_users`]
77#[derive(Clone, Debug)]
78pub struct SearchUsersParams {
79    /// Username for filtering results.
80    pub username: String,
81    /// An unique ID for the request
82    pub x_request_id: Option<String>,
83    /// The page number
84    pub page: Option<i64>,
85    /// The size of per page
86    pub page_size: Option<i64>
87}
88
89/// struct for passing parameters to the method [`set_cli_secret`]
90#[derive(Clone, Debug)]
91pub struct SetCliSecretParams {
92    /// User ID
93    pub user_id: i32,
94    pub secret: models::OidcCliSecretReq,
95    /// An unique ID for the request
96    pub x_request_id: Option<String>
97}
98
99/// struct for passing parameters to the method [`set_user_sys_admin`]
100#[derive(Clone, Debug)]
101pub struct SetUserSysAdminParams {
102    pub user_id: i32,
103    /// Toggle a user to admin or not.
104    pub sysadmin_flag: models::UserSysAdminFlag,
105    /// An unique ID for the request
106    pub x_request_id: Option<String>
107}
108
109/// struct for passing parameters to the method [`update_user_password`]
110#[derive(Clone, Debug)]
111pub struct UpdateUserPasswordParams {
112    pub user_id: i32,
113    /// Password to be updated, the attribute 'old_password' is optional when the API is called by the system administrator.
114    pub password: models::PasswordReq,
115    /// An unique ID for the request
116    pub x_request_id: Option<String>
117}
118
119/// struct for passing parameters to the method [`update_user_profile`]
120#[derive(Clone, Debug)]
121pub struct UpdateUserProfileParams {
122    /// Registered user ID
123    pub user_id: i32,
124    /// Only email, realname and comment can be modified.
125    pub profile: models::UserProfile,
126    /// An unique ID for the request
127    pub x_request_id: Option<String>
128}
129
130
131/// struct for typed errors of method [`create_user`]
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum CreateUserError {
135    Status400(models::Errors),
136    Status401(models::Errors),
137    Status403(),
138    Status409(models::Errors),
139    Status500(models::Errors),
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`delete_user`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum DeleteUserError {
147    Status401(models::Errors),
148    Status403(models::Errors),
149    Status404(models::Errors),
150    Status500(models::Errors),
151    UnknownValue(serde_json::Value),
152}
153
154/// struct for typed errors of method [`get_current_user_info`]
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum GetCurrentUserInfoError {
158    Status401(models::Errors),
159    Status500(models::Errors),
160    UnknownValue(serde_json::Value),
161}
162
163/// struct for typed errors of method [`get_current_user_permissions`]
164#[derive(Debug, Clone, Serialize, Deserialize)]
165#[serde(untagged)]
166pub enum GetCurrentUserPermissionsError {
167    Status401(),
168    Status500(),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`get_user`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum GetUserError {
176    Status401(models::Errors),
177    Status403(models::Errors),
178    Status404(models::Errors),
179    Status500(models::Errors),
180    UnknownValue(serde_json::Value),
181}
182
183/// struct for typed errors of method [`list_users`]
184#[derive(Debug, Clone, Serialize, Deserialize)]
185#[serde(untagged)]
186pub enum ListUsersError {
187    Status401(models::Errors),
188    Status403(models::Errors),
189    Status500(models::Errors),
190    UnknownValue(serde_json::Value),
191}
192
193/// struct for typed errors of method [`search_users`]
194#[derive(Debug, Clone, Serialize, Deserialize)]
195#[serde(untagged)]
196pub enum SearchUsersError {
197    Status401(models::Errors),
198    Status500(models::Errors),
199    UnknownValue(serde_json::Value),
200}
201
202/// struct for typed errors of method [`set_cli_secret`]
203#[derive(Debug, Clone, Serialize, Deserialize)]
204#[serde(untagged)]
205pub enum SetCliSecretError {
206    Status400(),
207    Status401(models::Errors),
208    Status403(models::Errors),
209    Status404(models::Errors),
210    Status412(),
211    Status500(models::Errors),
212    UnknownValue(serde_json::Value),
213}
214
215/// struct for typed errors of method [`set_user_sys_admin`]
216#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum SetUserSysAdminError {
219    Status401(models::Errors),
220    Status403(models::Errors),
221    Status404(models::Errors),
222    Status500(),
223    UnknownValue(serde_json::Value),
224}
225
226/// struct for typed errors of method [`update_user_password`]
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum UpdateUserPasswordError {
230    Status400(),
231    Status401(models::Errors),
232    Status403(),
233    Status500(models::Errors),
234    UnknownValue(serde_json::Value),
235}
236
237/// struct for typed errors of method [`update_user_profile`]
238#[derive(Debug, Clone, Serialize, Deserialize)]
239#[serde(untagged)]
240pub enum UpdateUserProfileError {
241    Status401(models::Errors),
242    Status403(models::Errors),
243    Status404(models::Errors),
244    Status500(models::Errors),
245    UnknownValue(serde_json::Value),
246}
247
248
249/// This API can be used only when the authentication mode is for local DB.  When self registration is disabled.
250pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result<(), Error<CreateUserError>> {
251
252    let uri_str = format!("{}/users", configuration.base_path);
253    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
254
255    if let Some(ref user_agent) = configuration.user_agent {
256        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
257    }
258    if let Some(param_value) = params.x_request_id {
259        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
260    }
261    if let Some(ref auth_conf) = configuration.basic_auth {
262        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
263    };
264    req_builder = req_builder.json(&params.user_req);
265
266    let req = req_builder.build()?;
267    let resp = configuration.client.execute(req).await?;
268
269    let status = resp.status();
270
271    if !status.is_client_error() && !status.is_server_error() {
272        Ok(())
273    } else {
274        let content = resp.text().await?;
275        let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
276        Err(Error::ResponseError(ResponseContent { status, content, entity }))
277    }
278}
279
280/// This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB. 
281pub async fn delete_user(configuration: &configuration::Configuration, params: DeleteUserParams) -> Result<(), Error<DeleteUserError>> {
282
283    let uri_str = format!("{}/users/{user_id}", configuration.base_path, user_id=params.user_id);
284    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
285
286    if let Some(ref user_agent) = configuration.user_agent {
287        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
288    }
289    if let Some(param_value) = params.x_request_id {
290        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
291    }
292    if let Some(ref auth_conf) = configuration.basic_auth {
293        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
294    };
295
296    let req = req_builder.build()?;
297    let resp = configuration.client.execute(req).await?;
298
299    let status = resp.status();
300
301    if !status.is_client_error() && !status.is_server_error() {
302        Ok(())
303    } else {
304        let content = resp.text().await?;
305        let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
306        Err(Error::ResponseError(ResponseContent { status, content, entity }))
307    }
308}
309
310pub async fn get_current_user_info(configuration: &configuration::Configuration, params: GetCurrentUserInfoParams) -> Result<models::UserResp, Error<GetCurrentUserInfoError>> {
311
312    let uri_str = format!("{}/users/current", configuration.base_path);
313    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
314
315    if let Some(ref user_agent) = configuration.user_agent {
316        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
317    }
318    if let Some(param_value) = params.x_request_id {
319        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
320    }
321    if let Some(ref auth_conf) = configuration.basic_auth {
322        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
323    };
324
325    let req = req_builder.build()?;
326    let resp = configuration.client.execute(req).await?;
327
328    let status = resp.status();
329    let content_type = resp
330        .headers()
331        .get("content-type")
332        .and_then(|v| v.to_str().ok())
333        .unwrap_or("application/octet-stream");
334    let content_type = super::ContentType::from(content_type);
335
336    if !status.is_client_error() && !status.is_server_error() {
337        let content = resp.text().await?;
338        match content_type {
339            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
340            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserResp`"))),
341            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserResp`")))),
342        }
343    } else {
344        let content = resp.text().await?;
345        let entity: Option<GetCurrentUserInfoError> = serde_json::from_str(&content).ok();
346        Err(Error::ResponseError(ResponseContent { status, content, entity }))
347    }
348}
349
350pub async fn get_current_user_permissions(configuration: &configuration::Configuration, params: GetCurrentUserPermissionsParams) -> Result<Vec<models::Permission>, Error<GetCurrentUserPermissionsError>> {
351
352    let uri_str = format!("{}/users/current/permissions", configuration.base_path);
353    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
354
355    if let Some(ref param_value) = params.scope {
356        req_builder = req_builder.query(&[("scope", &param_value.to_string())]);
357    }
358    if let Some(ref param_value) = params.relative {
359        req_builder = req_builder.query(&[("relative", &param_value.to_string())]);
360    }
361    if let Some(ref user_agent) = configuration.user_agent {
362        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
363    }
364    if let Some(param_value) = params.x_request_id {
365        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
366    }
367    if let Some(ref auth_conf) = configuration.basic_auth {
368        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
369    };
370
371    let req = req_builder.build()?;
372    let resp = configuration.client.execute(req).await?;
373
374    let status = resp.status();
375    let content_type = resp
376        .headers()
377        .get("content-type")
378        .and_then(|v| v.to_str().ok())
379        .unwrap_or("application/octet-stream");
380    let content_type = super::ContentType::from(content_type);
381
382    if !status.is_client_error() && !status.is_server_error() {
383        let content = resp.text().await?;
384        match content_type {
385            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
386            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Permission&gt;`"))),
387            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Permission&gt;`")))),
388        }
389    } else {
390        let content = resp.text().await?;
391        let entity: Option<GetCurrentUserPermissionsError> = serde_json::from_str(&content).ok();
392        Err(Error::ResponseError(ResponseContent { status, content, entity }))
393    }
394}
395
396pub async fn get_user(configuration: &configuration::Configuration, params: GetUserParams) -> Result<models::UserResp, Error<GetUserError>> {
397
398    let uri_str = format!("{}/users/{user_id}", configuration.base_path, user_id=params.user_id);
399    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
400
401    if let Some(ref user_agent) = configuration.user_agent {
402        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
403    }
404    if let Some(param_value) = params.x_request_id {
405        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
406    }
407    if let Some(ref auth_conf) = configuration.basic_auth {
408        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
409    };
410
411    let req = req_builder.build()?;
412    let resp = configuration.client.execute(req).await?;
413
414    let status = resp.status();
415    let content_type = resp
416        .headers()
417        .get("content-type")
418        .and_then(|v| v.to_str().ok())
419        .unwrap_or("application/octet-stream");
420    let content_type = super::ContentType::from(content_type);
421
422    if !status.is_client_error() && !status.is_server_error() {
423        let content = resp.text().await?;
424        match content_type {
425            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
426            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserResp`"))),
427            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserResp`")))),
428        }
429    } else {
430        let content = resp.text().await?;
431        let entity: Option<GetUserError> = serde_json::from_str(&content).ok();
432        Err(Error::ResponseError(ResponseContent { status, content, entity }))
433    }
434}
435
436pub async fn list_users(configuration: &configuration::Configuration, params: ListUsersParams) -> Result<Vec<models::UserResp>, Error<ListUsersError>> {
437
438    let uri_str = format!("{}/users", configuration.base_path);
439    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
440
441    if let Some(ref param_value) = params.q {
442        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
443    }
444    if let Some(ref param_value) = params.sort {
445        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
446    }
447    if let Some(ref param_value) = params.page {
448        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
449    }
450    if let Some(ref param_value) = params.page_size {
451        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
452    }
453    if let Some(ref user_agent) = configuration.user_agent {
454        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
455    }
456    if let Some(param_value) = params.x_request_id {
457        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
458    }
459    if let Some(ref auth_conf) = configuration.basic_auth {
460        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
461    };
462
463    let req = req_builder.build()?;
464    let resp = configuration.client.execute(req).await?;
465
466    let status = resp.status();
467    let content_type = resp
468        .headers()
469        .get("content-type")
470        .and_then(|v| v.to_str().ok())
471        .unwrap_or("application/octet-stream");
472    let content_type = super::ContentType::from(content_type);
473
474    if !status.is_client_error() && !status.is_server_error() {
475        let content = resp.text().await?;
476        match content_type {
477            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
478            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UserResp&gt;`"))),
479            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::UserResp&gt;`")))),
480        }
481    } else {
482        let content = resp.text().await?;
483        let entity: Option<ListUsersError> = serde_json::from_str(&content).ok();
484        Err(Error::ResponseError(ResponseContent { status, content, entity }))
485    }
486}
487
488/// This endpoint is to search the users by username.  It's open for all authenticated requests. 
489pub async fn search_users(configuration: &configuration::Configuration, params: SearchUsersParams) -> Result<Vec<models::UserSearchRespItem>, Error<SearchUsersError>> {
490
491    let uri_str = format!("{}/users/search", configuration.base_path);
492    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
493
494    if let Some(ref param_value) = params.page {
495        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
496    }
497    if let Some(ref param_value) = params.page_size {
498        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
499    }
500    req_builder = req_builder.query(&[("username", &params.username.to_string())]);
501    if let Some(ref user_agent) = configuration.user_agent {
502        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
503    }
504    if let Some(param_value) = params.x_request_id {
505        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
506    }
507    if let Some(ref auth_conf) = configuration.basic_auth {
508        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
509    };
510
511    let req = req_builder.build()?;
512    let resp = configuration.client.execute(req).await?;
513
514    let status = resp.status();
515    let content_type = resp
516        .headers()
517        .get("content-type")
518        .and_then(|v| v.to_str().ok())
519        .unwrap_or("application/octet-stream");
520    let content_type = super::ContentType::from(content_type);
521
522    if !status.is_client_error() && !status.is_server_error() {
523        let content = resp.text().await?;
524        match content_type {
525            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
526            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UserSearchRespItem&gt;`"))),
527            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::UserSearchRespItem&gt;`")))),
528        }
529    } else {
530        let content = resp.text().await?;
531        let entity: Option<SearchUsersError> = serde_json::from_str(&content).ok();
532        Err(Error::ResponseError(ResponseContent { status, content, entity }))
533    }
534}
535
536/// This endpoint let user generate a new CLI secret for himself.  This API only works when auth mode is set to 'OIDC'. Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user.
537pub async fn set_cli_secret(configuration: &configuration::Configuration, params: SetCliSecretParams) -> Result<(), Error<SetCliSecretError>> {
538
539    let uri_str = format!("{}/users/{user_id}/cli_secret", configuration.base_path, user_id=params.user_id);
540    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
541
542    if let Some(ref user_agent) = configuration.user_agent {
543        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
544    }
545    if let Some(param_value) = params.x_request_id {
546        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
547    }
548    if let Some(ref auth_conf) = configuration.basic_auth {
549        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
550    };
551    req_builder = req_builder.json(&params.secret);
552
553    let req = req_builder.build()?;
554    let resp = configuration.client.execute(req).await?;
555
556    let status = resp.status();
557
558    if !status.is_client_error() && !status.is_server_error() {
559        Ok(())
560    } else {
561        let content = resp.text().await?;
562        let entity: Option<SetCliSecretError> = serde_json::from_str(&content).ok();
563        Err(Error::ResponseError(ResponseContent { status, content, entity }))
564    }
565}
566
567pub async fn set_user_sys_admin(configuration: &configuration::Configuration, params: SetUserSysAdminParams) -> Result<(), Error<SetUserSysAdminError>> {
568
569    let uri_str = format!("{}/users/{user_id}/sysadmin", configuration.base_path, user_id=params.user_id);
570    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
571
572    if let Some(ref user_agent) = configuration.user_agent {
573        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
574    }
575    if let Some(param_value) = params.x_request_id {
576        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
577    }
578    if let Some(ref auth_conf) = configuration.basic_auth {
579        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
580    };
581    req_builder = req_builder.json(&params.sysadmin_flag);
582
583    let req = req_builder.build()?;
584    let resp = configuration.client.execute(req).await?;
585
586    let status = resp.status();
587
588    if !status.is_client_error() && !status.is_server_error() {
589        Ok(())
590    } else {
591        let content = resp.text().await?;
592        let entity: Option<SetUserSysAdminError> = serde_json::from_str(&content).ok();
593        Err(Error::ResponseError(ResponseContent { status, content, entity }))
594    }
595}
596
597/// This endpoint is for user to update password. Users with the admin role can change any user's password. Regular users can change only their own password. 
598pub async fn update_user_password(configuration: &configuration::Configuration, params: UpdateUserPasswordParams) -> Result<(), Error<UpdateUserPasswordError>> {
599
600    let uri_str = format!("{}/users/{user_id}/password", configuration.base_path, user_id=params.user_id);
601    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
602
603    if let Some(ref user_agent) = configuration.user_agent {
604        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
605    }
606    if let Some(param_value) = params.x_request_id {
607        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
608    }
609    if let Some(ref auth_conf) = configuration.basic_auth {
610        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
611    };
612    req_builder = req_builder.json(&params.password);
613
614    let req = req_builder.build()?;
615    let resp = configuration.client.execute(req).await?;
616
617    let status = resp.status();
618
619    if !status.is_client_error() && !status.is_server_error() {
620        Ok(())
621    } else {
622        let content = resp.text().await?;
623        let entity: Option<UpdateUserPasswordError> = serde_json::from_str(&content).ok();
624        Err(Error::ResponseError(ResponseContent { status, content, entity }))
625    }
626}
627
628pub async fn update_user_profile(configuration: &configuration::Configuration, params: UpdateUserProfileParams) -> Result<(), Error<UpdateUserProfileError>> {
629
630    let uri_str = format!("{}/users/{user_id}", configuration.base_path, user_id=params.user_id);
631    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
632
633    if let Some(ref user_agent) = configuration.user_agent {
634        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
635    }
636    if let Some(param_value) = params.x_request_id {
637        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
638    }
639    if let Some(ref auth_conf) = configuration.basic_auth {
640        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
641    };
642    req_builder = req_builder.json(&params.profile);
643
644    let req = req_builder.build()?;
645    let resp = configuration.client.execute(req).await?;
646
647    let status = resp.status();
648
649    if !status.is_client_error() && !status.is_server_error() {
650        Ok(())
651    } else {
652        let content = resp.text().await?;
653        let entity: Option<UpdateUserProfileError> = serde_json::from_str(&content).ok();
654        Err(Error::ResponseError(ResponseContent { status, content, entity }))
655    }
656}
657