mattermost_rust_client/apis/
imports_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ListImportsError {
22 Status400(crate::models::AppError),
23 Status401(crate::models::AppError),
24 Status403(crate::models::AppError),
25 Status404(crate::models::AppError),
26 UnknownValue(serde_json::Value),
27}
28
29
30pub async fn list_imports(configuration: &configuration::Configuration, ) -> Result<(), Error<ListImportsError>> {
32 let local_var_configuration = configuration;
33
34 let local_var_client = &local_var_configuration.client;
35
36 let local_var_uri_str = format!("{}/imports", local_var_configuration.base_path);
37 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
38
39 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
40 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
41 }
42 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
43 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
44 };
45
46 let local_var_req = local_var_req_builder.build()?;
47 let local_var_resp = local_var_client.execute(local_var_req).await?;
48
49 let local_var_status = local_var_resp.status();
50 let local_var_content = local_var_resp.text().await?;
51
52 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
53 Ok(())
54 } else {
55 let local_var_entity: Option<ListImportsError> = serde_json::from_str(&local_var_content).ok();
56 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
57 Err(Error::ResponseError(local_var_error))
58 }
59}
60