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