render_api/request/
list_jobs.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 ListJobsRequest<'a> {
10    pub(crate) http_client: &'a RenderClient,
11    pub created_after: Option<String>,
12    pub created_before: Option<String>,
13    pub cursor: Option<String>,
14    pub finished_after: Option<String>,
15    pub finished_before: Option<String>,
16    pub limit: Option<String>,
17    pub service_id: String,
18    pub started_after: Option<String>,
19    pub started_before: Option<String>,
20    pub status: Option<String>,
21}
22impl<'a> ListJobsRequest<'a> {
23    pub async fn send(self) -> ::httpclient::InMemoryResult<Vec<serde_json::Value>> {
24        let mut r = self
25            .http_client
26            .client
27            .get(&format!("/services/{service_id}/jobs", service_id = self.service_id));
28        if let Some(ref unwrapped) = self.created_after {
29            r = r.query("createdAfter", &unwrapped.to_string());
30        }
31        if let Some(ref unwrapped) = self.created_before {
32            r = r.query("createdBefore", &unwrapped.to_string());
33        }
34        if let Some(ref unwrapped) = self.cursor {
35            r = r.query("cursor", &unwrapped.to_string());
36        }
37        if let Some(ref unwrapped) = self.finished_after {
38            r = r.query("finishedAfter", &unwrapped.to_string());
39        }
40        if let Some(ref unwrapped) = self.finished_before {
41            r = r.query("finishedBefore", &unwrapped.to_string());
42        }
43        if let Some(ref unwrapped) = self.limit {
44            r = r.query("limit", &unwrapped.to_string());
45        }
46        if let Some(ref unwrapped) = self.started_after {
47            r = r.query("startedAfter", &unwrapped.to_string());
48        }
49        if let Some(ref unwrapped) = self.started_before {
50            r = r.query("startedBefore", &unwrapped.to_string());
51        }
52        if let Some(ref unwrapped) = self.status {
53            r = r.query("status", &unwrapped.to_string());
54        }
55        r = self.http_client.authenticate(r);
56        let res = r.await?;
57        res.json().map_err(Into::into)
58    }
59    pub fn created_after(mut self, created_after: &str) -> Self {
60        self.created_after = Some(created_after.to_owned());
61        self
62    }
63    pub fn created_before(mut self, created_before: &str) -> Self {
64        self.created_before = Some(created_before.to_owned());
65        self
66    }
67    pub fn cursor(mut self, cursor: &str) -> Self {
68        self.cursor = Some(cursor.to_owned());
69        self
70    }
71    pub fn finished_after(mut self, finished_after: &str) -> Self {
72        self.finished_after = Some(finished_after.to_owned());
73        self
74    }
75    pub fn finished_before(mut self, finished_before: &str) -> Self {
76        self.finished_before = Some(finished_before.to_owned());
77        self
78    }
79    pub fn limit(mut self, limit: &str) -> Self {
80        self.limit = Some(limit.to_owned());
81        self
82    }
83    pub fn started_after(mut self, started_after: &str) -> Self {
84        self.started_after = Some(started_after.to_owned());
85        self
86    }
87    pub fn started_before(mut self, started_before: &str) -> Self {
88        self.started_before = Some(started_before.to_owned());
89        self
90    }
91    pub fn status(mut self, status: &str) -> Self {
92        self.status = Some(status.to_owned());
93        self
94    }
95}
96impl<'a> ::std::future::IntoFuture for ListJobsRequest<'a> {
97    type Output = httpclient::InMemoryResult<Vec<serde_json::Value>>;
98    type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
99    fn into_future(self) -> Self::IntoFuture {
100        Box::pin(self.send())
101    }
102}