render_api/request/
add_custom_domain.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 AddCustomDomainRequest<'a> {
10    pub(crate) http_client: &'a RenderClient,
11    pub name: Option<String>,
12    pub service_id: String,
13}
14impl<'a> AddCustomDomainRequest<'a> {
15    pub async fn send(self) -> ::httpclient::InMemoryResult<Vec<serde_json::Value>> {
16        let mut r = self
17            .http_client
18            .client
19            .post(
20                &format!(
21                    "/services/{service_id}/custom-domains", service_id = self.service_id
22                ),
23            );
24        if let Some(ref unwrapped) = self.name {
25            r = r.json(json!({ "name" : unwrapped }));
26        }
27        r = self.http_client.authenticate(r);
28        let res = r.await?;
29        res.json().map_err(Into::into)
30    }
31    pub fn name(mut self, name: &str) -> Self {
32        self.name = Some(name.to_owned());
33        self
34    }
35}
36impl<'a> ::std::future::IntoFuture for AddCustomDomainRequest<'a> {
37    type Output = httpclient::InMemoryResult<Vec<serde_json::Value>>;
38    type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
39    fn into_future(self) -> Self::IntoFuture {
40        Box::pin(self.send())
41    }
42}