printnanny_api_client/apis/
moonraker_api.rs1use reqwest;
13
14use bytes::Bytes;
15use crate::apis::ResponseContent;
16use super::{Error, configuration};
17
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum MoonrakerCreateError {
23 Status409(crate::models::ErrorDetail),
24 Status400(crate::models::ErrorDetail),
25 Status401(crate::models::ErrorDetail),
26 Status403(crate::models::ErrorDetail),
27 Status500(crate::models::ErrorDetail),
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum MoonrakerListError {
35 Status400(crate::models::ErrorDetail),
36 Status401(crate::models::ErrorDetail),
37 Status403(crate::models::ErrorDetail),
38 Status500(crate::models::ErrorDetail),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum MoonrakerPartialUpdateError {
46 UnknownValue(serde_json::Value),
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum MoonrakerRetrieveError {
53 Status404(crate::models::ErrorDetail),
54 Status400(crate::models::ErrorDetail),
55 Status401(crate::models::ErrorDetail),
56 Status403(crate::models::ErrorDetail),
57 Status500(crate::models::ErrorDetail),
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum MoonrakerServerUpdateOrCreateError {
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum MoonrakerUpdateError {
72 Status409(crate::models::ErrorDetail),
73 Status400(crate::models::ErrorDetail),
74 Status401(crate::models::ErrorDetail),
75 Status403(crate::models::ErrorDetail),
76 Status500(crate::models::ErrorDetail),
77 UnknownValue(serde_json::Value),
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum PisMoonrakerServerListError {
84 Status400(crate::models::ErrorDetail),
85 Status401(crate::models::ErrorDetail),
86 Status403(crate::models::ErrorDetail),
87 Status500(crate::models::ErrorDetail),
88 UnknownValue(serde_json::Value),
89}
90
91
92pub async fn moonraker_create(configuration: &configuration::Configuration, moonraker_server_request: crate::models::MoonrakerServerRequest) -> Result<crate::models::MoonrakerServer, Error<MoonrakerCreateError>> {
93 let local_var_configuration = configuration;
94
95 let local_var_client = &local_var_configuration.client;
96
97 let local_var_uri_str = format!("{}/api/moonraker/", local_var_configuration.base_path);
98 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
99
100 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
101 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
102 }
103 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
104 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
105 };
106 local_var_req_builder = local_var_req_builder.json(&moonraker_server_request);
107
108 let local_var_req = local_var_req_builder.build()?;
109 let local_var_resp = local_var_client.execute(local_var_req).await?;
110
111 let local_var_status = local_var_resp.status();
112 let local_var_content = local_var_resp.text().await?;
113
114 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
115 serde_json::from_str(&local_var_content).map_err(Error::from)
116 } else {
117 let local_var_entity: Option<MoonrakerCreateError> = serde_json::from_str(&local_var_content).ok();
118 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
119 Err(Error::ResponseError(local_var_error))
120 }
121}
122
123pub async fn moonraker_list(configuration: &configuration::Configuration, page: Option<i32>) -> Result<crate::models::PaginatedMoonrakerServerList, Error<MoonrakerListError>> {
124 let local_var_configuration = configuration;
125
126 let local_var_client = &local_var_configuration.client;
127
128 let local_var_uri_str = format!("{}/api/moonraker/", local_var_configuration.base_path);
129 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
130
131 if let Some(ref local_var_str) = page {
132 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
133 }
134 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
135 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
136 }
137 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
138 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
139 };
140
141 let local_var_req = local_var_req_builder.build()?;
142 let local_var_resp = local_var_client.execute(local_var_req).await?;
143
144 let local_var_status = local_var_resp.status();
145 let local_var_content = local_var_resp.text().await?;
146
147 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
148 serde_json::from_str(&local_var_content).map_err(Error::from)
149 } else {
150 let local_var_entity: Option<MoonrakerListError> = serde_json::from_str(&local_var_content).ok();
151 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
152 Err(Error::ResponseError(local_var_error))
153 }
154}
155
156pub async fn moonraker_partial_update(configuration: &configuration::Configuration, id: i32, patched_moonraker_server_request: Option<crate::models::PatchedMoonrakerServerRequest>) -> Result<crate::models::MoonrakerServer, Error<MoonrakerPartialUpdateError>> {
157 let local_var_configuration = configuration;
158
159 let local_var_client = &local_var_configuration.client;
160
161 let local_var_uri_str = format!("{}/api/moonraker/{id}/", local_var_configuration.base_path, id=id);
162 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
163
164 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
165 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
166 }
167 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
168 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
169 };
170 local_var_req_builder = local_var_req_builder.json(&patched_moonraker_server_request);
171
172 let local_var_req = local_var_req_builder.build()?;
173 let local_var_resp = local_var_client.execute(local_var_req).await?;
174
175 let local_var_status = local_var_resp.status();
176 let local_var_content = local_var_resp.text().await?;
177
178 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
179 serde_json::from_str(&local_var_content).map_err(Error::from)
180 } else {
181 let local_var_entity: Option<MoonrakerPartialUpdateError> = serde_json::from_str(&local_var_content).ok();
182 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
183 Err(Error::ResponseError(local_var_error))
184 }
185}
186
187pub async fn moonraker_retrieve(configuration: &configuration::Configuration, id: i32) -> Result<crate::models::MoonrakerServer, Error<MoonrakerRetrieveError>> {
188 let local_var_configuration = configuration;
189
190 let local_var_client = &local_var_configuration.client;
191
192 let local_var_uri_str = format!("{}/api/moonraker/{id}/", local_var_configuration.base_path, id=id);
193 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
194
195 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
196 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
197 }
198 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
199 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
200 };
201
202 let local_var_req = local_var_req_builder.build()?;
203 let local_var_resp = local_var_client.execute(local_var_req).await?;
204
205 let local_var_status = local_var_resp.status();
206 let local_var_content = local_var_resp.text().await?;
207
208 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
209 serde_json::from_str(&local_var_content).map_err(Error::from)
210 } else {
211 let local_var_entity: Option<MoonrakerRetrieveError> = serde_json::from_str(&local_var_content).ok();
212 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
213 Err(Error::ResponseError(local_var_error))
214 }
215}
216
217pub async fn moonraker_server_update_or_create(configuration: &configuration::Configuration, moonraker_server_request: crate::models::MoonrakerServerRequest) -> Result<crate::models::MoonrakerServer, Error<MoonrakerServerUpdateOrCreateError>> {
218 let local_var_configuration = configuration;
219
220 let local_var_client = &local_var_configuration.client;
221
222 let local_var_uri_str = format!("{}/api/moonraker/update-or-create/", local_var_configuration.base_path);
223 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
224
225 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
226 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
227 }
228 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
229 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
230 };
231 local_var_req_builder = local_var_req_builder.json(&moonraker_server_request);
232
233 let local_var_req = local_var_req_builder.build()?;
234 let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236 let local_var_status = local_var_resp.status();
237 let local_var_content = local_var_resp.text().await?;
238
239 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240 serde_json::from_str(&local_var_content).map_err(Error::from)
241 } else {
242 let local_var_entity: Option<MoonrakerServerUpdateOrCreateError> = serde_json::from_str(&local_var_content).ok();
243 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
244 Err(Error::ResponseError(local_var_error))
245 }
246}
247
248pub async fn moonraker_update(configuration: &configuration::Configuration, id: i32, moonraker_server_request: crate::models::MoonrakerServerRequest) -> Result<crate::models::MoonrakerServer, Error<MoonrakerUpdateError>> {
249 let local_var_configuration = configuration;
250
251 let local_var_client = &local_var_configuration.client;
252
253 let local_var_uri_str = format!("{}/api/moonraker/{id}/", local_var_configuration.base_path, id=id);
254 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
255
256 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
257 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
258 }
259 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
260 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
261 };
262 local_var_req_builder = local_var_req_builder.json(&moonraker_server_request);
263
264 let local_var_req = local_var_req_builder.build()?;
265 let local_var_resp = local_var_client.execute(local_var_req).await?;
266
267 let local_var_status = local_var_resp.status();
268 let local_var_content = local_var_resp.text().await?;
269
270 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
271 serde_json::from_str(&local_var_content).map_err(Error::from)
272 } else {
273 let local_var_entity: Option<MoonrakerUpdateError> = serde_json::from_str(&local_var_content).ok();
274 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
275 Err(Error::ResponseError(local_var_error))
276 }
277}
278
279pub async fn pis_moonraker_server_list(configuration: &configuration::Configuration, pi_id: i32, page: Option<i32>) -> Result<crate::models::PaginatedMoonrakerServerList, Error<PisMoonrakerServerListError>> {
280 let local_var_configuration = configuration;
281
282 let local_var_client = &local_var_configuration.client;
283
284 let local_var_uri_str = format!("{}/api/pis/{pi_id}/moonraker-server/", local_var_configuration.base_path, pi_id=pi_id);
285 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
286
287 if let Some(ref local_var_str) = page {
288 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
289 }
290 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
291 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
292 }
293 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
294 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
295 };
296
297 let local_var_req = local_var_req_builder.build()?;
298 let local_var_resp = local_var_client.execute(local_var_req).await?;
299
300 let local_var_status = local_var_resp.status();
301 let local_var_content = local_var_resp.text().await?;
302
303 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
304 serde_json::from_str(&local_var_content).map_err(Error::from)
305 } else {
306 let local_var_entity: Option<PisMoonrakerServerListError> = serde_json::from_str(&local_var_content).ok();
307 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
308 Err(Error::ResponseError(local_var_error))
309 }
310}
311