github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/rust/src/apis/actions_api.rs (about) 1 /* 2 * lakeFS API 3 * 4 * lakeFS HTTP API 5 * 6 * The version of the OpenAPI document: 1.0.0 7 * Contact: services@treeverse.io 8 * Generated by: https://openapi-generator.tech 9 */ 10 11 12 use reqwest; 13 14 use crate::{apis::ResponseContent, models}; 15 use super::{Error, configuration}; 16 17 18 /// struct for typed errors of method [`get_run`] 19 #[derive(Debug, Clone, Serialize, Deserialize)] 20 #[serde(untagged)] 21 pub enum GetRunError { 22 Status401(models::Error), 23 Status404(models::Error), 24 Status420(), 25 DefaultResponse(models::Error), 26 UnknownValue(serde_json::Value), 27 } 28 29 /// struct for typed errors of method [`get_run_hook_output`] 30 #[derive(Debug, Clone, Serialize, Deserialize)] 31 #[serde(untagged)] 32 pub enum GetRunHookOutputError { 33 Status401(models::Error), 34 Status404(models::Error), 35 Status420(), 36 DefaultResponse(models::Error), 37 UnknownValue(serde_json::Value), 38 } 39 40 /// struct for typed errors of method [`list_repository_runs`] 41 #[derive(Debug, Clone, Serialize, Deserialize)] 42 #[serde(untagged)] 43 pub enum ListRepositoryRunsError { 44 Status401(models::Error), 45 Status404(models::Error), 46 Status420(), 47 DefaultResponse(models::Error), 48 UnknownValue(serde_json::Value), 49 } 50 51 /// struct for typed errors of method [`list_run_hooks`] 52 #[derive(Debug, Clone, Serialize, Deserialize)] 53 #[serde(untagged)] 54 pub enum ListRunHooksError { 55 Status401(models::Error), 56 Status404(models::Error), 57 Status420(), 58 DefaultResponse(models::Error), 59 UnknownValue(serde_json::Value), 60 } 61 62 63 pub async fn get_run(configuration: &configuration::Configuration, repository: &str, run_id: &str) -> Result<models::ActionRun, Error<GetRunError>> { 64 let local_var_configuration = configuration; 65 66 let local_var_client = &local_var_configuration.client; 67 68 let local_var_uri_str = format!("{}/repositories/{repository}/actions/runs/{run_id}", local_var_configuration.base_path, repository=crate::apis::urlencode(repository), run_id=crate::apis::urlencode(run_id)); 69 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 70 71 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 72 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 73 } 74 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 75 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 76 }; 77 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 78 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 79 }; 80 81 let local_var_req = local_var_req_builder.build()?; 82 let local_var_resp = local_var_client.execute(local_var_req).await?; 83 84 let local_var_status = local_var_resp.status(); 85 let local_var_content = local_var_resp.text().await?; 86 87 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 88 serde_json::from_str(&local_var_content).map_err(Error::from) 89 } else { 90 let local_var_entity: Option<GetRunError> = serde_json::from_str(&local_var_content).ok(); 91 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 92 Err(Error::ResponseError(local_var_error)) 93 } 94 } 95 96 pub async fn get_run_hook_output(configuration: &configuration::Configuration, repository: &str, run_id: &str, hook_run_id: &str) -> Result<std::path::PathBuf, Error<GetRunHookOutputError>> { 97 let local_var_configuration = configuration; 98 99 let local_var_client = &local_var_configuration.client; 100 101 let local_var_uri_str = format!("{}/repositories/{repository}/actions/runs/{run_id}/hooks/{hook_run_id}/output", local_var_configuration.base_path, repository=crate::apis::urlencode(repository), run_id=crate::apis::urlencode(run_id), hook_run_id=crate::apis::urlencode(hook_run_id)); 102 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 103 104 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 105 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 106 } 107 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 108 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 109 }; 110 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 111 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 112 }; 113 114 let local_var_req = local_var_req_builder.build()?; 115 let local_var_resp = local_var_client.execute(local_var_req).await?; 116 117 let local_var_status = local_var_resp.status(); 118 let local_var_content = local_var_resp.text().await?; 119 120 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 121 serde_json::from_str(&local_var_content).map_err(Error::from) 122 } else { 123 let local_var_entity: Option<GetRunHookOutputError> = serde_json::from_str(&local_var_content).ok(); 124 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 125 Err(Error::ResponseError(local_var_error)) 126 } 127 } 128 129 pub async fn list_repository_runs(configuration: &configuration::Configuration, repository: &str, after: Option<&str>, amount: Option<i32>, branch: Option<&str>, commit: Option<&str>) -> Result<models::ActionRunList, Error<ListRepositoryRunsError>> { 130 let local_var_configuration = configuration; 131 132 let local_var_client = &local_var_configuration.client; 133 134 let local_var_uri_str = format!("{}/repositories/{repository}/actions/runs", local_var_configuration.base_path, repository=crate::apis::urlencode(repository)); 135 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 136 137 if let Some(ref local_var_str) = after { 138 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 139 } 140 if let Some(ref local_var_str) = amount { 141 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 142 } 143 if let Some(ref local_var_str) = branch { 144 local_var_req_builder = local_var_req_builder.query(&[("branch", &local_var_str.to_string())]); 145 } 146 if let Some(ref local_var_str) = commit { 147 local_var_req_builder = local_var_req_builder.query(&[("commit", &local_var_str.to_string())]); 148 } 149 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 150 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 151 } 152 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 153 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 154 }; 155 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 156 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 157 }; 158 159 let local_var_req = local_var_req_builder.build()?; 160 let local_var_resp = local_var_client.execute(local_var_req).await?; 161 162 let local_var_status = local_var_resp.status(); 163 let local_var_content = local_var_resp.text().await?; 164 165 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 166 serde_json::from_str(&local_var_content).map_err(Error::from) 167 } else { 168 let local_var_entity: Option<ListRepositoryRunsError> = serde_json::from_str(&local_var_content).ok(); 169 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 170 Err(Error::ResponseError(local_var_error)) 171 } 172 } 173 174 pub async fn list_run_hooks(configuration: &configuration::Configuration, repository: &str, run_id: &str, after: Option<&str>, amount: Option<i32>) -> Result<models::HookRunList, Error<ListRunHooksError>> { 175 let local_var_configuration = configuration; 176 177 let local_var_client = &local_var_configuration.client; 178 179 let local_var_uri_str = format!("{}/repositories/{repository}/actions/runs/{run_id}/hooks", local_var_configuration.base_path, repository=crate::apis::urlencode(repository), run_id=crate::apis::urlencode(run_id)); 180 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 181 182 if let Some(ref local_var_str) = after { 183 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 184 } 185 if let Some(ref local_var_str) = amount { 186 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 187 } 188 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 189 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 190 } 191 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 192 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 193 }; 194 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 195 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 196 }; 197 198 let local_var_req = local_var_req_builder.build()?; 199 let local_var_resp = local_var_client.execute(local_var_req).await?; 200 201 let local_var_status = local_var_resp.status(); 202 let local_var_content = local_var_resp.text().await?; 203 204 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 205 serde_json::from_str(&local_var_content).map_err(Error::from) 206 } else { 207 let local_var_entity: Option<ListRunHooksError> = serde_json::from_str(&local_var_content).ok(); 208 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 209 Err(Error::ResponseError(local_var_error)) 210 } 211 } 212