1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CancelSiteDeployError {
22 DefaultResponse(crate::models::Error),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum CreateSiteDeployError {
30 DefaultResponse(crate::models::Error),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum GetDeployError {
38 DefaultResponse(crate::models::Error),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum GetSiteDeployError {
46 DefaultResponse(crate::models::Error),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum ListSiteDeploysError {
54 DefaultResponse(crate::models::Error),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum LockDeployError {
62 DefaultResponse(crate::models::Error),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum RestoreSiteDeployError {
70 DefaultResponse(crate::models::Error),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum RollbackSiteDeployError {
78 DefaultResponse(crate::models::Error),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum UnlockDeployError {
86 DefaultResponse(crate::models::Error),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum UpdateSiteDeployError {
94 DefaultResponse(crate::models::Error),
95 UnknownValue(serde_json::Value),
96}
97
98
99pub async fn cancel_site_deploy(configuration: &configuration::Configuration, deploy_id: &str) -> Result<crate::models::Deploy, Error<CancelSiteDeployError>> {
100
101 let local_var_client = &configuration.client;
102
103 let local_var_uri_str = format!("{}/deploys/{deploy_id}/cancel", configuration.base_path, deploy_id=crate::apis::urlencode(deploy_id));
104 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
105
106 if let Some(ref local_var_user_agent) = configuration.user_agent {
107 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
108 }
109 if let Some(ref local_var_token) = configuration.oauth_access_token {
110 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
111 };
112
113 let local_var_req = local_var_req_builder.build()?;
114 let local_var_resp = local_var_client.execute(local_var_req).await?;
115
116 let local_var_status = local_var_resp.status();
117 let local_var_content = local_var_resp.text().await?;
118
119 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
120 serde_json::from_str(&local_var_content).map_err(Error::from)
121 } else {
122 let local_var_entity: Option<CancelSiteDeployError> = serde_json::from_str(&local_var_content).ok();
123 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
124 Err(Error::ResponseError(local_var_error))
125 }
126}
127
128pub async fn create_site_deploy(configuration: &configuration::Configuration, site_id: &str, deploy: crate::models::DeployFiles, title: Option<&str>) -> Result<crate::models::Deploy, Error<CreateSiteDeployError>> {
129
130 let local_var_client = &configuration.client;
131
132 let local_var_uri_str = format!("{}/sites/{site_id}/deploys", configuration.base_path, site_id=crate::apis::urlencode(site_id));
133 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
134
135 if let Some(ref local_var_str) = title {
136 local_var_req_builder = local_var_req_builder.query(&[("title", &local_var_str.to_string())]);
137 }
138 if let Some(ref local_var_user_agent) = configuration.user_agent {
139 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
140 }
141 if let Some(ref local_var_token) = configuration.oauth_access_token {
142 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
143 };
144 local_var_req_builder = local_var_req_builder.json(&deploy);
145
146 let local_var_req = local_var_req_builder.build()?;
147 let local_var_resp = local_var_client.execute(local_var_req).await?;
148
149 let local_var_status = local_var_resp.status();
150 let local_var_content = local_var_resp.text().await?;
151
152 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
153 serde_json::from_str(&local_var_content).map_err(Error::from)
154 } else {
155 let local_var_entity: Option<CreateSiteDeployError> = serde_json::from_str(&local_var_content).ok();
156 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
157 Err(Error::ResponseError(local_var_error))
158 }
159}
160
161pub async fn get_deploy(configuration: &configuration::Configuration, deploy_id: &str) -> Result<crate::models::Deploy, Error<GetDeployError>> {
162
163 let local_var_client = &configuration.client;
164
165 let local_var_uri_str = format!("{}/deploys/{deploy_id}", configuration.base_path, deploy_id=crate::apis::urlencode(deploy_id));
166 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
167
168 if let Some(ref local_var_user_agent) = configuration.user_agent {
169 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
170 }
171 if let Some(ref local_var_token) = configuration.oauth_access_token {
172 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
173 };
174
175 let local_var_req = local_var_req_builder.build()?;
176 let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178 let local_var_status = local_var_resp.status();
179 let local_var_content = local_var_resp.text().await?;
180
181 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182 serde_json::from_str(&local_var_content).map_err(Error::from)
183 } else {
184 let local_var_entity: Option<GetDeployError> = serde_json::from_str(&local_var_content).ok();
185 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186 Err(Error::ResponseError(local_var_error))
187 }
188}
189
190pub async fn get_site_deploy(configuration: &configuration::Configuration, site_id: &str, deploy_id: &str) -> Result<crate::models::Deploy, Error<GetSiteDeployError>> {
191
192 let local_var_client = &configuration.client;
193
194 let local_var_uri_str = format!("{}/sites/{site_id}/deploys/{deploy_id}", configuration.base_path, site_id=crate::apis::urlencode(site_id), deploy_id=crate::apis::urlencode(deploy_id));
195 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
196
197 if let Some(ref local_var_user_agent) = configuration.user_agent {
198 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
199 }
200 if let Some(ref local_var_token) = configuration.oauth_access_token {
201 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
202 };
203
204 let local_var_req = local_var_req_builder.build()?;
205 let local_var_resp = local_var_client.execute(local_var_req).await?;
206
207 let local_var_status = local_var_resp.status();
208 let local_var_content = local_var_resp.text().await?;
209
210 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
211 serde_json::from_str(&local_var_content).map_err(Error::from)
212 } else {
213 let local_var_entity: Option<GetSiteDeployError> = serde_json::from_str(&local_var_content).ok();
214 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
215 Err(Error::ResponseError(local_var_error))
216 }
217}
218
219pub async fn list_site_deploys(configuration: &configuration::Configuration, site_id: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<crate::models::Deploy>, Error<ListSiteDeploysError>> {
220
221 let local_var_client = &configuration.client;
222
223 let local_var_uri_str = format!("{}/sites/{site_id}/deploys", configuration.base_path, site_id=crate::apis::urlencode(site_id));
224 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
225
226 if let Some(ref local_var_str) = page {
227 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
228 }
229 if let Some(ref local_var_str) = per_page {
230 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
231 }
232 if let Some(ref local_var_user_agent) = configuration.user_agent {
233 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
234 }
235 if let Some(ref local_var_token) = configuration.oauth_access_token {
236 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
237 };
238
239 let local_var_req = local_var_req_builder.build()?;
240 let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242 let local_var_status = local_var_resp.status();
243 let local_var_content = local_var_resp.text().await?;
244
245 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246 serde_json::from_str(&local_var_content).map_err(Error::from)
247 } else {
248 let local_var_entity: Option<ListSiteDeploysError> = serde_json::from_str(&local_var_content).ok();
249 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
250 Err(Error::ResponseError(local_var_error))
251 }
252}
253
254pub async fn lock_deploy(configuration: &configuration::Configuration, deploy_id: &str) -> Result<crate::models::Deploy, Error<LockDeployError>> {
255
256 let local_var_client = &configuration.client;
257
258 let local_var_uri_str = format!("{}/deploys/{deploy_id}/lock", configuration.base_path, deploy_id=crate::apis::urlencode(deploy_id));
259 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
260
261 if let Some(ref local_var_user_agent) = configuration.user_agent {
262 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
263 }
264 if let Some(ref local_var_token) = configuration.oauth_access_token {
265 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
266 };
267
268 let local_var_req = local_var_req_builder.build()?;
269 let local_var_resp = local_var_client.execute(local_var_req).await?;
270
271 let local_var_status = local_var_resp.status();
272 let local_var_content = local_var_resp.text().await?;
273
274 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
275 serde_json::from_str(&local_var_content).map_err(Error::from)
276 } else {
277 let local_var_entity: Option<LockDeployError> = serde_json::from_str(&local_var_content).ok();
278 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
279 Err(Error::ResponseError(local_var_error))
280 }
281}
282
283pub async fn restore_site_deploy(configuration: &configuration::Configuration, site_id: &str, deploy_id: &str) -> Result<crate::models::Deploy, Error<RestoreSiteDeployError>> {
284
285 let local_var_client = &configuration.client;
286
287 let local_var_uri_str = format!("{}/sites/{site_id}/deploys/{deploy_id}/restore", configuration.base_path, site_id=crate::apis::urlencode(site_id), deploy_id=crate::apis::urlencode(deploy_id));
288 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
289
290 if let Some(ref local_var_user_agent) = configuration.user_agent {
291 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
292 }
293 if let Some(ref local_var_token) = configuration.oauth_access_token {
294 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
295 };
296
297 let local_var_req = local_var_req_builder.build()?;
298 let local_var_resp = local_var_client.execute(local_var_req).await?;
299
300 let local_var_status = local_var_resp.status();
301 let local_var_content = local_var_resp.text().await?;
302
303 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
304 serde_json::from_str(&local_var_content).map_err(Error::from)
305 } else {
306 let local_var_entity: Option<RestoreSiteDeployError> = serde_json::from_str(&local_var_content).ok();
307 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
308 Err(Error::ResponseError(local_var_error))
309 }
310}
311
312pub async fn rollback_site_deploy(configuration: &configuration::Configuration, site_id: &str) -> Result<(), Error<RollbackSiteDeployError>> {
313
314 let local_var_client = &configuration.client;
315
316 let local_var_uri_str = format!("{}/sites/{site_id}/rollback", configuration.base_path, site_id=crate::apis::urlencode(site_id));
317 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
318
319 if let Some(ref local_var_user_agent) = configuration.user_agent {
320 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
321 }
322 if let Some(ref local_var_token) = configuration.oauth_access_token {
323 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
324 };
325
326 let local_var_req = local_var_req_builder.build()?;
327 let local_var_resp = local_var_client.execute(local_var_req).await?;
328
329 let local_var_status = local_var_resp.status();
330 let local_var_content = local_var_resp.text().await?;
331
332 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
333 Ok(())
334 } else {
335 let local_var_entity: Option<RollbackSiteDeployError> = serde_json::from_str(&local_var_content).ok();
336 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
337 Err(Error::ResponseError(local_var_error))
338 }
339}
340
341pub async fn unlock_deploy(configuration: &configuration::Configuration, deploy_id: &str) -> Result<crate::models::Deploy, Error<UnlockDeployError>> {
342
343 let local_var_client = &configuration.client;
344
345 let local_var_uri_str = format!("{}/deploys/{deploy_id}/unlock", configuration.base_path, deploy_id=crate::apis::urlencode(deploy_id));
346 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
347
348 if let Some(ref local_var_user_agent) = configuration.user_agent {
349 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
350 }
351 if let Some(ref local_var_token) = configuration.oauth_access_token {
352 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
353 };
354
355 let local_var_req = local_var_req_builder.build()?;
356 let local_var_resp = local_var_client.execute(local_var_req).await?;
357
358 let local_var_status = local_var_resp.status();
359 let local_var_content = local_var_resp.text().await?;
360
361 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
362 serde_json::from_str(&local_var_content).map_err(Error::from)
363 } else {
364 let local_var_entity: Option<UnlockDeployError> = serde_json::from_str(&local_var_content).ok();
365 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
366 Err(Error::ResponseError(local_var_error))
367 }
368}
369
370pub async fn update_site_deploy(configuration: &configuration::Configuration, site_id: &str, deploy_id: &str, deploy: crate::models::DeployFiles) -> Result<crate::models::Deploy, Error<UpdateSiteDeployError>> {
371
372 let local_var_client = &configuration.client;
373
374 let local_var_uri_str = format!("{}/sites/{site_id}/deploys/{deploy_id}", configuration.base_path, site_id=crate::apis::urlencode(site_id), deploy_id=crate::apis::urlencode(deploy_id));
375 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
376
377 if let Some(ref local_var_user_agent) = configuration.user_agent {
378 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
379 }
380 if let Some(ref local_var_token) = configuration.oauth_access_token {
381 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
382 };
383 local_var_req_builder = local_var_req_builder.json(&deploy);
384
385 let local_var_req = local_var_req_builder.build()?;
386 let local_var_resp = local_var_client.execute(local_var_req).await?;
387
388 let local_var_status = local_var_resp.status();
389 let local_var_content = local_var_resp.text().await?;
390
391 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
392 serde_json::from_str(&local_var_content).map_err(Error::from)
393 } else {
394 let local_var_entity: Option<UpdateSiteDeployError> = serde_json::from_str(&local_var_content).ok();
395 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
396 Err(Error::ResponseError(local_var_error))
397 }
398}
399