mesa_dev_oapi/apis/
agent_blame_api.rs1use 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 GetByOrgByRepoAgentblameError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetByOrgByRepoAnalyticsError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum PostByOrgByRepoAnalyticsRefreshError {
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
61pub async fn get_by_org_by_repo_agentblame(configuration: &configuration::Configuration, org: &str, repo: &str, base: &str, head: &str) -> Result<models::GetByOrgByRepoAgentblame200Response, Error<GetByOrgByRepoAgentblameError>> {
63 let p_path_org = org;
65 let p_path_repo = repo;
66 let p_query_base = base;
67 let p_query_head = head;
68
69 let uri_str = format!("{}/{org}/{repo}/agentblame", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
70 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
71
72 req_builder = req_builder.query(&[("base", &p_query_base.to_string())]);
73 req_builder = req_builder.query(&[("head", &p_query_head.to_string())]);
74 if let Some(ref user_agent) = configuration.user_agent {
75 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
76 }
77 if let Some(ref token) = configuration.bearer_access_token {
78 req_builder = req_builder.bearer_auth(token.to_owned());
79 };
80
81 let req = req_builder.build()?;
82 let resp = configuration.client.execute(req).await?;
83
84 let status = resp.status();
85 let content_type = resp
86 .headers()
87 .get("content-type")
88 .and_then(|v| v.to_str().ok())
89 .unwrap_or("application/octet-stream");
90 let content_type = super::ContentType::from(content_type);
91
92 if !status.is_client_error() && !status.is_server_error() {
93 let content = resp.text().await?;
94 match content_type {
95 ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
96 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetByOrgByRepoAgentblame200Response`"))),
97 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::GetByOrgByRepoAgentblame200Response`")))),
98 }
99 } else {
100 let content = resp.text().await?;
101 let entity: Option<GetByOrgByRepoAgentblameError> = serde_json::from_str(&content).ok();
102 Err(Error::ResponseError(ResponseContent { status, content, entity }))
103 }
104}
105
106pub async fn get_by_org_by_repo_analytics(configuration: &configuration::Configuration, org: &str, repo: &str, period: Option<&str>) -> Result<models::GetByOrgByRepoAnalytics200Response, Error<GetByOrgByRepoAnalyticsError>> {
108 let p_path_org = org;
110 let p_path_repo = repo;
111 let p_query_period = period;
112
113 let uri_str = format!("{}/{org}/{repo}/analytics", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
114 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
115
116 if let Some(ref param_value) = p_query_period {
117 req_builder = req_builder.query(&[("period", ¶m_value.to_string())]);
118 }
119 if let Some(ref user_agent) = configuration.user_agent {
120 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
121 }
122 if let Some(ref token) = configuration.bearer_access_token {
123 req_builder = req_builder.bearer_auth(token.to_owned());
124 };
125
126 let req = req_builder.build()?;
127 let resp = configuration.client.execute(req).await?;
128
129 let status = resp.status();
130 let content_type = resp
131 .headers()
132 .get("content-type")
133 .and_then(|v| v.to_str().ok())
134 .unwrap_or("application/octet-stream");
135 let content_type = super::ContentType::from(content_type);
136
137 if !status.is_client_error() && !status.is_server_error() {
138 let content = resp.text().await?;
139 match content_type {
140 ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
141 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetByOrgByRepoAnalytics200Response`"))),
142 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::GetByOrgByRepoAnalytics200Response`")))),
143 }
144 } else {
145 let content = resp.text().await?;
146 let entity: Option<GetByOrgByRepoAnalyticsError> = serde_json::from_str(&content).ok();
147 Err(Error::ResponseError(ResponseContent { status, content, entity }))
148 }
149}
150
151pub async fn post_by_org_by_repo_analytics_refresh(configuration: &configuration::Configuration, org: &str, repo: &str) -> Result<models::GetByOrgByRepoAnalytics200Response, Error<PostByOrgByRepoAnalyticsRefreshError>> {
153 let p_path_org = org;
155 let p_path_repo = repo;
156
157 let uri_str = format!("{}/{org}/{repo}/analytics/refresh", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
158 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
159
160 if let Some(ref user_agent) = configuration.user_agent {
161 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
162 }
163 if let Some(ref token) = configuration.bearer_access_token {
164 req_builder = req_builder.bearer_auth(token.to_owned());
165 };
166
167 let req = req_builder.build()?;
168 let resp = configuration.client.execute(req).await?;
169
170 let status = resp.status();
171 let content_type = resp
172 .headers()
173 .get("content-type")
174 .and_then(|v| v.to_str().ok())
175 .unwrap_or("application/octet-stream");
176 let content_type = super::ContentType::from(content_type);
177
178 if !status.is_client_error() && !status.is_server_error() {
179 let content = resp.text().await?;
180 match content_type {
181 ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
182 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetByOrgByRepoAnalytics200Response`"))),
183 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::GetByOrgByRepoAnalytics200Response`")))),
184 }
185 } else {
186 let content = resp.text().await?;
187 let entity: Option<PostByOrgByRepoAnalyticsRefreshError> = serde_json::from_str(&content).ok();
188 Err(Error::ResponseError(ResponseContent { status, content, entity }))
189 }
190}
191