1use 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 PisCameraSnapshotsCreateError {
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 PisCameraSnapshotsListError {
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 PisCameraSnapshotsRetrieveError {
46 Status404(crate::models::ErrorDetail),
47 Status400(crate::models::ErrorDetail),
48 Status401(crate::models::ErrorDetail),
49 Status403(crate::models::ErrorDetail),
50 Status500(crate::models::ErrorDetail),
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum VideoPartsCreateError {
58 Status409(crate::models::ErrorDetail),
59 Status400(crate::models::ErrorDetail),
60 Status401(crate::models::ErrorDetail),
61 Status403(crate::models::ErrorDetail),
62 Status500(crate::models::ErrorDetail),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum VideoPartsListError {
70 Status400(crate::models::ErrorDetail),
71 Status401(crate::models::ErrorDetail),
72 Status403(crate::models::ErrorDetail),
73 Status500(crate::models::ErrorDetail),
74 UnknownValue(serde_json::Value),
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum VideoPartsRetrieveError {
81 Status404(crate::models::ErrorDetail),
82 Status400(crate::models::ErrorDetail),
83 Status401(crate::models::ErrorDetail),
84 Status403(crate::models::ErrorDetail),
85 Status500(crate::models::ErrorDetail),
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum VideoRecordingsFinalizeError {
93 UnknownValue(serde_json::Value),
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum VideoRecordingsUpdateOrCreateError {
100 Status409(crate::models::ErrorDetail),
101 Status400(crate::models::ErrorDetail),
102 Status401(crate::models::ErrorDetail),
103 Status403(crate::models::ErrorDetail),
104 Status500(crate::models::ErrorDetail),
105 Status404(crate::models::ErrorDetail),
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum VideosCreateError {
113 Status409(crate::models::ErrorDetail),
114 Status400(crate::models::ErrorDetail),
115 Status401(crate::models::ErrorDetail),
116 Status403(crate::models::ErrorDetail),
117 Status500(crate::models::ErrorDetail),
118 UnknownValue(serde_json::Value),
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum VideosListError {
125 Status400(crate::models::ErrorDetail),
126 Status401(crate::models::ErrorDetail),
127 Status403(crate::models::ErrorDetail),
128 Status500(crate::models::ErrorDetail),
129 UnknownValue(serde_json::Value),
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum VideosPartialUpdateError {
136 Status409(crate::models::ErrorDetail),
137 Status400(crate::models::ErrorDetail),
138 Status401(crate::models::ErrorDetail),
139 Status403(crate::models::ErrorDetail),
140 Status500(crate::models::ErrorDetail),
141 UnknownValue(serde_json::Value),
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum VideosRetrieveError {
148 Status404(crate::models::ErrorDetail),
149 Status400(crate::models::ErrorDetail),
150 Status401(crate::models::ErrorDetail),
151 Status403(crate::models::ErrorDetail),
152 Status500(crate::models::ErrorDetail),
153 UnknownValue(serde_json::Value),
154}
155
156#[derive(Debug, Clone, Serialize, Deserialize)]
158#[serde(untagged)]
159pub enum VideosUpdateError {
160 Status409(crate::models::ErrorDetail),
161 Status400(crate::models::ErrorDetail),
162 Status401(crate::models::ErrorDetail),
163 Status403(crate::models::ErrorDetail),
164 Status500(crate::models::ErrorDetail),
165 UnknownValue(serde_json::Value),
166}
167
168
169pub async fn pis_camera_snapshots_create(configuration: &configuration::Configuration, pi_id: i32, image: std::path::PathBuf, pi: i32) -> Result<crate::models::CameraSnapshot, Error<PisCameraSnapshotsCreateError>> {
170 let local_var_configuration = configuration;
171
172 let local_var_client = &local_var_configuration.client;
173
174 let local_var_uri_str = format!("{}/api/pis/{pi_id}/camera-snapshots/", local_var_configuration.base_path, pi_id=pi_id);
175 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
176
177 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
178 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
179 }
180 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
181 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
182 };
183 let mut local_var_form = reqwest::multipart::Form::new();
184 let local_var_param_value = image;
185 let kind = infer::get_from_path(&local_var_param_value)?.map(|v| v.mime_type().to_string()).unwrap_or_else(|| "application/octet-stream".to_string());
186 let filebytes = tokio::fs::read(&local_var_param_value).await?;
187 let file_part = reqwest::multipart::Part::bytes(filebytes)
188 .file_name(local_var_param_value.display().to_string())
189 .mime_str(&kind)?;
190 local_var_form = local_var_form.part("image", file_part);
191 local_var_form = local_var_form.text("pi", pi.to_string());
192 local_var_req_builder = local_var_req_builder.multipart(local_var_form);
193
194 let local_var_req = local_var_req_builder.build()?;
195 let local_var_resp = local_var_client.execute(local_var_req).await?;
196
197 let local_var_status = local_var_resp.status();
198 let local_var_content = local_var_resp.text().await?;
199
200 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
201 serde_json::from_str(&local_var_content).map_err(Error::from)
202 } else {
203 let local_var_entity: Option<PisCameraSnapshotsCreateError> = serde_json::from_str(&local_var_content).ok();
204 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
205 Err(Error::ResponseError(local_var_error))
206 }
207}
208
209pub async fn pis_camera_snapshots_list(configuration: &configuration::Configuration, pi_id: i32, page: Option<i32>) -> Result<crate::models::PaginatedCameraSnapshotList, Error<PisCameraSnapshotsListError>> {
210 let local_var_configuration = configuration;
211
212 let local_var_client = &local_var_configuration.client;
213
214 let local_var_uri_str = format!("{}/api/pis/{pi_id}/camera-snapshots/", local_var_configuration.base_path, pi_id=pi_id);
215 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
216
217 if let Some(ref local_var_str) = page {
218 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
219 }
220 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
221 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
222 }
223 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
224 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
225 };
226
227 let local_var_req = local_var_req_builder.build()?;
228 let local_var_resp = local_var_client.execute(local_var_req).await?;
229
230 let local_var_status = local_var_resp.status();
231 let local_var_content = local_var_resp.text().await?;
232
233 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
234 serde_json::from_str(&local_var_content).map_err(Error::from)
235 } else {
236 let local_var_entity: Option<PisCameraSnapshotsListError> = serde_json::from_str(&local_var_content).ok();
237 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
238 Err(Error::ResponseError(local_var_error))
239 }
240}
241
242pub async fn pis_camera_snapshots_retrieve(configuration: &configuration::Configuration, id: &str, pi_id: i32) -> Result<crate::models::CameraSnapshot, Error<PisCameraSnapshotsRetrieveError>> {
243 let local_var_configuration = configuration;
244
245 let local_var_client = &local_var_configuration.client;
246
247 let local_var_uri_str = format!("{}/api/pis/{pi_id}/camera-snapshots/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id), pi_id=pi_id);
248 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
249
250 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
251 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
252 }
253 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
254 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
255 };
256
257 let local_var_req = local_var_req_builder.build()?;
258 let local_var_resp = local_var_client.execute(local_var_req).await?;
259
260 let local_var_status = local_var_resp.status();
261 let local_var_content = local_var_resp.text().await?;
262
263 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
264 serde_json::from_str(&local_var_content).map_err(Error::from)
265 } else {
266 let local_var_entity: Option<PisCameraSnapshotsRetrieveError> = serde_json::from_str(&local_var_content).ok();
267 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
268 Err(Error::ResponseError(local_var_error))
269 }
270}
271
272pub async fn video_parts_create(configuration: &configuration::Configuration, id: &str, size: i64, buffer_index: i64, buffer_runningtime: i64, file_name: &str, mp4_file: std::path::PathBuf, sync_start: String, video_recording: &str) -> Result<crate::models::VideoRecordingPart, Error<VideoPartsCreateError>> {
273 let local_var_configuration = configuration;
274
275 let local_var_client = &local_var_configuration.client;
276
277 let local_var_uri_str = format!("{}/api/video-parts/", local_var_configuration.base_path);
278 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
279
280 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
281 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
282 }
283 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
284 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
285 };
286 let mut local_var_form = reqwest::multipart::Form::new();
287 local_var_form = local_var_form.text("id", id.to_string());
288 local_var_form = local_var_form.text("size", size.to_string());
289 local_var_form = local_var_form.text("buffer_index", buffer_index.to_string());
290 local_var_form = local_var_form.text("buffer_runningtime", buffer_runningtime.to_string());
291 local_var_form = local_var_form.text("file_name", file_name.to_string());
292 let local_var_param_value = mp4_file;
293 let kind = infer::get_from_path(&local_var_param_value)?.map(|v| v.mime_type().to_string()).unwrap_or_else(|| "application/octet-stream".to_string());
294 let filebytes = tokio::fs::read(&local_var_param_value).await?;
295 let file_part = reqwest::multipart::Part::bytes(filebytes)
296 .file_name(local_var_param_value.display().to_string())
297 .mime_str(&kind)?;
298 local_var_form = local_var_form.part("mp4_file", file_part);
299 local_var_form = local_var_form.text("sync_start", sync_start.to_string());
300 local_var_form = local_var_form.text("video_recording", video_recording.to_string());
301 local_var_req_builder = local_var_req_builder.multipart(local_var_form);
302
303 let local_var_req = local_var_req_builder.build()?;
304 let local_var_resp = local_var_client.execute(local_var_req).await?;
305
306 let local_var_status = local_var_resp.status();
307 let local_var_content = local_var_resp.text().await?;
308
309 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
310 serde_json::from_str(&local_var_content).map_err(Error::from)
311 } else {
312 let local_var_entity: Option<VideoPartsCreateError> = serde_json::from_str(&local_var_content).ok();
313 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
314 Err(Error::ResponseError(local_var_error))
315 }
316}
317
318pub async fn video_parts_list(configuration: &configuration::Configuration, page: Option<i32>) -> Result<crate::models::PaginatedVideoRecordingPartList, Error<VideoPartsListError>> {
319 let local_var_configuration = configuration;
320
321 let local_var_client = &local_var_configuration.client;
322
323 let local_var_uri_str = format!("{}/api/video-parts/", local_var_configuration.base_path);
324 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
325
326 if let Some(ref local_var_str) = page {
327 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
328 }
329 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
330 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
331 }
332 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
333 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
334 };
335
336 let local_var_req = local_var_req_builder.build()?;
337 let local_var_resp = local_var_client.execute(local_var_req).await?;
338
339 let local_var_status = local_var_resp.status();
340 let local_var_content = local_var_resp.text().await?;
341
342 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
343 serde_json::from_str(&local_var_content).map_err(Error::from)
344 } else {
345 let local_var_entity: Option<VideoPartsListError> = serde_json::from_str(&local_var_content).ok();
346 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
347 Err(Error::ResponseError(local_var_error))
348 }
349}
350
351pub async fn video_parts_retrieve(configuration: &configuration::Configuration, id: &str) -> Result<crate::models::VideoRecordingPart, Error<VideoPartsRetrieveError>> {
352 let local_var_configuration = configuration;
353
354 let local_var_client = &local_var_configuration.client;
355
356 let local_var_uri_str = format!("{}/api/video-parts/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
357 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
358
359 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
360 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
361 }
362 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
363 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
364 };
365
366 let local_var_req = local_var_req_builder.build()?;
367 let local_var_resp = local_var_client.execute(local_var_req).await?;
368
369 let local_var_status = local_var_resp.status();
370 let local_var_content = local_var_resp.text().await?;
371
372 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
373 serde_json::from_str(&local_var_content).map_err(Error::from)
374 } else {
375 let local_var_entity: Option<VideoPartsRetrieveError> = serde_json::from_str(&local_var_content).ok();
376 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
377 Err(Error::ResponseError(local_var_error))
378 }
379}
380
381pub async fn video_recordings_finalize(configuration: &configuration::Configuration, id: &str, video_recording_finalize_request: crate::models::VideoRecordingFinalizeRequest) -> Result<crate::models::VideoRecording, Error<VideoRecordingsFinalizeError>> {
382 let local_var_configuration = configuration;
383
384 let local_var_client = &local_var_configuration.client;
385
386 let local_var_uri_str = format!("{}/api/videos/{id}/finalize/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
387 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
388
389 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
390 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
391 }
392 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
393 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
394 };
395 local_var_req_builder = local_var_req_builder.json(&video_recording_finalize_request);
396
397 let local_var_req = local_var_req_builder.build()?;
398 let local_var_resp = local_var_client.execute(local_var_req).await?;
399
400 let local_var_status = local_var_resp.status();
401 let local_var_content = local_var_resp.text().await?;
402
403 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
404 serde_json::from_str(&local_var_content).map_err(Error::from)
405 } else {
406 let local_var_entity: Option<VideoRecordingsFinalizeError> = serde_json::from_str(&local_var_content).ok();
407 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
408 Err(Error::ResponseError(local_var_error))
409 }
410}
411
412pub async fn video_recordings_update_or_create(configuration: &configuration::Configuration, id: &str, video_recording_request: Option<crate::models::VideoRecordingRequest>) -> Result<crate::models::VideoRecording, Error<VideoRecordingsUpdateOrCreateError>> {
413 let local_var_configuration = configuration;
414
415 let local_var_client = &local_var_configuration.client;
416
417 let local_var_uri_str = format!("{}/api/videos/{id}/update-or-create/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
418 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
419
420 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
421 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
422 }
423 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
424 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
425 };
426 local_var_req_builder = local_var_req_builder.json(&video_recording_request);
427
428 let local_var_req = local_var_req_builder.build()?;
429 let local_var_resp = local_var_client.execute(local_var_req).await?;
430
431 let local_var_status = local_var_resp.status();
432 let local_var_content = local_var_resp.text().await?;
433
434 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
435 serde_json::from_str(&local_var_content).map_err(Error::from)
436 } else {
437 let local_var_entity: Option<VideoRecordingsUpdateOrCreateError> = serde_json::from_str(&local_var_content).ok();
438 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
439 Err(Error::ResponseError(local_var_error))
440 }
441}
442
443pub async fn videos_create(configuration: &configuration::Configuration, video_recording_request: Option<crate::models::VideoRecordingRequest>) -> Result<crate::models::VideoRecording, Error<VideosCreateError>> {
444 let local_var_configuration = configuration;
445
446 let local_var_client = &local_var_configuration.client;
447
448 let local_var_uri_str = format!("{}/api/videos/", local_var_configuration.base_path);
449 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
450
451 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
452 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
453 }
454 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
455 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
456 };
457 local_var_req_builder = local_var_req_builder.json(&video_recording_request);
458
459 let local_var_req = local_var_req_builder.build()?;
460 let local_var_resp = local_var_client.execute(local_var_req).await?;
461
462 let local_var_status = local_var_resp.status();
463 let local_var_content = local_var_resp.text().await?;
464
465 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
466 serde_json::from_str(&local_var_content).map_err(Error::from)
467 } else {
468 let local_var_entity: Option<VideosCreateError> = serde_json::from_str(&local_var_content).ok();
469 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
470 Err(Error::ResponseError(local_var_error))
471 }
472}
473
474pub async fn videos_list(configuration: &configuration::Configuration, page: Option<i32>) -> Result<crate::models::PaginatedVideoRecordingList, Error<VideosListError>> {
475 let local_var_configuration = configuration;
476
477 let local_var_client = &local_var_configuration.client;
478
479 let local_var_uri_str = format!("{}/api/videos/", local_var_configuration.base_path);
480 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
481
482 if let Some(ref local_var_str) = page {
483 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
484 }
485 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
486 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
487 }
488 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
489 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
490 };
491
492 let local_var_req = local_var_req_builder.build()?;
493 let local_var_resp = local_var_client.execute(local_var_req).await?;
494
495 let local_var_status = local_var_resp.status();
496 let local_var_content = local_var_resp.text().await?;
497
498 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
499 serde_json::from_str(&local_var_content).map_err(Error::from)
500 } else {
501 let local_var_entity: Option<VideosListError> = serde_json::from_str(&local_var_content).ok();
502 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
503 Err(Error::ResponseError(local_var_error))
504 }
505}
506
507pub async fn videos_partial_update(configuration: &configuration::Configuration, id: &str, patched_video_recording_request: Option<crate::models::PatchedVideoRecordingRequest>) -> Result<crate::models::VideoRecording, Error<VideosPartialUpdateError>> {
508 let local_var_configuration = configuration;
509
510 let local_var_client = &local_var_configuration.client;
511
512 let local_var_uri_str = format!("{}/api/videos/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
513 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
514
515 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
516 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
517 }
518 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
519 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
520 };
521 local_var_req_builder = local_var_req_builder.json(&patched_video_recording_request);
522
523 let local_var_req = local_var_req_builder.build()?;
524 let local_var_resp = local_var_client.execute(local_var_req).await?;
525
526 let local_var_status = local_var_resp.status();
527 let local_var_content = local_var_resp.text().await?;
528
529 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
530 serde_json::from_str(&local_var_content).map_err(Error::from)
531 } else {
532 let local_var_entity: Option<VideosPartialUpdateError> = serde_json::from_str(&local_var_content).ok();
533 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
534 Err(Error::ResponseError(local_var_error))
535 }
536}
537
538pub async fn videos_retrieve(configuration: &configuration::Configuration, id: &str) -> Result<crate::models::VideoRecording, Error<VideosRetrieveError>> {
539 let local_var_configuration = configuration;
540
541 let local_var_client = &local_var_configuration.client;
542
543 let local_var_uri_str = format!("{}/api/videos/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
544 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
545
546 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
547 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
548 }
549 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
550 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
551 };
552
553 let local_var_req = local_var_req_builder.build()?;
554 let local_var_resp = local_var_client.execute(local_var_req).await?;
555
556 let local_var_status = local_var_resp.status();
557 let local_var_content = local_var_resp.text().await?;
558
559 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
560 serde_json::from_str(&local_var_content).map_err(Error::from)
561 } else {
562 let local_var_entity: Option<VideosRetrieveError> = serde_json::from_str(&local_var_content).ok();
563 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
564 Err(Error::ResponseError(local_var_error))
565 }
566}
567
568pub async fn videos_update(configuration: &configuration::Configuration, id: &str, video_recording_request: Option<crate::models::VideoRecordingRequest>) -> Result<crate::models::VideoRecording, Error<VideosUpdateError>> {
569 let local_var_configuration = configuration;
570
571 let local_var_client = &local_var_configuration.client;
572
573 let local_var_uri_str = format!("{}/api/videos/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
574 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
575
576 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
577 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
578 }
579 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
580 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
581 };
582 local_var_req_builder = local_var_req_builder.json(&video_recording_request);
583
584 let local_var_req = local_var_req_builder.build()?;
585 let local_var_resp = local_var_client.execute(local_var_req).await?;
586
587 let local_var_status = local_var_resp.status();
588 let local_var_content = local_var_resp.text().await?;
589
590 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
591 serde_json::from_str(&local_var_content).map_err(Error::from)
592 } else {
593 let local_var_entity: Option<VideosUpdateError> = serde_json::from_str(&local_var_content).ok();
594 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
595 Err(Error::ResponseError(local_var_error))
596 }
597}
598