1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteLinkByIdError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetLinkError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetLinkByIdError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetLinkDevicesByMachineError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetLinkRouteError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetLinkUsageError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetLinkUsageAccountsError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetLinkUsageSummaryError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostLinkError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PostLinkDevicesByMachineRevokeError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum PostLinkUsageError {
92 UnknownValue(serde_json::Value),
93}
94
95
96pub async fn delete_link_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::RevokeResp, Error<DeleteLinkByIdError>> {
98 let p_id = id;
100
101 let uri_str = format!("{}/v1/link/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
102 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
103
104 if let Some(ref user_agent) = configuration.user_agent {
105 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
106 }
107 if let Some(ref token) = configuration.bearer_access_token {
108 req_builder = req_builder.bearer_auth(token.to_owned());
109 };
110
111 let req = req_builder.build()?;
112 let resp = configuration.client.execute(req).await?;
113
114 let status = resp.status();
115 let content_type = resp
116 .headers()
117 .get("content-type")
118 .and_then(|v| v.to_str().ok())
119 .unwrap_or("application/octet-stream");
120 let content_type = super::ContentType::from(content_type);
121
122 if !status.is_client_error() && !status.is_server_error() {
123 let content = resp.text().await?;
124 match content_type {
125 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
126 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RevokeResp`"))),
127 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RevokeResp`")))),
128 }
129 } else {
130 let content = resp.text().await?;
131 let entity: Option<DeleteLinkByIdError> = serde_json::from_str(&content).ok();
132 Err(Error::ResponseError(ResponseContent { status, content, entity }))
133 }
134}
135
136pub async fn get_link(configuration: &configuration::Configuration, ) -> Result<models::LinkList, Error<GetLinkError>> {
138
139 let uri_str = format!("{}/v1/link", configuration.base_path);
140 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
141
142 if let Some(ref user_agent) = configuration.user_agent {
143 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
144 }
145 if let Some(ref token) = configuration.bearer_access_token {
146 req_builder = req_builder.bearer_auth(token.to_owned());
147 };
148
149 let req = req_builder.build()?;
150 let resp = configuration.client.execute(req).await?;
151
152 let status = resp.status();
153 let content_type = resp
154 .headers()
155 .get("content-type")
156 .and_then(|v| v.to_str().ok())
157 .unwrap_or("application/octet-stream");
158 let content_type = super::ContentType::from(content_type);
159
160 if !status.is_client_error() && !status.is_server_error() {
161 let content = resp.text().await?;
162 match content_type {
163 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
164 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LinkList`"))),
165 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LinkList`")))),
166 }
167 } else {
168 let content = resp.text().await?;
169 let entity: Option<GetLinkError> = serde_json::from_str(&content).ok();
170 Err(Error::ResponseError(ResponseContent { status, content, entity }))
171 }
172}
173
174pub async fn get_link_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::LinkView, Error<GetLinkByIdError>> {
176 let p_id = id;
178
179 let uri_str = format!("{}/v1/link/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
180 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
181
182 if let Some(ref user_agent) = configuration.user_agent {
183 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
184 }
185 if let Some(ref token) = configuration.bearer_access_token {
186 req_builder = req_builder.bearer_auth(token.to_owned());
187 };
188
189 let req = req_builder.build()?;
190 let resp = configuration.client.execute(req).await?;
191
192 let status = resp.status();
193 let content_type = resp
194 .headers()
195 .get("content-type")
196 .and_then(|v| v.to_str().ok())
197 .unwrap_or("application/octet-stream");
198 let content_type = super::ContentType::from(content_type);
199
200 if !status.is_client_error() && !status.is_server_error() {
201 let content = resp.text().await?;
202 match content_type {
203 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
204 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LinkView`"))),
205 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LinkView`")))),
206 }
207 } else {
208 let content = resp.text().await?;
209 let entity: Option<GetLinkByIdError> = serde_json::from_str(&content).ok();
210 Err(Error::ResponseError(ResponseContent { status, content, entity }))
211 }
212}
213
214pub async fn get_link_devices_by_machine(configuration: &configuration::Configuration, machine: &str) -> Result<models::DeviceView, Error<GetLinkDevicesByMachineError>> {
216 let p_machine = machine;
218
219 let uri_str = format!("{}/v1/link/devices/{machine}", configuration.base_path, machine=crate::apis::urlencode(p_machine));
220 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
221
222 if let Some(ref user_agent) = configuration.user_agent {
223 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
224 }
225 if let Some(ref token) = configuration.bearer_access_token {
226 req_builder = req_builder.bearer_auth(token.to_owned());
227 };
228
229 let req = req_builder.build()?;
230 let resp = configuration.client.execute(req).await?;
231
232 let status = resp.status();
233 let content_type = resp
234 .headers()
235 .get("content-type")
236 .and_then(|v| v.to_str().ok())
237 .unwrap_or("application/octet-stream");
238 let content_type = super::ContentType::from(content_type);
239
240 if !status.is_client_error() && !status.is_server_error() {
241 let content = resp.text().await?;
242 match content_type {
243 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
244 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeviceView`"))),
245 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeviceView`")))),
246 }
247 } else {
248 let content = resp.text().await?;
249 let entity: Option<GetLinkDevicesByMachineError> = serde_json::from_str(&content).ok();
250 Err(Error::ResponseError(ResponseContent { status, content, entity }))
251 }
252}
253
254pub async fn get_link_route(configuration: &configuration::Configuration, ) -> Result<models::RoutePlan, Error<GetLinkRouteError>> {
256
257 let uri_str = format!("{}/v1/link/route", configuration.base_path);
258 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
259
260 if let Some(ref user_agent) = configuration.user_agent {
261 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
262 }
263 if let Some(ref token) = configuration.bearer_access_token {
264 req_builder = req_builder.bearer_auth(token.to_owned());
265 };
266
267 let req = req_builder.build()?;
268 let resp = configuration.client.execute(req).await?;
269
270 let status = resp.status();
271 let content_type = resp
272 .headers()
273 .get("content-type")
274 .and_then(|v| v.to_str().ok())
275 .unwrap_or("application/octet-stream");
276 let content_type = super::ContentType::from(content_type);
277
278 if !status.is_client_error() && !status.is_server_error() {
279 let content = resp.text().await?;
280 match content_type {
281 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
282 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RoutePlan`"))),
283 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RoutePlan`")))),
284 }
285 } else {
286 let content = resp.text().await?;
287 let entity: Option<GetLinkRouteError> = serde_json::from_str(&content).ok();
288 Err(Error::ResponseError(ResponseContent { status, content, entity }))
289 }
290}
291
292pub async fn get_link_usage(configuration: &configuration::Configuration, provider: Option<&str>, account: Option<&str>, window: Option<&str>, range: Option<&str>) -> Result<models::BoardResp, Error<GetLinkUsageError>> {
294 let p_provider = provider;
296 let p_account = account;
297 let p_window = window;
298 let p_range = range;
299
300 let uri_str = format!("{}/v1/link/usage", configuration.base_path);
301 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
302
303 if let Some(ref param_value) = p_provider {
304 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
305 }
306 if let Some(ref param_value) = p_account {
307 req_builder = req_builder.query(&[("account", ¶m_value.to_string())]);
308 }
309 if let Some(ref param_value) = p_window {
310 req_builder = req_builder.query(&[("window", ¶m_value.to_string())]);
311 }
312 if let Some(ref param_value) = p_range {
313 req_builder = req_builder.query(&[("range", ¶m_value.to_string())]);
314 }
315 if let Some(ref user_agent) = configuration.user_agent {
316 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
317 }
318 if let Some(ref token) = configuration.bearer_access_token {
319 req_builder = req_builder.bearer_auth(token.to_owned());
320 };
321
322 let req = req_builder.build()?;
323 let resp = configuration.client.execute(req).await?;
324
325 let status = resp.status();
326 let content_type = resp
327 .headers()
328 .get("content-type")
329 .and_then(|v| v.to_str().ok())
330 .unwrap_or("application/octet-stream");
331 let content_type = super::ContentType::from(content_type);
332
333 if !status.is_client_error() && !status.is_server_error() {
334 let content = resp.text().await?;
335 match content_type {
336 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
337 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BoardResp`"))),
338 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BoardResp`")))),
339 }
340 } else {
341 let content = resp.text().await?;
342 let entity: Option<GetLinkUsageError> = serde_json::from_str(&content).ok();
343 Err(Error::ResponseError(ResponseContent { status, content, entity }))
344 }
345}
346
347pub async fn get_link_usage_accounts(configuration: &configuration::Configuration, ) -> Result<models::AccountsUsage, Error<GetLinkUsageAccountsError>> {
349
350 let uri_str = format!("{}/v1/link/usage/accounts", configuration.base_path);
351 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
352
353 if let Some(ref user_agent) = configuration.user_agent {
354 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
355 }
356 if let Some(ref token) = configuration.bearer_access_token {
357 req_builder = req_builder.bearer_auth(token.to_owned());
358 };
359
360 let req = req_builder.build()?;
361 let resp = configuration.client.execute(req).await?;
362
363 let status = resp.status();
364 let content_type = resp
365 .headers()
366 .get("content-type")
367 .and_then(|v| v.to_str().ok())
368 .unwrap_or("application/octet-stream");
369 let content_type = super::ContentType::from(content_type);
370
371 if !status.is_client_error() && !status.is_server_error() {
372 let content = resp.text().await?;
373 match content_type {
374 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
375 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccountsUsage`"))),
376 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AccountsUsage`")))),
377 }
378 } else {
379 let content = resp.text().await?;
380 let entity: Option<GetLinkUsageAccountsError> = serde_json::from_str(&content).ok();
381 Err(Error::ResponseError(ResponseContent { status, content, entity }))
382 }
383}
384
385pub async fn get_link_usage_summary(configuration: &configuration::Configuration, range: Option<&str>) -> Result<models::SummaryResp, Error<GetLinkUsageSummaryError>> {
387 let p_range = range;
389
390 let uri_str = format!("{}/v1/link/usage/summary", configuration.base_path);
391 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
392
393 if let Some(ref param_value) = p_range {
394 req_builder = req_builder.query(&[("range", ¶m_value.to_string())]);
395 }
396 if let Some(ref user_agent) = configuration.user_agent {
397 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
398 }
399 if let Some(ref token) = configuration.bearer_access_token {
400 req_builder = req_builder.bearer_auth(token.to_owned());
401 };
402
403 let req = req_builder.build()?;
404 let resp = configuration.client.execute(req).await?;
405
406 let status = resp.status();
407 let content_type = resp
408 .headers()
409 .get("content-type")
410 .and_then(|v| v.to_str().ok())
411 .unwrap_or("application/octet-stream");
412 let content_type = super::ContentType::from(content_type);
413
414 if !status.is_client_error() && !status.is_server_error() {
415 let content = resp.text().await?;
416 match content_type {
417 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
418 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SummaryResp`"))),
419 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SummaryResp`")))),
420 }
421 } else {
422 let content = resp.text().await?;
423 let entity: Option<GetLinkUsageSummaryError> = serde_json::from_str(&content).ok();
424 Err(Error::ResponseError(ResponseContent { status, content, entity }))
425 }
426}
427
428pub async fn post_link(configuration: &configuration::Configuration, enroll_req: models::EnrollReq) -> Result<models::LinkView, Error<PostLinkError>> {
430 let p_enroll_req = enroll_req;
432
433 let uri_str = format!("{}/v1/link", configuration.base_path);
434 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
435
436 if let Some(ref user_agent) = configuration.user_agent {
437 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
438 }
439 if let Some(ref token) = configuration.bearer_access_token {
440 req_builder = req_builder.bearer_auth(token.to_owned());
441 };
442 req_builder = req_builder.json(&p_enroll_req);
443
444 let req = req_builder.build()?;
445 let resp = configuration.client.execute(req).await?;
446
447 let status = resp.status();
448 let content_type = resp
449 .headers()
450 .get("content-type")
451 .and_then(|v| v.to_str().ok())
452 .unwrap_or("application/octet-stream");
453 let content_type = super::ContentType::from(content_type);
454
455 if !status.is_client_error() && !status.is_server_error() {
456 let content = resp.text().await?;
457 match content_type {
458 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
459 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LinkView`"))),
460 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LinkView`")))),
461 }
462 } else {
463 let content = resp.text().await?;
464 let entity: Option<PostLinkError> = serde_json::from_str(&content).ok();
465 Err(Error::ResponseError(ResponseContent { status, content, entity }))
466 }
467}
468
469pub async fn post_link_devices_by_machine_revoke(configuration: &configuration::Configuration, machine: &str) -> Result<models::RevokeResp, Error<PostLinkDevicesByMachineRevokeError>> {
471 let p_machine = machine;
473
474 let uri_str = format!("{}/v1/link/devices/{machine}/revoke", configuration.base_path, machine=crate::apis::urlencode(p_machine));
475 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
476
477 if let Some(ref user_agent) = configuration.user_agent {
478 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
479 }
480 if let Some(ref token) = configuration.bearer_access_token {
481 req_builder = req_builder.bearer_auth(token.to_owned());
482 };
483
484 let req = req_builder.build()?;
485 let resp = configuration.client.execute(req).await?;
486
487 let status = resp.status();
488 let content_type = resp
489 .headers()
490 .get("content-type")
491 .and_then(|v| v.to_str().ok())
492 .unwrap_or("application/octet-stream");
493 let content_type = super::ContentType::from(content_type);
494
495 if !status.is_client_error() && !status.is_server_error() {
496 let content = resp.text().await?;
497 match content_type {
498 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
499 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RevokeResp`"))),
500 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RevokeResp`")))),
501 }
502 } else {
503 let content = resp.text().await?;
504 let entity: Option<PostLinkDevicesByMachineRevokeError> = serde_json::from_str(&content).ok();
505 Err(Error::ResponseError(ResponseContent { status, content, entity }))
506 }
507}
508
509pub async fn post_link_usage(configuration: &configuration::Configuration, ingest_req: models::IngestReq) -> Result<models::IngestResp, Error<PostLinkUsageError>> {
511 let p_ingest_req = ingest_req;
513
514 let uri_str = format!("{}/v1/link/usage", configuration.base_path);
515 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
516
517 if let Some(ref user_agent) = configuration.user_agent {
518 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
519 }
520 if let Some(ref token) = configuration.bearer_access_token {
521 req_builder = req_builder.bearer_auth(token.to_owned());
522 };
523 req_builder = req_builder.json(&p_ingest_req);
524
525 let req = req_builder.build()?;
526 let resp = configuration.client.execute(req).await?;
527
528 let status = resp.status();
529 let content_type = resp
530 .headers()
531 .get("content-type")
532 .and_then(|v| v.to_str().ok())
533 .unwrap_or("application/octet-stream");
534 let content_type = super::ContentType::from(content_type);
535
536 if !status.is_client_error() && !status.is_server_error() {
537 let content = resp.text().await?;
538 match content_type {
539 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
540 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IngestResp`"))),
541 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::IngestResp`")))),
542 }
543 } else {
544 let content = resp.text().await?;
545 let entity: Option<PostLinkUsageError> = serde_json::from_str(&content).ok();
546 Err(Error::ResponseError(ResponseContent { status, content, entity }))
547 }
548}
549