casdoor_sdk/apis/
provider_api.rs1
2
3use reqwest;
4
5use crate::{apis::ResponseContent, models};
6use super::{Error, configuration};
7
8#[derive(Clone, Debug)]
10pub struct ApiControllerAddProviderParams {
11 pub body: models::Provider
13}
14
15#[derive(Clone, Debug)]
17pub struct ApiControllerDeleteProviderParams {
18 pub body: models::Provider
20}
21
22#[derive(Clone, Debug)]
24pub struct ApiControllerGetProviderParams {
25 pub id: String
27}
28
29#[derive(Clone, Debug)]
31pub struct ApiControllerGetProvidersParams {
32 pub owner: String
34}
35
36#[derive(Clone, Debug)]
38pub struct ApiControllerUpdateProviderParams {
39 pub id: String,
41 pub body: models::Provider
43}
44
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ApiControllerAddProviderError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ApiControllerDeleteProviderError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ApiControllerGetGlobalProvidersError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ApiControllerGetProviderError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ApiControllerGetProvidersError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum ApiControllerUpdateProviderError {
85 UnknownValue(serde_json::Value),
86}
87
88
89pub async fn add_provider(configuration: &configuration::Configuration, params: ApiControllerAddProviderParams) -> Result<models::ControllersResponse, Error<ApiControllerAddProviderError>> {
91 let local_var_configuration = configuration;
92
93 let body = params.body;
95
96
97 let local_var_client = &local_var_configuration.client;
98
99 let local_var_uri_str = format!("{}/api/add-provider", local_var_configuration.base_path);
100 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
101
102 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
103 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
104 }
105 local_var_req_builder = local_var_req_builder.json(&body);
106
107 let local_var_req = local_var_req_builder.build()?;
108 let local_var_resp = local_var_client.execute(local_var_req).await?;
109
110 let local_var_status = local_var_resp.status();
111 let local_var_content = local_var_resp.text().await?;
112
113 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
114 serde_json::from_str(&local_var_content).map_err(Error::from)
115 } else {
116 let local_var_entity: Option<ApiControllerAddProviderError> = serde_json::from_str(&local_var_content).ok();
117 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
118 Err(Error::ResponseError(local_var_error))
119 }
120}
121
122pub async fn delete_provider(configuration: &configuration::Configuration, params: ApiControllerDeleteProviderParams) -> Result<models::ControllersResponse, Error<ApiControllerDeleteProviderError>> {
124 let local_var_configuration = configuration;
125
126 let body = params.body;
128
129
130 let local_var_client = &local_var_configuration.client;
131
132 let local_var_uri_str = format!("{}/api/delete-provider", local_var_configuration.base_path);
133 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
134
135 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
136 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
137 }
138 local_var_req_builder = local_var_req_builder.json(&body);
139
140 let local_var_req = local_var_req_builder.build()?;
141 let local_var_resp = local_var_client.execute(local_var_req).await?;
142
143 let local_var_status = local_var_resp.status();
144 let local_var_content = local_var_resp.text().await?;
145
146 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
147 serde_json::from_str(&local_var_content).map_err(Error::from)
148 } else {
149 let local_var_entity: Option<ApiControllerDeleteProviderError> = serde_json::from_str(&local_var_content).ok();
150 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
151 Err(Error::ResponseError(local_var_error))
152 }
153}
154
155pub async fn get_global_providers(configuration: &configuration::Configuration) -> Result<Vec<models::Provider>, Error<ApiControllerGetGlobalProvidersError>> {
157 let local_var_configuration = configuration;
158
159 let local_var_client = &local_var_configuration.client;
163
164 let local_var_uri_str = format!("{}/api/get-global-providers", local_var_configuration.base_path);
165 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
166
167 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
168 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
169 }
170
171 let local_var_req = local_var_req_builder.build()?;
172 let local_var_resp = local_var_client.execute(local_var_req).await?;
173
174 let local_var_status = local_var_resp.status();
175 let local_var_content = local_var_resp.text().await?;
176
177 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
178 serde_json::from_str(&local_var_content).map_err(Error::from)
179 } else {
180 let local_var_entity: Option<ApiControllerGetGlobalProvidersError> = serde_json::from_str(&local_var_content).ok();
181 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
182 Err(Error::ResponseError(local_var_error))
183 }
184}
185
186pub async fn get_provider(configuration: &configuration::Configuration, params: ApiControllerGetProviderParams) -> Result<models::Provider, Error<ApiControllerGetProviderError>> {
188 let local_var_configuration = configuration;
189
190 let id = params.id;
192
193
194 let local_var_client = &local_var_configuration.client;
195
196 let local_var_uri_str = format!("{}/api/get-provider", local_var_configuration.base_path);
197 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
198
199 local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
200 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
201 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
202 }
203
204 let local_var_req = local_var_req_builder.build()?;
205 let local_var_resp = local_var_client.execute(local_var_req).await?;
206
207 let local_var_status = local_var_resp.status();
208 let local_var_content = local_var_resp.text().await?;
209
210 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
211 serde_json::from_str(&local_var_content).map_err(Error::from)
212 } else {
213 let local_var_entity: Option<ApiControllerGetProviderError> = serde_json::from_str(&local_var_content).ok();
214 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
215 Err(Error::ResponseError(local_var_error))
216 }
217}
218
219pub async fn get_providers(configuration: &configuration::Configuration, params: ApiControllerGetProvidersParams) -> Result<Vec<models::Provider>, Error<ApiControllerGetProvidersError>> {
221 let local_var_configuration = configuration;
222
223 let owner = params.owner;
225
226
227 let local_var_client = &local_var_configuration.client;
228
229 let local_var_uri_str = format!("{}/api/get-providers", local_var_configuration.base_path);
230 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
231
232 local_var_req_builder = local_var_req_builder.query(&[("owner", &owner.to_string())]);
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).await?;
239
240 let local_var_status = local_var_resp.status();
241 let local_var_content = local_var_resp.text().await?;
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<ApiControllerGetProvidersError> = 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 async fn update_provider(configuration: &configuration::Configuration, params: ApiControllerUpdateProviderParams) -> Result<models::ControllersResponse, Error<ApiControllerUpdateProviderError>> {
254 let local_var_configuration = configuration;
255
256 let id = params.id;
258 let body = params.body;
259
260
261 let local_var_client = &local_var_configuration.client;
262
263 let local_var_uri_str = format!("{}/api/update-provider", local_var_configuration.base_path);
264 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
265
266 local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
267 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
268 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
269 }
270 local_var_req_builder = local_var_req_builder.json(&body);
271
272 let local_var_req = local_var_req_builder.build()?;
273 let local_var_resp = local_var_client.execute(local_var_req).await?;
274
275 let local_var_status = local_var_resp.status();
276 let local_var_content = local_var_resp.text().await?;
277
278 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
279 serde_json::from_str(&local_var_content).map_err(Error::from)
280 } else {
281 let local_var_entity: Option<ApiControllerUpdateProviderError> = serde_json::from_str(&local_var_content).ok();
282 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
283 Err(Error::ResponseError(local_var_error))
284 }
285}
286