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_repos`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetByOrgReposError {
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 [`patch_by_org_by_repo`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PatchByOrgByRepoError {
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 [`post_by_org_repos`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostByOrgReposError {
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
89/// Permanently delete a repository and all its data
90pub async fn delete_by_org_by_repo(configuration: &configuration::Configuration, org: &str, repo: &str) -> Result<models::DeleteByOrgApiKeysById200Response, Error<DeleteByOrgByRepoError>> {
91    // add a prefix to parameters to efficiently prevent name collisions
92    let p_path_org = org;
93    let p_path_repo = repo;
94
95    let uri_str = format!("{}/{org}/{repo}", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
96    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
97
98    if let Some(ref user_agent) = configuration.user_agent {
99        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
100    }
101    if let Some(ref token) = configuration.bearer_access_token {
102        req_builder = req_builder.bearer_auth(token.to_owned());
103    };
104
105    let req = req_builder.build()?;
106    let resp = configuration.client.execute(req).await?;
107
108    let status = resp.status();
109    let content_type = resp
110        .headers()
111        .get("content-type")
112        .and_then(|v| v.to_str().ok())
113        .unwrap_or("application/octet-stream");
114    let content_type = super::ContentType::from(content_type);
115
116    if !status.is_client_error() && !status.is_server_error() {
117        let content = resp.text().await?;
118        match content_type {
119            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
120            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteByOrgApiKeysById200Response`"))),
121            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`")))),
122        }
123    } else {
124        let content = resp.text().await?;
125        let entity: Option<DeleteByOrgByRepoError> = serde_json::from_str(&content).ok();
126        Err(Error::ResponseError(ResponseContent { status, content, entity }))
127    }
128}
129
130/// Get metadata for a specific repository
131pub async fn get_by_org_by_repo(configuration: &configuration::Configuration, org: &str, repo: Option<&str>) -> Result<models::PostByOrgRepos201Response, Error<GetByOrgByRepoError>> {
132    // add a prefix to parameters to efficiently prevent name collisions
133    let p_path_org = org;
134    let p_path_repo = repo;
135
136    let uri_str = format!("{}/{org}/{repo}", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo.unwrap()));
137    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
138
139    if let Some(ref user_agent) = configuration.user_agent {
140        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
141    }
142    if let Some(ref token) = configuration.bearer_access_token {
143        req_builder = req_builder.bearer_auth(token.to_owned());
144    };
145
146    let req = req_builder.build()?;
147    let resp = configuration.client.execute(req).await?;
148
149    let status = resp.status();
150    let content_type = resp
151        .headers()
152        .get("content-type")
153        .and_then(|v| v.to_str().ok())
154        .unwrap_or("application/octet-stream");
155    let content_type = super::ContentType::from(content_type);
156
157    if !status.is_client_error() && !status.is_server_error() {
158        let content = resp.text().await?;
159        match content_type {
160            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
161            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostByOrgRepos201Response`"))),
162            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`")))),
163        }
164    } else {
165        let content = resp.text().await?;
166        let entity: Option<GetByOrgByRepoError> = serde_json::from_str(&content).ok();
167        Err(Error::ResponseError(ResponseContent { status, content, entity }))
168    }
169}
170
171/// List all repositories in the organization
172pub async fn get_by_org_repos(configuration: &configuration::Configuration, org: Option<&str>, cursor: Option<&str>, limit: Option<u8>) -> Result<models::GetByOrgRepos200Response, Error<GetByOrgReposError>> {
173    // add a prefix to parameters to efficiently prevent name collisions
174    let p_path_org = org;
175    let p_query_cursor = cursor;
176    let p_query_limit = limit;
177
178    let uri_str = format!("{}/{org}/repos", configuration.base_path, org=crate::apis::urlencode(p_path_org.unwrap()));
179    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
180
181    if let Some(ref param_value) = p_query_cursor {
182        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
183    }
184    if let Some(ref param_value) = p_query_limit {
185        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
186    }
187    if let Some(ref user_agent) = configuration.user_agent {
188        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
189    }
190    if let Some(ref token) = configuration.bearer_access_token {
191        req_builder = req_builder.bearer_auth(token.to_owned());
192    };
193
194    let req = req_builder.build()?;
195    let resp = configuration.client.execute(req).await?;
196
197    let status = resp.status();
198    let content_type = resp
199        .headers()
200        .get("content-type")
201        .and_then(|v| v.to_str().ok())
202        .unwrap_or("application/octet-stream");
203    let content_type = super::ContentType::from(content_type);
204
205    if !status.is_client_error() && !status.is_server_error() {
206        let content = resp.text().await?;
207        match content_type {
208            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
209            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetByOrgRepos200Response`"))),
210            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`")))),
211        }
212    } else {
213        let content = resp.text().await?;
214        let entity: Option<GetByOrgReposError> = serde_json::from_str(&content).ok();
215        Err(Error::ResponseError(ResponseContent { status, content, entity }))
216    }
217}
218
219/// Update repository name or upstream configuration
220pub 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>> {
221    // add a prefix to parameters to efficiently prevent name collisions
222    let p_path_org = org;
223    let p_path_repo = repo;
224    let p_body_patch_by_org_by_repo_request = patch_by_org_by_repo_request;
225
226    let uri_str = format!("{}/{org}/{repo}", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
227    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
228
229    if let Some(ref user_agent) = configuration.user_agent {
230        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
231    }
232    if let Some(ref token) = configuration.bearer_access_token {
233        req_builder = req_builder.bearer_auth(token.to_owned());
234    };
235    req_builder = req_builder.json(&p_body_patch_by_org_by_repo_request);
236
237    let req = req_builder.build()?;
238    let resp = configuration.client.execute(req).await?;
239
240    let status = resp.status();
241    let content_type = resp
242        .headers()
243        .get("content-type")
244        .and_then(|v| v.to_str().ok())
245        .unwrap_or("application/octet-stream");
246    let content_type = super::ContentType::from(content_type);
247
248    if !status.is_client_error() && !status.is_server_error() {
249        let content = resp.text().await?;
250        match content_type {
251            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
252            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostByOrgRepos201Response`"))),
253            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`")))),
254        }
255    } else {
256        let content = resp.text().await?;
257        let entity: Option<PatchByOrgByRepoError> = serde_json::from_str(&content).ok();
258        Err(Error::ResponseError(ResponseContent { status, content, entity }))
259    }
260}
261
262/// Create a new repository in the organization
263pub async fn post_by_org_repos(configuration: &configuration::Configuration, org: &str, post_by_org_repos_request: Option<models::PostByOrgReposRequest>) -> Result<models::PostByOrgRepos201Response, Error<PostByOrgReposError>> {
264    // add a prefix to parameters to efficiently prevent name collisions
265    let p_path_org = org;
266    let p_body_post_by_org_repos_request = post_by_org_repos_request;
267
268    let uri_str = format!("{}/{org}/repos", configuration.base_path, org=crate::apis::urlencode(p_path_org));
269    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
270
271    if let Some(ref user_agent) = configuration.user_agent {
272        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
273    }
274    if let Some(ref token) = configuration.bearer_access_token {
275        req_builder = req_builder.bearer_auth(token.to_owned());
276    };
277    req_builder = req_builder.json(&p_body_post_by_org_repos_request);
278
279    let req = req_builder.build()?;
280    let resp = configuration.client.execute(req).await?;
281
282    let status = resp.status();
283    let content_type = resp
284        .headers()
285        .get("content-type")
286        .and_then(|v| v.to_str().ok())
287        .unwrap_or("application/octet-stream");
288    let content_type = super::ContentType::from(content_type);
289
290    if !status.is_client_error() && !status.is_server_error() {
291        let content = resp.text().await?;
292        match content_type {
293            ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
294            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostByOrgRepos201Response`"))),
295            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`")))),
296        }
297    } else {
298        let content = resp.text().await?;
299        let entity: Option<PostByOrgReposError> = serde_json::from_str(&content).ok();
300        Err(Error::ResponseError(ResponseContent { status, content, entity }))
301    }
302}
303