render_api/request/
create_service.rs1use serde_json::json;
2use crate::model::*;
3use crate::RenderClient;
4use httpclient::InMemoryResponseExt;
5#[derive(Clone)]
9pub struct CreateServiceRequest<'a> {
10 pub(crate) http_client: &'a RenderClient,
11 pub auto_deploy: Option<String>,
12 pub branch: Option<String>,
13 pub env_vars: Option<Vec<serde_json::Value>>,
14 pub name: Option<String>,
15 pub owner_id: Option<String>,
16 pub repo: Option<String>,
17 pub secret_files: Option<Vec<serde_json::Value>>,
18 pub service_details: Option<serde_json::Value>,
19 pub type_: Option<String>,
20}
21impl<'a> CreateServiceRequest<'a> {
22 pub async fn send(self) -> ::httpclient::InMemoryResult<serde_json::Value> {
23 let mut r = self.http_client.client.post("/services");
24 if let Some(ref unwrapped) = self.auto_deploy {
25 r = r.json(json!({ "autoDeploy" : unwrapped }));
26 }
27 if let Some(ref unwrapped) = self.branch {
28 r = r.json(json!({ "branch" : unwrapped }));
29 }
30 if let Some(ref unwrapped) = self.env_vars {
31 r = r.json(json!({ "envVars" : unwrapped }));
32 }
33 if let Some(ref unwrapped) = self.name {
34 r = r.json(json!({ "name" : unwrapped }));
35 }
36 if let Some(ref unwrapped) = self.owner_id {
37 r = r.json(json!({ "ownerId" : unwrapped }));
38 }
39 if let Some(ref unwrapped) = self.repo {
40 r = r.json(json!({ "repo" : unwrapped }));
41 }
42 if let Some(ref unwrapped) = self.secret_files {
43 r = r.json(json!({ "secretFiles" : unwrapped }));
44 }
45 if let Some(ref unwrapped) = self.service_details {
46 r = r.json(json!({ "serviceDetails" : unwrapped }));
47 }
48 if let Some(ref unwrapped) = self.type_ {
49 r = r.json(json!({ "type" : unwrapped }));
50 }
51 r = self.http_client.authenticate(r);
52 let res = r.await?;
53 res.json().map_err(Into::into)
54 }
55 pub fn auto_deploy(mut self, auto_deploy: &str) -> Self {
56 self.auto_deploy = Some(auto_deploy.to_owned());
57 self
58 }
59 pub fn branch(mut self, branch: &str) -> Self {
60 self.branch = Some(branch.to_owned());
61 self
62 }
63 pub fn env_vars(mut self, env_vars: Vec<serde_json::Value>) -> Self {
64 self.env_vars = Some(env_vars);
65 self
66 }
67 pub fn name(mut self, name: &str) -> Self {
68 self.name = Some(name.to_owned());
69 self
70 }
71 pub fn owner_id(mut self, owner_id: &str) -> Self {
72 self.owner_id = Some(owner_id.to_owned());
73 self
74 }
75 pub fn repo(mut self, repo: &str) -> Self {
76 self.repo = Some(repo.to_owned());
77 self
78 }
79 pub fn secret_files(mut self, secret_files: Vec<serde_json::Value>) -> Self {
80 self.secret_files = Some(secret_files);
81 self
82 }
83 pub fn service_details(mut self, service_details: serde_json::Value) -> Self {
84 self.service_details = Some(service_details);
85 self
86 }
87 pub fn type_(mut self, type_: &str) -> Self {
88 self.type_ = Some(type_.to_owned());
89 self
90 }
91}
92impl<'a> ::std::future::IntoFuture for CreateServiceRequest<'a> {
93 type Output = httpclient::InMemoryResult<serde_json::Value>;
94 type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
95 fn into_future(self) -> Self::IntoFuture {
96 Box::pin(self.send())
97 }
98}