render_api/request/
retrieve_headers.rs1use serde_json::json;
2use crate::model::*;
3use crate::RenderClient;
4use httpclient::InMemoryResponseExt;
5#[derive(Clone)]
9pub struct RetrieveHeadersRequest<'a> {
10 pub(crate) http_client: &'a RenderClient,
11 pub cursor: Option<String>,
12 pub limit: Option<String>,
13 pub name: Option<String>,
14 pub path: Option<String>,
15 pub service_id: String,
16 pub value: Option<String>,
17}
18impl<'a> RetrieveHeadersRequest<'a> {
19 pub async fn send(self) -> ::httpclient::InMemoryResult<Vec<serde_json::Value>> {
20 let mut r = self
21 .http_client
22 .client
23 .get(
24 &format!("/services/{service_id}/headers", service_id = self.service_id),
25 );
26 if let Some(ref unwrapped) = self.cursor {
27 r = r.query("cursor", &unwrapped.to_string());
28 }
29 if let Some(ref unwrapped) = self.limit {
30 r = r.query("limit", &unwrapped.to_string());
31 }
32 if let Some(ref unwrapped) = self.name {
33 r = r.query("name", &unwrapped.to_string());
34 }
35 if let Some(ref unwrapped) = self.path {
36 r = r.query("path", &unwrapped.to_string());
37 }
38 if let Some(ref unwrapped) = self.value {
39 r = r.query("value", &unwrapped.to_string());
40 }
41 r = self.http_client.authenticate(r);
42 let res = r.await?;
43 res.json().map_err(Into::into)
44 }
45 pub fn cursor(mut self, cursor: &str) -> Self {
46 self.cursor = Some(cursor.to_owned());
47 self
48 }
49 pub fn limit(mut self, limit: &str) -> Self {
50 self.limit = Some(limit.to_owned());
51 self
52 }
53 pub fn name(mut self, name: &str) -> Self {
54 self.name = Some(name.to_owned());
55 self
56 }
57 pub fn path(mut self, path: &str) -> Self {
58 self.path = Some(path.to_owned());
59 self
60 }
61 pub fn value(mut self, value: &str) -> Self {
62 self.value = Some(value.to_owned());
63 self
64 }
65}
66impl<'a> ::std::future::IntoFuture for RetrieveHeadersRequest<'a> {
67 type Output = httpclient::InMemoryResult<Vec<serde_json::Value>>;
68 type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
69 fn into_future(self) -> Self::IntoFuture {
70 Box::pin(self.send())
71 }
72}