1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ProjectsCreateError {
20 Status400(serde_json::Value),
21 Status401(serde_json::Value),
22 Status403(serde_json::Value),
23 Status404(serde_json::Value),
24 Status405(serde_json::Value),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum ProjectsCreateApiKeyError {
32 Status400(serde_json::Value),
33 Status401(serde_json::Value),
34 Status403(serde_json::Value),
35 Status404(serde_json::Value),
36 Status405(serde_json::Value),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum ProjectsDeleteError {
44 Status400(serde_json::Value),
45 Status401(serde_json::Value),
46 Status403(serde_json::Value),
47 Status404(serde_json::Value),
48 Status405(serde_json::Value),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum ProjectsDeleteApiKeyError {
56 Status400(serde_json::Value),
57 Status401(serde_json::Value),
58 Status403(serde_json::Value),
59 Status404(serde_json::Value),
60 Status405(serde_json::Value),
61 UnknownValue(serde_json::Value),
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum ProjectsGetError {
68 Status400(serde_json::Value),
69 Status401(serde_json::Value),
70 Status403(serde_json::Value),
71 Status404(serde_json::Value),
72 Status405(serde_json::Value),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum ProjectsGetApiKeysError {
80 Status400(serde_json::Value),
81 Status401(serde_json::Value),
82 Status403(serde_json::Value),
83 Status404(serde_json::Value),
84 Status405(serde_json::Value),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ProjectsUpdateError {
92 Status400(serde_json::Value),
93 Status401(serde_json::Value),
94 Status403(serde_json::Value),
95 Status404(serde_json::Value),
96 Status405(serde_json::Value),
97 UnknownValue(serde_json::Value),
98}
99
100#[bon::builder]
102pub async fn projects_create(
103 configuration: &configuration::Configuration,
104 projects_create_request: models::ProjectsCreateRequest,
105) -> Result<models::Project, Error<ProjectsCreateError>> {
106 let p_body_projects_create_request = projects_create_request;
108
109 let uri_str = format!("{}/api/public/projects", configuration.base_path);
110 let mut req_builder = configuration
111 .client
112 .request(reqwest::Method::POST, &uri_str);
113
114 if let Some(ref user_agent) = configuration.user_agent {
115 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116 }
117 if let Some(ref auth_conf) = configuration.basic_auth {
118 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
119 };
120 req_builder = req_builder.json(&p_body_projects_create_request);
121
122 let req = req_builder.build()?;
123 let resp = configuration.client.execute(req).await?;
124
125 let status = resp.status();
126 let content_type = resp
127 .headers()
128 .get("content-type")
129 .and_then(|v| v.to_str().ok())
130 .unwrap_or("application/octet-stream");
131 let content_type = super::ContentType::from(content_type);
132
133 if !status.is_client_error() && !status.is_server_error() {
134 let content = resp.text().await?;
135 match content_type {
136 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
137 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
138 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::Project`")))),
139 }
140 } else {
141 let content = resp.text().await?;
142 let entity: Option<ProjectsCreateError> = serde_json::from_str(&content).ok();
143 Err(Error::ResponseError(ResponseContent {
144 status,
145 content,
146 entity,
147 }))
148 }
149}
150
151#[bon::builder]
153pub async fn projects_create_api_key(
154 configuration: &configuration::Configuration,
155 project_id: &str,
156 projects_create_api_key_request: models::ProjectsCreateApiKeyRequest,
157) -> Result<models::ApiKeyResponse, Error<ProjectsCreateApiKeyError>> {
158 let p_path_project_id = project_id;
160 let p_body_projects_create_api_key_request = projects_create_api_key_request;
161
162 let uri_str = format!(
163 "{}/api/public/projects/{projectId}/apiKeys",
164 configuration.base_path,
165 projectId = crate::apis::urlencode(p_path_project_id)
166 );
167 let mut req_builder = configuration
168 .client
169 .request(reqwest::Method::POST, &uri_str);
170
171 if let Some(ref user_agent) = configuration.user_agent {
172 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
173 }
174 if let Some(ref auth_conf) = configuration.basic_auth {
175 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
176 };
177 req_builder = req_builder.json(&p_body_projects_create_api_key_request);
178
179 let req = req_builder.build()?;
180 let resp = configuration.client.execute(req).await?;
181
182 let status = resp.status();
183 let content_type = resp
184 .headers()
185 .get("content-type")
186 .and_then(|v| v.to_str().ok())
187 .unwrap_or("application/octet-stream");
188 let content_type = super::ContentType::from(content_type);
189
190 if !status.is_client_error() && !status.is_server_error() {
191 let content = resp.text().await?;
192 match content_type {
193 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
194 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyResponse`"))),
195 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::ApiKeyResponse`")))),
196 }
197 } else {
198 let content = resp.text().await?;
199 let entity: Option<ProjectsCreateApiKeyError> = serde_json::from_str(&content).ok();
200 Err(Error::ResponseError(ResponseContent {
201 status,
202 content,
203 entity,
204 }))
205 }
206}
207
208#[bon::builder]
210pub async fn projects_delete(
211 configuration: &configuration::Configuration,
212 project_id: &str,
213) -> Result<models::ProjectDeletionResponse, Error<ProjectsDeleteError>> {
214 let p_path_project_id = project_id;
216
217 let uri_str = format!(
218 "{}/api/public/projects/{projectId}",
219 configuration.base_path,
220 projectId = crate::apis::urlencode(p_path_project_id)
221 );
222 let mut req_builder = configuration
223 .client
224 .request(reqwest::Method::DELETE, &uri_str);
225
226 if let Some(ref user_agent) = configuration.user_agent {
227 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
228 }
229 if let Some(ref auth_conf) = configuration.basic_auth {
230 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
231 };
232
233 let req = req_builder.build()?;
234 let resp = configuration.client.execute(req).await?;
235
236 let status = resp.status();
237 let content_type = resp
238 .headers()
239 .get("content-type")
240 .and_then(|v| v.to_str().ok())
241 .unwrap_or("application/octet-stream");
242 let content_type = super::ContentType::from(content_type);
243
244 if !status.is_client_error() && !status.is_server_error() {
245 let content = resp.text().await?;
246 match content_type {
247 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
248 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectDeletionResponse`"))),
249 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::ProjectDeletionResponse`")))),
250 }
251 } else {
252 let content = resp.text().await?;
253 let entity: Option<ProjectsDeleteError> = serde_json::from_str(&content).ok();
254 Err(Error::ResponseError(ResponseContent {
255 status,
256 content,
257 entity,
258 }))
259 }
260}
261
262#[bon::builder]
264pub async fn projects_delete_api_key(
265 configuration: &configuration::Configuration,
266 project_id: &str,
267 api_key_id: &str,
268) -> Result<models::ApiKeyDeletionResponse, Error<ProjectsDeleteApiKeyError>> {
269 let p_path_project_id = project_id;
271 let p_path_api_key_id = api_key_id;
272
273 let uri_str = format!(
274 "{}/api/public/projects/{projectId}/apiKeys/{apiKeyId}",
275 configuration.base_path,
276 projectId = crate::apis::urlencode(p_path_project_id),
277 apiKeyId = crate::apis::urlencode(p_path_api_key_id)
278 );
279 let mut req_builder = configuration
280 .client
281 .request(reqwest::Method::DELETE, &uri_str);
282
283 if let Some(ref user_agent) = configuration.user_agent {
284 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
285 }
286 if let Some(ref auth_conf) = configuration.basic_auth {
287 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
288 };
289
290 let req = req_builder.build()?;
291 let resp = configuration.client.execute(req).await?;
292
293 let status = resp.status();
294 let content_type = resp
295 .headers()
296 .get("content-type")
297 .and_then(|v| v.to_str().ok())
298 .unwrap_or("application/octet-stream");
299 let content_type = super::ContentType::from(content_type);
300
301 if !status.is_client_error() && !status.is_server_error() {
302 let content = resp.text().await?;
303 match content_type {
304 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
305 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyDeletionResponse`"))),
306 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::ApiKeyDeletionResponse`")))),
307 }
308 } else {
309 let content = resp.text().await?;
310 let entity: Option<ProjectsDeleteApiKeyError> = serde_json::from_str(&content).ok();
311 Err(Error::ResponseError(ResponseContent {
312 status,
313 content,
314 entity,
315 }))
316 }
317}
318
319#[bon::builder]
321pub async fn projects_get(
322 configuration: &configuration::Configuration,
323) -> Result<models::Projects, Error<ProjectsGetError>> {
324 let uri_str = format!("{}/api/public/projects", configuration.base_path);
325 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
326
327 if let Some(ref user_agent) = configuration.user_agent {
328 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
329 }
330 if let Some(ref auth_conf) = configuration.basic_auth {
331 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
332 };
333
334 let req = req_builder.build()?;
335 let resp = configuration.client.execute(req).await?;
336
337 let status = resp.status();
338 let content_type = resp
339 .headers()
340 .get("content-type")
341 .and_then(|v| v.to_str().ok())
342 .unwrap_or("application/octet-stream");
343 let content_type = super::ContentType::from(content_type);
344
345 if !status.is_client_error() && !status.is_server_error() {
346 let content = resp.text().await?;
347 match content_type {
348 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
349 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Projects`"))),
350 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::Projects`")))),
351 }
352 } else {
353 let content = resp.text().await?;
354 let entity: Option<ProjectsGetError> = serde_json::from_str(&content).ok();
355 Err(Error::ResponseError(ResponseContent {
356 status,
357 content,
358 entity,
359 }))
360 }
361}
362
363#[bon::builder]
365pub async fn projects_get_api_keys(
366 configuration: &configuration::Configuration,
367 project_id: &str,
368) -> Result<models::ApiKeyList, Error<ProjectsGetApiKeysError>> {
369 let p_path_project_id = project_id;
371
372 let uri_str = format!(
373 "{}/api/public/projects/{projectId}/apiKeys",
374 configuration.base_path,
375 projectId = crate::apis::urlencode(p_path_project_id)
376 );
377 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
378
379 if let Some(ref user_agent) = configuration.user_agent {
380 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
381 }
382 if let Some(ref auth_conf) = configuration.basic_auth {
383 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
384 };
385
386 let req = req_builder.build()?;
387 let resp = configuration.client.execute(req).await?;
388
389 let status = resp.status();
390 let content_type = resp
391 .headers()
392 .get("content-type")
393 .and_then(|v| v.to_str().ok())
394 .unwrap_or("application/octet-stream");
395 let content_type = super::ContentType::from(content_type);
396
397 if !status.is_client_error() && !status.is_server_error() {
398 let content = resp.text().await?;
399 match content_type {
400 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
401 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiKeyList`"))),
402 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::ApiKeyList`")))),
403 }
404 } else {
405 let content = resp.text().await?;
406 let entity: Option<ProjectsGetApiKeysError> = serde_json::from_str(&content).ok();
407 Err(Error::ResponseError(ResponseContent {
408 status,
409 content,
410 entity,
411 }))
412 }
413}
414
415#[bon::builder]
417pub async fn projects_update(
418 configuration: &configuration::Configuration,
419 project_id: &str,
420 projects_create_request: models::ProjectsCreateRequest,
421) -> Result<models::Project, Error<ProjectsUpdateError>> {
422 let p_path_project_id = project_id;
424 let p_body_projects_create_request = projects_create_request;
425
426 let uri_str = format!(
427 "{}/api/public/projects/{projectId}",
428 configuration.base_path,
429 projectId = crate::apis::urlencode(p_path_project_id)
430 );
431 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
432
433 if let Some(ref user_agent) = configuration.user_agent {
434 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
435 }
436 if let Some(ref auth_conf) = configuration.basic_auth {
437 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
438 };
439 req_builder = req_builder.json(&p_body_projects_create_request);
440
441 let req = req_builder.build()?;
442 let resp = configuration.client.execute(req).await?;
443
444 let status = resp.status();
445 let content_type = resp
446 .headers()
447 .get("content-type")
448 .and_then(|v| v.to_str().ok())
449 .unwrap_or("application/octet-stream");
450 let content_type = super::ContentType::from(content_type);
451
452 if !status.is_client_error() && !status.is_server_error() {
453 let content = resp.text().await?;
454 match content_type {
455 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
456 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
457 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::Project`")))),
458 }
459 } else {
460 let content = resp.text().await?;
461 let entity: Option<ProjectsUpdateError> = serde_json::from_str(&content).ok();
462 Err(Error::ResponseError(ResponseContent {
463 status,
464 content,
465 entity,
466 }))
467 }
468}