Skip to main content

mesa_dev_oapi/apis/
repos_api.rs

1/*
2 * Depot API
3 *
4 * Depot HTTP API v1
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`delete_by_org_by_repo`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteByOrgByRepoError {
22    Status400(models::PostByOrgApiKeys400Response),
23    Status401(models::PostByOrgApiKeys400Response),
24    Status403(models::PostByOrgApiKeys400Response),
25    Status404(models::PostByOrgApiKeys400Response),
26    Status406(models::PostByOrgApiKeys400Response),
27    Status409(models::PostByOrgApiKeys400Response),
28    Status500(models::PostByOrgApiKeys400Response),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_by_org_by_repo`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetByOrgByRepoError {
36    Status400(models::PostByOrgApiKeys400Response),
37    Status401(models::PostByOrgApiKeys400Response),
38    Status403(models::PostByOrgApiKeys400Response),
39    Status404(models::PostByOrgApiKeys400Response),
40    Status406(models::PostByOrgApiKeys400Response),
41    Status409(models::PostByOrgApiKeys400Response),
42    Status500(models::PostByOrgApiKeys400Response),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_by_org_by_repo_sync`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetByOrgByRepoSyncError {
50    Status400(models::PostByOrgApiKeys400Response),
51    Status401(models::PostByOrgApiKeys400Response),
52    Status403(models::PostByOrgApiKeys400Response),
53    Status404(models::PostByOrgApiKeys400Response),
54    Status406(models::PostByOrgApiKeys400Response),
55    Status409(models::PostByOrgApiKeys400Response),
56    Status500(models::PostByOrgApiKeys400Response),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_by_org_repos`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetByOrgReposError {
64    Status400(models::PostByOrgApiKeys400Response),
65    Status401(models::PostByOrgApiKeys400Response),
66    Status403(models::PostByOrgApiKeys400Response),
67    Status404(models::PostByOrgApiKeys400Response),
68    Status406(models::PostByOrgApiKeys400Response),
69    Status409(models::PostByOrgApiKeys400Response),
70    Status500(models::PostByOrgApiKeys400Response),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`patch_by_org_by_repo`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PatchByOrgByRepoError {
78    Status400(models::PostByOrgApiKeys400Response),
79    Status401(models::PostByOrgApiKeys400Response),
80    Status403(models::PostByOrgApiKeys400Response),
81    Status404(models::PostByOrgApiKeys400Response),
82    Status406(models::PostByOrgApiKeys400Response),
83    Status409(models::PostByOrgApiKeys400Response),
84    Status500(models::PostByOrgApiKeys400Response),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`post_by_org_by_repo_sync`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum PostByOrgByRepoSyncError {
92    Status400(models::PostByOrgApiKeys400Response),
93    Status401(models::PostByOrgApiKeys400Response),
94    Status403(models::PostByOrgApiKeys400Response),
95    Status404(models::PostByOrgApiKeys400Response),
96    Status406(models::PostByOrgApiKeys400Response),
97    Status409(models::PostByOrgApiKeys400Response),
98    Status500(models::PostByOrgApiKeys400Response),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`post_by_org_repos`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum PostByOrgReposError {
106    Status400(models::PostByOrgApiKeys400Response),
107    Status401(models::PostByOrgApiKeys400Response),
108    Status403(models::PostByOrgApiKeys400Response),
109    Status404(models::PostByOrgApiKeys400Response),
110    Status406(models::PostByOrgApiKeys400Response),
111    Status409(models::PostByOrgApiKeys400Response),
112    Status500(models::PostByOrgApiKeys400Response),
113    UnknownValue(serde_json::Value),
114}
115
116
117/// Permanently delete a repository and all its data
118pub async fn delete_by_org_by_repo(configuration: &configuration::Configuration, org: &str, repo: &str) -> Result<models::DeleteByOrgApiKeysById200Response, Error<DeleteByOrgByRepoError>> {
119    // add a prefix to parameters to efficiently prevent name collisions
120    let p_path_org = org;
121    let p_path_repo = repo;
122
123    let uri_str = format!("{}/{org}/{repo}", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
124    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
125
126    if let Some(ref user_agent) = configuration.user_agent {
127        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128    }
129    if let Some(ref token) = configuration.bearer_access_token {
130        req_builder = req_builder.bearer_auth(token.to_owned());
131    };
132
133    let req = req_builder.build()?;
134    let resp = configuration.client.execute(req).await?;
135
136    let status = resp.status();
137    let content_type = resp
138        .headers()
139        .get("content-type")
140        .and_then(|v| v.to_str().ok())
141        .unwrap_or("application/octet-stream");
142    let content_type = super::ContentType::from(content_type);
143
144    if !status.is_client_error() && !status.is_server_error() {
145        let content = resp.text().await?;
146        match content_type {
147            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
148            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteByOrgApiKeysById200Response`"))),
149            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::DeleteByOrgApiKeysById200Response`")))),
150        }
151    } else {
152        let content = resp.text().await?;
153        let entity: Option<DeleteByOrgByRepoError> = serde_json::from_str(&content).ok();
154        Err(Error::ResponseError(ResponseContent { status, content, entity }))
155    }
156}
157
158/// Get metadata for a specific repository
159pub async fn get_by_org_by_repo(configuration: &configuration::Configuration, org: &str, repo: &str) -> Result<models::PostByOrgRepos201Response, Error<GetByOrgByRepoError>> {
160    // add a prefix to parameters to efficiently prevent name collisions
161    let p_path_org = org;
162    let p_path_repo = repo;
163
164    let uri_str = format!("{}/{org}/{repo}", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
165    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
166
167    if let Some(ref user_agent) = configuration.user_agent {
168        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
169    }
170    if let Some(ref token) = configuration.bearer_access_token {
171        req_builder = req_builder.bearer_auth(token.to_owned());
172    };
173
174    let req = req_builder.build()?;
175    let resp = configuration.client.execute(req).await?;
176
177    let status = resp.status();
178    let content_type = resp
179        .headers()
180        .get("content-type")
181        .and_then(|v| v.to_str().ok())
182        .unwrap_or("application/octet-stream");
183    let content_type = super::ContentType::from(content_type);
184
185    if !status.is_client_error() && !status.is_server_error() {
186        let content = resp.text().await?;
187        match content_type {
188            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
189            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostByOrgRepos201Response`"))),
190            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::PostByOrgRepos201Response`")))),
191        }
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<GetByOrgByRepoError> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent { status, content, entity }))
196    }
197}
198
199/// Get the sync status for a repository with upstream configured
200pub async fn get_by_org_by_repo_sync(configuration: &configuration::Configuration, org: &str, repo: &str) -> Result<models::GetByOrgByRepoSync200Response, Error<GetByOrgByRepoSyncError>> {
201    // add a prefix to parameters to efficiently prevent name collisions
202    let p_path_org = org;
203    let p_path_repo = repo;
204
205    let uri_str = format!("{}/{org}/{repo}/sync", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
206    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
207
208    if let Some(ref user_agent) = configuration.user_agent {
209        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
210    }
211    if let Some(ref token) = configuration.bearer_access_token {
212        req_builder = req_builder.bearer_auth(token.to_owned());
213    };
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_path_to_error::deserialize(&mut serde_json::Deserializer::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::GetByOrgByRepoSync200Response`"))),
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::GetByOrgByRepoSync200Response`")))),
232        }
233    } else {
234        let content = resp.text().await?;
235        let entity: Option<GetByOrgByRepoSyncError> = serde_json::from_str(&content).ok();
236        Err(Error::ResponseError(ResponseContent { status, content, entity }))
237    }
238}
239
240/// List all repositories in the organization
241pub async fn get_by_org_repos(configuration: &configuration::Configuration, org: &str, cursor: Option<&str>, limit: Option<u8>) -> Result<models::GetByOrgRepos200Response, Error<GetByOrgReposError>> {
242    // add a prefix to parameters to efficiently prevent name collisions
243    let p_path_org = org;
244    let p_query_cursor = cursor;
245    let p_query_limit = limit;
246
247    let uri_str = format!("{}/{org}/repos", configuration.base_path, org=crate::apis::urlencode(p_path_org));
248    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
249
250    if let Some(ref param_value) = p_query_cursor {
251        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
252    }
253    if let Some(ref param_value) = p_query_limit {
254        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
255    }
256    if let Some(ref user_agent) = configuration.user_agent {
257        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
258    }
259    if let Some(ref token) = configuration.bearer_access_token {
260        req_builder = req_builder.bearer_auth(token.to_owned());
261    };
262
263    let req = req_builder.build()?;
264    let resp = configuration.client.execute(req).await?;
265
266    let status = resp.status();
267    let content_type = resp
268        .headers()
269        .get("content-type")
270        .and_then(|v| v.to_str().ok())
271        .unwrap_or("application/octet-stream");
272    let content_type = super::ContentType::from(content_type);
273
274    if !status.is_client_error() && !status.is_server_error() {
275        let content = resp.text().await?;
276        match content_type {
277            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
278            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetByOrgRepos200Response`"))),
279            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::GetByOrgRepos200Response`")))),
280        }
281    } else {
282        let content = resp.text().await?;
283        let entity: Option<GetByOrgReposError> = serde_json::from_str(&content).ok();
284        Err(Error::ResponseError(ResponseContent { status, content, entity }))
285    }
286}
287
288/// Update repository name or upstream configuration
289pub async fn patch_by_org_by_repo(configuration: &configuration::Configuration, org: &str, repo: &str, patch_by_org_by_repo_request: Option<models::PatchByOrgByRepoRequest>) -> Result<models::PostByOrgRepos201Response, Error<PatchByOrgByRepoError>> {
290    // add a prefix to parameters to efficiently prevent name collisions
291    let p_path_org = org;
292    let p_path_repo = repo;
293    let p_body_patch_by_org_by_repo_request = patch_by_org_by_repo_request;
294
295    let uri_str = format!("{}/{org}/{repo}", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
296    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
297
298    if let Some(ref user_agent) = configuration.user_agent {
299        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
300    }
301    if let Some(ref token) = configuration.bearer_access_token {
302        req_builder = req_builder.bearer_auth(token.to_owned());
303    };
304    req_builder = req_builder.json(&p_body_patch_by_org_by_repo_request);
305
306    let req = req_builder.build()?;
307    let resp = configuration.client.execute(req).await?;
308
309    let status = resp.status();
310    let content_type = resp
311        .headers()
312        .get("content-type")
313        .and_then(|v| v.to_str().ok())
314        .unwrap_or("application/octet-stream");
315    let content_type = super::ContentType::from(content_type);
316
317    if !status.is_client_error() && !status.is_server_error() {
318        let content = resp.text().await?;
319        match content_type {
320            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
321            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostByOrgRepos201Response`"))),
322            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::PostByOrgRepos201Response`")))),
323        }
324    } else {
325        let content = resp.text().await?;
326        let entity: Option<PatchByOrgByRepoError> = serde_json::from_str(&content).ok();
327        Err(Error::ResponseError(ResponseContent { status, content, entity }))
328    }
329}
330
331/// Trigger a sync from the upstream repository. Waits for sync to complete.
332pub async fn post_by_org_by_repo_sync(configuration: &configuration::Configuration, org: &str, repo: &str) -> Result<models::DeleteByOrgApiKeysById200Response, Error<PostByOrgByRepoSyncError>> {
333    // add a prefix to parameters to efficiently prevent name collisions
334    let p_path_org = org;
335    let p_path_repo = repo;
336
337    let uri_str = format!("{}/{org}/{repo}/sync", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
338    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
339
340    if let Some(ref user_agent) = configuration.user_agent {
341        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
342    }
343    if let Some(ref token) = configuration.bearer_access_token {
344        req_builder = req_builder.bearer_auth(token.to_owned());
345    };
346
347    let req = req_builder.build()?;
348    let resp = configuration.client.execute(req).await?;
349
350    let status = resp.status();
351    let content_type = resp
352        .headers()
353        .get("content-type")
354        .and_then(|v| v.to_str().ok())
355        .unwrap_or("application/octet-stream");
356    let content_type = super::ContentType::from(content_type);
357
358    if !status.is_client_error() && !status.is_server_error() {
359        let content = resp.text().await?;
360        match content_type {
361            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
362            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteByOrgApiKeysById200Response`"))),
363            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::DeleteByOrgApiKeysById200Response`")))),
364        }
365    } else {
366        let content = resp.text().await?;
367        let entity: Option<PostByOrgByRepoSyncError> = serde_json::from_str(&content).ok();
368        Err(Error::ResponseError(ResponseContent { status, content, entity }))
369    }
370}
371
372/// Create a new repository in the organization
373pub async fn post_by_org_repos(configuration: &configuration::Configuration, org: &str, post_by_org_repos_request: Option<models::PostByOrgReposRequest>) -> Result<models::PostByOrgRepos201Response, Error<PostByOrgReposError>> {
374    // add a prefix to parameters to efficiently prevent name collisions
375    let p_path_org = org;
376    let p_body_post_by_org_repos_request = post_by_org_repos_request;
377
378    let uri_str = format!("{}/{org}/repos", configuration.base_path, org=crate::apis::urlencode(p_path_org));
379    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
380
381    if let Some(ref user_agent) = configuration.user_agent {
382        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
383    }
384    if let Some(ref token) = configuration.bearer_access_token {
385        req_builder = req_builder.bearer_auth(token.to_owned());
386    };
387    req_builder = req_builder.json(&p_body_post_by_org_repos_request);
388
389    let req = req_builder.build()?;
390    let resp = configuration.client.execute(req).await?;
391
392    let status = resp.status();
393    let content_type = resp
394        .headers()
395        .get("content-type")
396        .and_then(|v| v.to_str().ok())
397        .unwrap_or("application/octet-stream");
398    let content_type = super::ContentType::from(content_type);
399
400    if !status.is_client_error() && !status.is_server_error() {
401        let content = resp.text().await?;
402        match content_type {
403            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
404            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostByOrgRepos201Response`"))),
405            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::PostByOrgRepos201Response`")))),
406        }
407    } else {
408        let content = resp.text().await?;
409        let entity: Option<PostByOrgReposError> = serde_json::from_str(&content).ok();
410        Err(Error::ResponseError(ResponseContent { status, content, entity }))
411    }
412}
413