render_api/request/
update_service.rs

1use serde_json::json;
2use crate::model::*;
3use crate::RenderClient;
4use httpclient::InMemoryResponseExt;
5/**Create this with the associated client method.
6
7That method takes required values as arguments. Set optional values using builder methods on this struct.*/
8#[derive(Clone)]
9pub struct UpdateServiceRequest<'a> {
10    pub(crate) http_client: &'a RenderClient,
11    pub auto_deploy: Option<String>,
12    pub branch: Option<String>,
13    pub name: Option<String>,
14    pub service_details: Option<serde_json::Value>,
15    pub service_id: String,
16}
17impl<'a> UpdateServiceRequest<'a> {
18    pub async fn send(self) -> ::httpclient::InMemoryResult<Service> {
19        let mut r = self
20            .http_client
21            .client
22            .patch(&format!("/services/{service_id}", service_id = self.service_id));
23        if let Some(ref unwrapped) = self.auto_deploy {
24            r = r.json(json!({ "autoDeploy" : unwrapped }));
25        }
26        if let Some(ref unwrapped) = self.branch {
27            r = r.json(json!({ "branch" : unwrapped }));
28        }
29        if let Some(ref unwrapped) = self.name {
30            r = r.json(json!({ "name" : unwrapped }));
31        }
32        if let Some(ref unwrapped) = self.service_details {
33            r = r.json(json!({ "serviceDetails" : unwrapped }));
34        }
35        r = self.http_client.authenticate(r);
36        let res = r.await?;
37        res.json().map_err(Into::into)
38    }
39    pub fn auto_deploy(mut self, auto_deploy: &str) -> Self {
40        self.auto_deploy = Some(auto_deploy.to_owned());
41        self
42    }
43    pub fn branch(mut self, branch: &str) -> Self {
44        self.branch = Some(branch.to_owned());
45        self
46    }
47    pub fn name(mut self, name: &str) -> Self {
48        self.name = Some(name.to_owned());
49        self
50    }
51    pub fn service_details(mut self, service_details: serde_json::Value) -> Self {
52        self.service_details = Some(service_details);
53        self
54    }
55}
56impl<'a> ::std::future::IntoFuture for UpdateServiceRequest<'a> {
57    type Output = httpclient::InMemoryResult<Service>;
58    type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
59    fn into_future(self) -> Self::IntoFuture {
60        Box::pin(self.send())
61    }
62}