1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateOrganizationError {
22 Status400(models::ErrorGeneric),
23 Status403(models::ErrorGeneric),
24 Status409(models::ErrorGeneric),
25 DefaultResponse(models::ErrorGeneric),
26 UnknownValue(serde_json::Value),
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum CreateProjectError {
33 Status401(models::ErrorGeneric),
34 Status403(models::ErrorGeneric),
35 Status404(models::ErrorGeneric),
36 DefaultResponse(models::ErrorGeneric),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum CreateProjectApiKeyError {
44 DefaultResponse(models::ErrorGeneric),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum DeleteOrganizationError {
52 Status400(models::ErrorGeneric),
53 Status403(models::ErrorGeneric),
54 Status404(models::ErrorGeneric),
55 Status409(models::ErrorGeneric),
56 DefaultResponse(models::ErrorGeneric),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum DeleteProjectApiKeyError {
64 DefaultResponse(models::ErrorGeneric),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum GetOrganizationError {
72 Status400(models::ErrorGeneric),
73 Status403(models::ErrorGeneric),
74 DefaultResponse(models::ErrorGeneric),
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum GetProjectError {
82 Status401(models::ErrorGeneric),
83 Status403(models::ErrorGeneric),
84 Status404(models::ErrorGeneric),
85 DefaultResponse(models::ErrorGeneric),
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum GetProjectMembersError {
93 Status401(models::GenericError),
94 Status406(models::GenericError),
95 DefaultResponse(models::GenericError),
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum ListOrganizationsError {
103 Status400(models::ErrorGeneric),
104 Status403(models::ErrorGeneric),
105 DefaultResponse(models::ErrorGeneric),
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum ListProjectApiKeysError {
113 DefaultResponse(models::ErrorGeneric),
114 UnknownValue(serde_json::Value),
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum ListProjectsError {
121 Status401(models::ErrorGeneric),
122 Status403(models::ErrorGeneric),
123 Status404(models::ErrorGeneric),
124 DefaultResponse(models::ErrorGeneric),
125 UnknownValue(serde_json::Value),
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum PatchProjectError {
132 Status400(models::ErrorGeneric),
133 Status401(models::ErrorGeneric),
134 Status403(models::ErrorGeneric),
135 Status404(models::ErrorGeneric),
136 DefaultResponse(models::ErrorGeneric),
137 UnknownValue(serde_json::Value),
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize)]
142#[serde(untagged)]
143pub enum PatchProjectWithRevisionError {
144 Status400(models::ErrorGeneric),
145 Status401(models::ErrorGeneric),
146 Status403(models::ErrorGeneric),
147 Status404(models::ErrorGeneric),
148 DefaultResponse(models::ErrorGeneric),
149 UnknownValue(serde_json::Value),
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
154#[serde(untagged)]
155pub enum PurgeProjectError {
156 Status401(models::GenericError),
157 Status403(models::GenericError),
158 Status404(models::GenericError),
159 DefaultResponse(models::GenericError),
160 UnknownValue(serde_json::Value),
161}
162
163#[derive(Debug, Clone, Serialize, Deserialize)]
165#[serde(untagged)]
166pub enum RemoveProjectMemberError {
167 Status401(models::GenericError),
168 Status406(models::GenericError),
169 DefaultResponse(models::GenericError),
170 UnknownValue(serde_json::Value),
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum SetProjectError {
177 Status400(models::ErrorGeneric),
178 Status401(models::ErrorGeneric),
179 Status403(models::ErrorGeneric),
180 Status404(models::ErrorGeneric),
181 DefaultResponse(models::ErrorGeneric),
182 UnknownValue(serde_json::Value),
183}
184
185#[derive(Debug, Clone, Serialize, Deserialize)]
187#[serde(untagged)]
188pub enum UpdateOrganizationError {
189 Status400(models::ErrorGeneric),
190 Status403(models::ErrorGeneric),
191 Status404(models::ErrorGeneric),
192 Status409(models::ErrorGeneric),
193 DefaultResponse(models::ErrorGeneric),
194 UnknownValue(serde_json::Value),
195}
196
197
198pub async fn create_organization(configuration: &configuration::Configuration, project_id: &str, organization_body: Option<models::OrganizationBody>) -> Result<models::Organization, Error<CreateOrganizationError>> {
200 let p_project_id = project_id;
202 let p_organization_body = organization_body;
203
204 let uri_str = format!("{}/projects/{project_id}/organizations", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
205 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
206
207 if let Some(ref user_agent) = configuration.user_agent {
208 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
209 }
210 if let Some(ref token) = configuration.bearer_access_token {
211 req_builder = req_builder.bearer_auth(token.to_owned());
212 };
213 req_builder = req_builder.json(&p_organization_body);
214
215 let req = req_builder.build()?;
216 let resp = configuration.client.execute(req).await?;
217
218 let status = resp.status();
219 let content_type = resp
220 .headers()
221 .get("content-type")
222 .and_then(|v| v.to_str().ok())
223 .unwrap_or("application/octet-stream");
224 let content_type = super::ContentType::from(content_type);
225
226 if !status.is_client_error() && !status.is_server_error() {
227 let content = resp.text().await?;
228 match content_type {
229 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
230 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Organization`"))),
231 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::Organization`")))),
232 }
233 } else {
234 let content = resp.text().await?;
235 let entity: Option<CreateOrganizationError> = serde_json::from_str(&content).ok();
236 Err(Error::ResponseError(ResponseContent { status, content, entity }))
237 }
238}
239
240pub async fn create_project(configuration: &configuration::Configuration, create_project_body: Option<models::CreateProjectBody>) -> Result<models::Project, Error<CreateProjectError>> {
242 let p_create_project_body = create_project_body;
244
245 let uri_str = format!("{}/projects", configuration.base_path);
246 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
247
248 if let Some(ref user_agent) = configuration.user_agent {
249 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
250 }
251 if let Some(ref token) = configuration.bearer_access_token {
252 req_builder = req_builder.bearer_auth(token.to_owned());
253 };
254 req_builder = req_builder.json(&p_create_project_body);
255
256 let req = req_builder.build()?;
257 let resp = configuration.client.execute(req).await?;
258
259 let status = resp.status();
260 let content_type = resp
261 .headers()
262 .get("content-type")
263 .and_then(|v| v.to_str().ok())
264 .unwrap_or("application/octet-stream");
265 let content_type = super::ContentType::from(content_type);
266
267 if !status.is_client_error() && !status.is_server_error() {
268 let content = resp.text().await?;
269 match content_type {
270 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
271 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
272 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`")))),
273 }
274 } else {
275 let content = resp.text().await?;
276 let entity: Option<CreateProjectError> = serde_json::from_str(&content).ok();
277 Err(Error::ResponseError(ResponseContent { status, content, entity }))
278 }
279}
280
281pub async fn create_project_api_key(configuration: &configuration::Configuration, project: &str, create_project_api_key_request: Option<models::CreateProjectApiKeyRequest>) -> Result<models::ProjectApiKey, Error<CreateProjectApiKeyError>> {
283 let p_project = project;
285 let p_create_project_api_key_request = create_project_api_key_request;
286
287 let uri_str = format!("{}/projects/{project}/tokens", configuration.base_path, project=crate::apis::urlencode(p_project));
288 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
289
290 if let Some(ref user_agent) = configuration.user_agent {
291 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
292 }
293 if let Some(ref token) = configuration.bearer_access_token {
294 req_builder = req_builder.bearer_auth(token.to_owned());
295 };
296 req_builder = req_builder.json(&p_create_project_api_key_request);
297
298 let req = req_builder.build()?;
299 let resp = configuration.client.execute(req).await?;
300
301 let status = resp.status();
302 let content_type = resp
303 .headers()
304 .get("content-type")
305 .and_then(|v| v.to_str().ok())
306 .unwrap_or("application/octet-stream");
307 let content_type = super::ContentType::from(content_type);
308
309 if !status.is_client_error() && !status.is_server_error() {
310 let content = resp.text().await?;
311 match content_type {
312 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
313 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectApiKey`"))),
314 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::ProjectApiKey`")))),
315 }
316 } else {
317 let content = resp.text().await?;
318 let entity: Option<CreateProjectApiKeyError> = serde_json::from_str(&content).ok();
319 Err(Error::ResponseError(ResponseContent { status, content, entity }))
320 }
321}
322
323pub async fn delete_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<(), Error<DeleteOrganizationError>> {
325 let p_project_id = project_id;
327 let p_organization_id = organization_id;
328
329 let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
330 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
331
332 if let Some(ref user_agent) = configuration.user_agent {
333 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
334 }
335 if let Some(ref token) = configuration.bearer_access_token {
336 req_builder = req_builder.bearer_auth(token.to_owned());
337 };
338
339 let req = req_builder.build()?;
340 let resp = configuration.client.execute(req).await?;
341
342 let status = resp.status();
343
344 if !status.is_client_error() && !status.is_server_error() {
345 Ok(())
346 } else {
347 let content = resp.text().await?;
348 let entity: Option<DeleteOrganizationError> = serde_json::from_str(&content).ok();
349 Err(Error::ResponseError(ResponseContent { status, content, entity }))
350 }
351}
352
353pub async fn delete_project_api_key(configuration: &configuration::Configuration, project: &str, token_id: &str) -> Result<(), Error<DeleteProjectApiKeyError>> {
355 let p_project = project;
357 let p_token_id = token_id;
358
359 let uri_str = format!("{}/projects/{project}/tokens/{token_id}", configuration.base_path, project=crate::apis::urlencode(p_project), token_id=crate::apis::urlencode(p_token_id));
360 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
361
362 if let Some(ref user_agent) = configuration.user_agent {
363 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
364 }
365 if let Some(ref token) = configuration.bearer_access_token {
366 req_builder = req_builder.bearer_auth(token.to_owned());
367 };
368
369 let req = req_builder.build()?;
370 let resp = configuration.client.execute(req).await?;
371
372 let status = resp.status();
373
374 if !status.is_client_error() && !status.is_server_error() {
375 Ok(())
376 } else {
377 let content = resp.text().await?;
378 let entity: Option<DeleteProjectApiKeyError> = serde_json::from_str(&content).ok();
379 Err(Error::ResponseError(ResponseContent { status, content, entity }))
380 }
381}
382
383pub async fn get_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str) -> Result<models::GetOrganizationResponse, Error<GetOrganizationError>> {
385 let p_project_id = project_id;
387 let p_organization_id = organization_id;
388
389 let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
390 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
391
392 if let Some(ref user_agent) = configuration.user_agent {
393 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
394 }
395 if let Some(ref token) = configuration.bearer_access_token {
396 req_builder = req_builder.bearer_auth(token.to_owned());
397 };
398
399 let req = req_builder.build()?;
400 let resp = configuration.client.execute(req).await?;
401
402 let status = resp.status();
403 let content_type = resp
404 .headers()
405 .get("content-type")
406 .and_then(|v| v.to_str().ok())
407 .unwrap_or("application/octet-stream");
408 let content_type = super::ContentType::from(content_type);
409
410 if !status.is_client_error() && !status.is_server_error() {
411 let content = resp.text().await?;
412 match content_type {
413 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
414 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrganizationResponse`"))),
415 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::GetOrganizationResponse`")))),
416 }
417 } else {
418 let content = resp.text().await?;
419 let entity: Option<GetOrganizationError> = serde_json::from_str(&content).ok();
420 Err(Error::ResponseError(ResponseContent { status, content, entity }))
421 }
422}
423
424pub async fn get_project(configuration: &configuration::Configuration, project_id: &str) -> Result<models::Project, Error<GetProjectError>> {
426 let p_project_id = project_id;
428
429 let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
430 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
431
432 if let Some(ref user_agent) = configuration.user_agent {
433 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
434 }
435 if let Some(ref token) = configuration.bearer_access_token {
436 req_builder = req_builder.bearer_auth(token.to_owned());
437 };
438
439 let req = req_builder.build()?;
440 let resp = configuration.client.execute(req).await?;
441
442 let status = resp.status();
443 let content_type = resp
444 .headers()
445 .get("content-type")
446 .and_then(|v| v.to_str().ok())
447 .unwrap_or("application/octet-stream");
448 let content_type = super::ContentType::from(content_type);
449
450 if !status.is_client_error() && !status.is_server_error() {
451 let content = resp.text().await?;
452 match content_type {
453 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
454 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
455 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`")))),
456 }
457 } else {
458 let content = resp.text().await?;
459 let entity: Option<GetProjectError> = serde_json::from_str(&content).ok();
460 Err(Error::ResponseError(ResponseContent { status, content, entity }))
461 }
462}
463
464pub async fn get_project_members(configuration: &configuration::Configuration, project: &str) -> Result<Vec<models::ProjectMember>, Error<GetProjectMembersError>> {
466 let p_project = project;
468
469 let uri_str = format!("{}/projects/{project}/members", configuration.base_path, project=crate::apis::urlencode(p_project));
470 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
471
472 if let Some(ref user_agent) = configuration.user_agent {
473 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
474 }
475 if let Some(ref token) = configuration.bearer_access_token {
476 req_builder = req_builder.bearer_auth(token.to_owned());
477 };
478
479 let req = req_builder.build()?;
480 let resp = configuration.client.execute(req).await?;
481
482 let status = resp.status();
483 let content_type = resp
484 .headers()
485 .get("content-type")
486 .and_then(|v| v.to_str().ok())
487 .unwrap_or("application/octet-stream");
488 let content_type = super::ContentType::from(content_type);
489
490 if !status.is_client_error() && !status.is_server_error() {
491 let content = resp.text().await?;
492 match content_type {
493 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
494 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProjectMember>`"))),
495 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<models::ProjectMember>`")))),
496 }
497 } else {
498 let content = resp.text().await?;
499 let entity: Option<GetProjectMembersError> = serde_json::from_str(&content).ok();
500 Err(Error::ResponseError(ResponseContent { status, content, entity }))
501 }
502}
503
504pub async fn list_organizations(configuration: &configuration::Configuration, project_id: &str, page_size: Option<i64>, page_token: Option<&str>, domain: Option<&str>) -> Result<models::ListOrganizationsResponse, Error<ListOrganizationsError>> {
506 let p_project_id = project_id;
508 let p_page_size = page_size;
509 let p_page_token = page_token;
510 let p_domain = domain;
511
512 let uri_str = format!("{}/projects/{project_id}/organizations", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
513 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
514
515 if let Some(ref param_value) = p_page_size {
516 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
517 }
518 if let Some(ref param_value) = p_page_token {
519 req_builder = req_builder.query(&[("page_token", ¶m_value.to_string())]);
520 }
521 if let Some(ref param_value) = p_domain {
522 req_builder = req_builder.query(&[("domain", ¶m_value.to_string())]);
523 }
524 if let Some(ref user_agent) = configuration.user_agent {
525 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
526 }
527 if let Some(ref token) = configuration.bearer_access_token {
528 req_builder = req_builder.bearer_auth(token.to_owned());
529 };
530
531 let req = req_builder.build()?;
532 let resp = configuration.client.execute(req).await?;
533
534 let status = resp.status();
535 let content_type = resp
536 .headers()
537 .get("content-type")
538 .and_then(|v| v.to_str().ok())
539 .unwrap_or("application/octet-stream");
540 let content_type = super::ContentType::from(content_type);
541
542 if !status.is_client_error() && !status.is_server_error() {
543 let content = resp.text().await?;
544 match content_type {
545 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
546 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListOrganizationsResponse`"))),
547 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::ListOrganizationsResponse`")))),
548 }
549 } else {
550 let content = resp.text().await?;
551 let entity: Option<ListOrganizationsError> = serde_json::from_str(&content).ok();
552 Err(Error::ResponseError(ResponseContent { status, content, entity }))
553 }
554}
555
556pub async fn list_project_api_keys(configuration: &configuration::Configuration, project: &str) -> Result<Vec<models::ProjectApiKey>, Error<ListProjectApiKeysError>> {
558 let p_project = project;
560
561 let uri_str = format!("{}/projects/{project}/tokens", configuration.base_path, project=crate::apis::urlencode(p_project));
562 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
563
564 if let Some(ref user_agent) = configuration.user_agent {
565 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
566 }
567 if let Some(ref token) = configuration.bearer_access_token {
568 req_builder = req_builder.bearer_auth(token.to_owned());
569 };
570
571 let req = req_builder.build()?;
572 let resp = configuration.client.execute(req).await?;
573
574 let status = resp.status();
575 let content_type = resp
576 .headers()
577 .get("content-type")
578 .and_then(|v| v.to_str().ok())
579 .unwrap_or("application/octet-stream");
580 let content_type = super::ContentType::from(content_type);
581
582 if !status.is_client_error() && !status.is_server_error() {
583 let content = resp.text().await?;
584 match content_type {
585 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
586 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProjectApiKey>`"))),
587 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<models::ProjectApiKey>`")))),
588 }
589 } else {
590 let content = resp.text().await?;
591 let entity: Option<ListProjectApiKeysError> = serde_json::from_str(&content).ok();
592 Err(Error::ResponseError(ResponseContent { status, content, entity }))
593 }
594}
595
596pub async fn list_projects(configuration: &configuration::Configuration, ) -> Result<Vec<models::ProjectMetadata>, Error<ListProjectsError>> {
598
599 let uri_str = format!("{}/projects", configuration.base_path);
600 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
601
602 if let Some(ref user_agent) = configuration.user_agent {
603 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
604 }
605 if let Some(ref token) = configuration.bearer_access_token {
606 req_builder = req_builder.bearer_auth(token.to_owned());
607 };
608
609 let req = req_builder.build()?;
610 let resp = configuration.client.execute(req).await?;
611
612 let status = resp.status();
613 let content_type = resp
614 .headers()
615 .get("content-type")
616 .and_then(|v| v.to_str().ok())
617 .unwrap_or("application/octet-stream");
618 let content_type = super::ContentType::from(content_type);
619
620 if !status.is_client_error() && !status.is_server_error() {
621 let content = resp.text().await?;
622 match content_type {
623 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
624 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ProjectMetadata>`"))),
625 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<models::ProjectMetadata>`")))),
626 }
627 } else {
628 let content = resp.text().await?;
629 let entity: Option<ListProjectsError> = serde_json::from_str(&content).ok();
630 Err(Error::ResponseError(ResponseContent { status, content, entity }))
631 }
632}
633
634pub async fn patch_project(configuration: &configuration::Configuration, project_id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::SuccessfulProjectUpdate, Error<PatchProjectError>> {
636 let p_project_id = project_id;
638 let p_json_patch = json_patch;
639
640 let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
641 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
642
643 if let Some(ref user_agent) = configuration.user_agent {
644 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
645 }
646 if let Some(ref token) = configuration.bearer_access_token {
647 req_builder = req_builder.bearer_auth(token.to_owned());
648 };
649 req_builder = req_builder.json(&p_json_patch);
650
651 let req = req_builder.build()?;
652 let resp = configuration.client.execute(req).await?;
653
654 let status = resp.status();
655 let content_type = resp
656 .headers()
657 .get("content-type")
658 .and_then(|v| v.to_str().ok())
659 .unwrap_or("application/octet-stream");
660 let content_type = super::ContentType::from(content_type);
661
662 if !status.is_client_error() && !status.is_server_error() {
663 let content = resp.text().await?;
664 match content_type {
665 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
666 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
667 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::SuccessfulProjectUpdate`")))),
668 }
669 } else {
670 let content = resp.text().await?;
671 let entity: Option<PatchProjectError> = serde_json::from_str(&content).ok();
672 Err(Error::ResponseError(ResponseContent { status, content, entity }))
673 }
674}
675
676pub async fn patch_project_with_revision(configuration: &configuration::Configuration, project_id: &str, revision_id: &str, json_patch: Option<Vec<models::JsonPatch>>) -> Result<models::SuccessfulProjectUpdate, Error<PatchProjectWithRevisionError>> {
678 let p_project_id = project_id;
680 let p_revision_id = revision_id;
681 let p_json_patch = json_patch;
682
683 let uri_str = format!("{}/projects/{project_id}/revision/{revision_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), revision_id=crate::apis::urlencode(p_revision_id));
684 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
685
686 if let Some(ref user_agent) = configuration.user_agent {
687 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
688 }
689 if let Some(ref token) = configuration.bearer_access_token {
690 req_builder = req_builder.bearer_auth(token.to_owned());
691 };
692 req_builder = req_builder.json(&p_json_patch);
693
694 let req = req_builder.build()?;
695 let resp = configuration.client.execute(req).await?;
696
697 let status = resp.status();
698 let content_type = resp
699 .headers()
700 .get("content-type")
701 .and_then(|v| v.to_str().ok())
702 .unwrap_or("application/octet-stream");
703 let content_type = super::ContentType::from(content_type);
704
705 if !status.is_client_error() && !status.is_server_error() {
706 let content = resp.text().await?;
707 match content_type {
708 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
709 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
710 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::SuccessfulProjectUpdate`")))),
711 }
712 } else {
713 let content = resp.text().await?;
714 let entity: Option<PatchProjectWithRevisionError> = serde_json::from_str(&content).ok();
715 Err(Error::ResponseError(ResponseContent { status, content, entity }))
716 }
717}
718
719pub async fn purge_project(configuration: &configuration::Configuration, project_id: &str) -> Result<(), Error<PurgeProjectError>> {
721 let p_project_id = project_id;
723
724 let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
725 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
726
727 if let Some(ref user_agent) = configuration.user_agent {
728 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
729 }
730 if let Some(ref token) = configuration.bearer_access_token {
731 req_builder = req_builder.bearer_auth(token.to_owned());
732 };
733
734 let req = req_builder.build()?;
735 let resp = configuration.client.execute(req).await?;
736
737 let status = resp.status();
738
739 if !status.is_client_error() && !status.is_server_error() {
740 Ok(())
741 } else {
742 let content = resp.text().await?;
743 let entity: Option<PurgeProjectError> = serde_json::from_str(&content).ok();
744 Err(Error::ResponseError(ResponseContent { status, content, entity }))
745 }
746}
747
748pub async fn remove_project_member(configuration: &configuration::Configuration, project: &str, member: &str) -> Result<(), Error<RemoveProjectMemberError>> {
750 let p_project = project;
752 let p_member = member;
753
754 let uri_str = format!("{}/projects/{project}/members/{member}", configuration.base_path, project=crate::apis::urlencode(p_project), member=crate::apis::urlencode(p_member));
755 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
756
757 if let Some(ref user_agent) = configuration.user_agent {
758 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
759 }
760 if let Some(ref token) = configuration.bearer_access_token {
761 req_builder = req_builder.bearer_auth(token.to_owned());
762 };
763
764 let req = req_builder.build()?;
765 let resp = configuration.client.execute(req).await?;
766
767 let status = resp.status();
768
769 if !status.is_client_error() && !status.is_server_error() {
770 Ok(())
771 } else {
772 let content = resp.text().await?;
773 let entity: Option<RemoveProjectMemberError> = serde_json::from_str(&content).ok();
774 Err(Error::ResponseError(ResponseContent { status, content, entity }))
775 }
776}
777
778pub async fn set_project(configuration: &configuration::Configuration, project_id: &str, set_project: Option<models::SetProject>) -> Result<models::SuccessfulProjectUpdate, Error<SetProjectError>> {
780 let p_project_id = project_id;
782 let p_set_project = set_project;
783
784 let uri_str = format!("{}/projects/{project_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id));
785 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
786
787 if let Some(ref user_agent) = configuration.user_agent {
788 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
789 }
790 if let Some(ref token) = configuration.bearer_access_token {
791 req_builder = req_builder.bearer_auth(token.to_owned());
792 };
793 req_builder = req_builder.json(&p_set_project);
794
795 let req = req_builder.build()?;
796 let resp = configuration.client.execute(req).await?;
797
798 let status = resp.status();
799 let content_type = resp
800 .headers()
801 .get("content-type")
802 .and_then(|v| v.to_str().ok())
803 .unwrap_or("application/octet-stream");
804 let content_type = super::ContentType::from(content_type);
805
806 if !status.is_client_error() && !status.is_server_error() {
807 let content = resp.text().await?;
808 match content_type {
809 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
810 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulProjectUpdate`"))),
811 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::SuccessfulProjectUpdate`")))),
812 }
813 } else {
814 let content = resp.text().await?;
815 let entity: Option<SetProjectError> = serde_json::from_str(&content).ok();
816 Err(Error::ResponseError(ResponseContent { status, content, entity }))
817 }
818}
819
820pub async fn update_organization(configuration: &configuration::Configuration, project_id: &str, organization_id: &str, organization_body: Option<models::OrganizationBody>) -> Result<models::Organization, Error<UpdateOrganizationError>> {
822 let p_project_id = project_id;
824 let p_organization_id = organization_id;
825 let p_organization_body = organization_body;
826
827 let uri_str = format!("{}/projects/{project_id}/organizations/{organization_id}", configuration.base_path, project_id=crate::apis::urlencode(p_project_id), organization_id=crate::apis::urlencode(p_organization_id));
828 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
829
830 if let Some(ref user_agent) = configuration.user_agent {
831 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
832 }
833 if let Some(ref token) = configuration.bearer_access_token {
834 req_builder = req_builder.bearer_auth(token.to_owned());
835 };
836 req_builder = req_builder.json(&p_organization_body);
837
838 let req = req_builder.build()?;
839 let resp = configuration.client.execute(req).await?;
840
841 let status = resp.status();
842 let content_type = resp
843 .headers()
844 .get("content-type")
845 .and_then(|v| v.to_str().ok())
846 .unwrap_or("application/octet-stream");
847 let content_type = super::ContentType::from(content_type);
848
849 if !status.is_client_error() && !status.is_server_error() {
850 let content = resp.text().await?;
851 match content_type {
852 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
853 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Organization`"))),
854 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::Organization`")))),
855 }
856 } else {
857 let content = resp.text().await?;
858 let entity: Option<UpdateOrganizationError> = serde_json::from_str(&content).ok();
859 Err(Error::ResponseError(ResponseContent { status, content, entity }))
860 }
861}
862