render_api/request/
list_services.rs1use serde_json::json;
2use crate::model::*;
3use crate::RenderClient;
4use httpclient::InMemoryResponseExt;
5#[derive(Clone)]
9pub struct ListServicesRequest<'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 env: Option<String>,
15 pub limit: Option<i64>,
16 pub name: Option<String>,
17 pub owner_id: Option<String>,
18 pub region: Option<String>,
19 pub suspended: Option<String>,
20 pub type_: Option<String>,
21 pub updated_after: Option<String>,
22 pub updated_before: Option<String>,
23}
24impl<'a> ListServicesRequest<'a> {
25 pub async fn send(self) -> ::httpclient::InMemoryResult<Vec<ServiceCursor>> {
26 let mut r = self.http_client.client.get("/services");
27 if let Some(ref unwrapped) = self.created_after {
28 r = r.query("createdAfter", &unwrapped.to_string());
29 }
30 if let Some(ref unwrapped) = self.created_before {
31 r = r.query("createdBefore", &unwrapped.to_string());
32 }
33 if let Some(ref unwrapped) = self.cursor {
34 r = r.query("cursor", &unwrapped.to_string());
35 }
36 if let Some(ref unwrapped) = self.env {
37 r = r.query("env", &unwrapped.to_string());
38 }
39 if let Some(ref unwrapped) = self.limit {
40 r = r.query("limit", &unwrapped.to_string());
41 }
42 if let Some(ref unwrapped) = self.name {
43 r = r.query("name", &unwrapped.to_string());
44 }
45 if let Some(ref unwrapped) = self.owner_id {
46 r = r.query("ownerId", &unwrapped.to_string());
47 }
48 if let Some(ref unwrapped) = self.region {
49 r = r.query("region", &unwrapped.to_string());
50 }
51 if let Some(ref unwrapped) = self.suspended {
52 r = r.query("suspended", &unwrapped.to_string());
53 }
54 if let Some(ref unwrapped) = self.type_ {
55 r = r.query("type", &unwrapped.to_string());
56 }
57 if let Some(ref unwrapped) = self.updated_after {
58 r = r.query("updatedAfter", &unwrapped.to_string());
59 }
60 if let Some(ref unwrapped) = self.updated_before {
61 r = r.query("updatedBefore", &unwrapped.to_string());
62 }
63 r = self.http_client.authenticate(r);
64 let res = r.await?;
65 res.json().map_err(Into::into)
66 }
67 pub fn created_after(mut self, created_after: &str) -> Self {
68 self.created_after = Some(created_after.to_owned());
69 self
70 }
71 pub fn created_before(mut self, created_before: &str) -> Self {
72 self.created_before = Some(created_before.to_owned());
73 self
74 }
75 pub fn cursor(mut self, cursor: &str) -> Self {
76 self.cursor = Some(cursor.to_owned());
77 self
78 }
79 pub fn env(mut self, env: &str) -> Self {
80 self.env = Some(env.to_owned());
81 self
82 }
83 pub fn limit(mut self, limit: i64) -> Self {
84 self.limit = Some(limit);
85 self
86 }
87 pub fn name(mut self, name: &str) -> Self {
88 self.name = Some(name.to_owned());
89 self
90 }
91 pub fn owner_id(mut self, owner_id: &str) -> Self {
92 self.owner_id = Some(owner_id.to_owned());
93 self
94 }
95 pub fn region(mut self, region: &str) -> Self {
96 self.region = Some(region.to_owned());
97 self
98 }
99 pub fn suspended(mut self, suspended: &str) -> Self {
100 self.suspended = Some(suspended.to_owned());
101 self
102 }
103 pub fn type_(mut self, type_: &str) -> Self {
104 self.type_ = Some(type_.to_owned());
105 self
106 }
107 pub fn updated_after(mut self, updated_after: &str) -> Self {
108 self.updated_after = Some(updated_after.to_owned());
109 self
110 }
111 pub fn updated_before(mut self, updated_before: &str) -> Self {
112 self.updated_before = Some(updated_before.to_owned());
113 self
114 }
115}
116impl<'a> ::std::future::IntoFuture for ListServicesRequest<'a> {
117 type Output = httpclient::InMemoryResult<Vec<ServiceCursor>>;
118 type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
119 fn into_future(self) -> Self::IntoFuture {
120 Box::pin(self.send())
121 }
122}