render_api/request/
trigger_deploy.rs1use serde_json::json;
2use crate::model::*;
3use crate::RenderClient;
4use httpclient::InMemoryResponseExt;
5#[derive(Clone)]
9pub struct TriggerDeployRequest<'a> {
10 pub(crate) http_client: &'a RenderClient,
11 pub clear_cache: Option<String>,
12 pub service_id: String,
13}
14impl<'a> TriggerDeployRequest<'a> {
15 pub async fn send(self) -> ::httpclient::InMemoryResult<Deploy> {
16 let mut r = self
17 .http_client
18 .client
19 .post(
20 &format!("/services/{service_id}/deploys", service_id = self.service_id),
21 );
22 if let Some(ref unwrapped) = self.clear_cache {
23 r = r.json(json!({ "clearCache" : unwrapped }));
24 }
25 r = self.http_client.authenticate(r);
26 let res = r.await?;
27 res.json().map_err(Into::into)
28 }
29 pub fn clear_cache(mut self, clear_cache: &str) -> Self {
30 self.clear_cache = Some(clear_cache.to_owned());
31 self
32 }
33}
34impl<'a> ::std::future::IntoFuture for TriggerDeployRequest<'a> {
35 type Output = httpclient::InMemoryResult<Deploy>;
36 type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
37 fn into_future(self) -> Self::IntoFuture {
38 Box::pin(self.send())
39 }
40}