mesa_dev_oapi/apis/
webhooks_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 DeleteByOrgByRepoWebhooksByWebhookIdError {
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 GetByOrgByRepoWebhooksError {
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 PostByOrgByRepoWebhooksError {
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 delete_by_org_by_repo_webhooks_by_webhook_id(configuration: &configuration::Configuration, org: &str, repo: &str, webhook_id: &str) -> Result<models::DeleteByOrgApiKeysById200Response, Error<DeleteByOrgByRepoWebhooksByWebhookIdError>> {
63 let p_path_org = org;
65 let p_path_repo = repo;
66 let p_path_webhook_id = webhook_id;
67
68 let uri_str = format!("{}/{org}/{repo}/webhooks/{webhookId}", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo), webhookId=crate::apis::urlencode(p_path_webhook_id));
69 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
70
71 if let Some(ref user_agent) = configuration.user_agent {
72 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
73 }
74 if let Some(ref token) = configuration.bearer_access_token {
75 req_builder = req_builder.bearer_auth(token.to_owned());
76 };
77
78 let req = req_builder.build()?;
79 let resp = configuration.client.execute(req).await?;
80
81 let status = resp.status();
82 let content_type = resp
83 .headers()
84 .get("content-type")
85 .and_then(|v| v.to_str().ok())
86 .unwrap_or("application/octet-stream");
87 let content_type = super::ContentType::from(content_type);
88
89 if !status.is_client_error() && !status.is_server_error() {
90 let content = resp.text().await?;
91 match content_type {
92 ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
93 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteByOrgApiKeysById200Response`"))),
94 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`")))),
95 }
96 } else {
97 let content = resp.text().await?;
98 let entity: Option<DeleteByOrgByRepoWebhooksByWebhookIdError> = serde_json::from_str(&content).ok();
99 Err(Error::ResponseError(ResponseContent { status, content, entity }))
100 }
101}
102
103pub async fn get_by_org_by_repo_webhooks(configuration: &configuration::Configuration, org: &str, repo: &str) -> Result<models::GetByOrgByRepoWebhooks200Response, Error<GetByOrgByRepoWebhooksError>> {
105 let p_path_org = org;
107 let p_path_repo = repo;
108
109 let uri_str = format!("{}/{org}/{repo}/webhooks", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
110 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
111
112 if let Some(ref user_agent) = configuration.user_agent {
113 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
114 }
115 if let Some(ref token) = configuration.bearer_access_token {
116 req_builder = req_builder.bearer_auth(token.to_owned());
117 };
118
119 let req = req_builder.build()?;
120 let resp = configuration.client.execute(req).await?;
121
122 let status = resp.status();
123 let content_type = resp
124 .headers()
125 .get("content-type")
126 .and_then(|v| v.to_str().ok())
127 .unwrap_or("application/octet-stream");
128 let content_type = super::ContentType::from(content_type);
129
130 if !status.is_client_error() && !status.is_server_error() {
131 let content = resp.text().await?;
132 match content_type {
133 ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
134 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetByOrgByRepoWebhooks200Response`"))),
135 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::GetByOrgByRepoWebhooks200Response`")))),
136 }
137 } else {
138 let content = resp.text().await?;
139 let entity: Option<GetByOrgByRepoWebhooksError> = serde_json::from_str(&content).ok();
140 Err(Error::ResponseError(ResponseContent { status, content, entity }))
141 }
142}
143
144pub async fn post_by_org_by_repo_webhooks(configuration: &configuration::Configuration, org: &str, repo: &str, post_by_org_by_repo_webhooks_request: Option<models::PostByOrgByRepoWebhooksRequest>) -> Result<models::PostByOrgByRepoWebhooks201Response, Error<PostByOrgByRepoWebhooksError>> {
146 let p_path_org = org;
148 let p_path_repo = repo;
149 let p_body_post_by_org_by_repo_webhooks_request = post_by_org_by_repo_webhooks_request;
150
151 let uri_str = format!("{}/{org}/{repo}/webhooks", configuration.base_path, org=crate::apis::urlencode(p_path_org), repo=crate::apis::urlencode(p_path_repo));
152 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
153
154 if let Some(ref user_agent) = configuration.user_agent {
155 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156 }
157 if let Some(ref token) = configuration.bearer_access_token {
158 req_builder = req_builder.bearer_auth(token.to_owned());
159 };
160 req_builder = req_builder.json(&p_body_post_by_org_by_repo_webhooks_request);
161
162 let req = req_builder.build()?;
163 let resp = configuration.client.execute(req).await?;
164
165 let status = resp.status();
166 let content_type = resp
167 .headers()
168 .get("content-type")
169 .and_then(|v| v.to_str().ok())
170 .unwrap_or("application/octet-stream");
171 let content_type = super::ContentType::from(content_type);
172
173 if !status.is_client_error() && !status.is_server_error() {
174 let content = resp.text().await?;
175 match content_type {
176 ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
177 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PostByOrgByRepoWebhooks201Response`"))),
178 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::PostByOrgByRepoWebhooks201Response`")))),
179 }
180 } else {
181 let content = resp.text().await?;
182 let entity: Option<PostByOrgByRepoWebhooksError> = serde_json::from_str(&content).ok();
183 Err(Error::ResponseError(ResponseContent { status, content, entity }))
184 }
185}
186