mattermost_rust_client/apis/
shared_channels_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 GetAllSharedChannelsError {
22 Status400(crate::models::AppError),
23 Status401(crate::models::AppError),
24 Status403(crate::models::AppError),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum GetRemoteClusterInfoError {
32 Status400(crate::models::AppError),
33 Status401(crate::models::AppError),
34 Status403(crate::models::AppError),
35 Status404(crate::models::AppError),
36 UnknownValue(serde_json::Value),
37}
38
39
40pub async fn get_all_shared_channels(configuration: &configuration::Configuration, team_id: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<crate::models::SharedChannel>, Error<GetAllSharedChannelsError>> {
42 let local_var_configuration = configuration;
43
44 let local_var_client = &local_var_configuration.client;
45
46 let local_var_uri_str = format!("{}/sharedchannels/{team_id}", local_var_configuration.base_path, team_id=crate::apis::urlencode(team_id));
47 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
48
49 if let Some(ref local_var_str) = page {
50 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
51 }
52 if let Some(ref local_var_str) = per_page {
53 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
54 }
55 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57 }
58 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
59 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60 };
61
62 let local_var_req = local_var_req_builder.build()?;
63 let local_var_resp = local_var_client.execute(local_var_req).await?;
64
65 let local_var_status = local_var_resp.status();
66 let local_var_content = local_var_resp.text().await?;
67
68 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
69 serde_json::from_str(&local_var_content).map_err(Error::from)
70 } else {
71 let local_var_entity: Option<GetAllSharedChannelsError> = serde_json::from_str(&local_var_content).ok();
72 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
73 Err(Error::ResponseError(local_var_error))
74 }
75}
76
77pub async fn get_remote_cluster_info(configuration: &configuration::Configuration, remote_id: &str) -> Result<crate::models::RemoteClusterInfo, Error<GetRemoteClusterInfoError>> {
79 let local_var_configuration = configuration;
80
81 let local_var_client = &local_var_configuration.client;
82
83 let local_var_uri_str = format!("{}/sharedchannels/remote_info/{remote_id}", local_var_configuration.base_path, remote_id=crate::apis::urlencode(remote_id));
84 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
85
86 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
87 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
88 }
89 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
90 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
91 };
92
93 let local_var_req = local_var_req_builder.build()?;
94 let local_var_resp = local_var_client.execute(local_var_req).await?;
95
96 let local_var_status = local_var_resp.status();
97 let local_var_content = local_var_resp.text().await?;
98
99 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
100 serde_json::from_str(&local_var_content).map_err(Error::from)
101 } else {
102 let local_var_entity: Option<GetRemoteClusterInfoError> = serde_json::from_str(&local_var_content).ok();
103 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
104 Err(Error::ResponseError(local_var_error))
105 }
106}
107