1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum RacConnectionTokensDestroyError {
20 Status400(models::ValidationError),
21 Status403(models::GenericError),
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum RacConnectionTokensListError {
29 Status400(models::ValidationError),
30 Status403(models::GenericError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum RacConnectionTokensPartialUpdateError {
38 Status400(models::ValidationError),
39 Status403(models::GenericError),
40 UnknownValue(serde_json::Value),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum RacConnectionTokensRetrieveError {
47 Status400(models::ValidationError),
48 Status403(models::GenericError),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum RacConnectionTokensUpdateError {
56 Status400(models::ValidationError),
57 Status403(models::GenericError),
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum RacConnectionTokensUsedByListError {
65 Status400(models::ValidationError),
66 Status403(models::GenericError),
67 UnknownValue(serde_json::Value),
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum RacEndpointsCreateError {
74 Status400(models::ValidationError),
75 Status403(models::GenericError),
76 UnknownValue(serde_json::Value),
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum RacEndpointsDestroyError {
83 Status400(models::ValidationError),
84 Status403(models::GenericError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum RacEndpointsListError {
92 Status400(),
93 Status403(models::GenericError),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum RacEndpointsPartialUpdateError {
101 Status400(models::ValidationError),
102 Status403(models::GenericError),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum RacEndpointsRetrieveError {
110 Status400(models::ValidationError),
111 Status403(models::GenericError),
112 UnknownValue(serde_json::Value),
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum RacEndpointsUpdateError {
119 Status400(models::ValidationError),
120 Status403(models::GenericError),
121 UnknownValue(serde_json::Value),
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum RacEndpointsUsedByListError {
128 Status400(models::ValidationError),
129 Status403(models::GenericError),
130 UnknownValue(serde_json::Value),
131}
132
133pub async fn rac_connection_tokens_destroy(
135 configuration: &configuration::Configuration,
136 connection_token_uuid: &str,
137) -> Result<(), Error<RacConnectionTokensDestroyError>> {
138 let p_path_connection_token_uuid = connection_token_uuid;
140
141 let uri_str = format!(
142 "{}/rac/connection_tokens/{connection_token_uuid}/",
143 configuration.base_path,
144 connection_token_uuid = crate::apis::urlencode(p_path_connection_token_uuid)
145 );
146 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
147
148 if let Some(ref user_agent) = configuration.user_agent {
149 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
150 }
151 if let Some(ref token) = configuration.bearer_access_token {
152 req_builder = req_builder.bearer_auth(token.to_owned());
153 };
154
155 let req = req_builder.build()?;
156 let resp = configuration.client.execute(req).await?;
157
158 let status = resp.status();
159
160 if !status.is_client_error() && !status.is_server_error() {
161 Ok(())
162 } else {
163 let content = resp.text().await?;
164 let entity: Option<RacConnectionTokensDestroyError> = serde_json::from_str(&content).ok();
165 Err(Error::ResponseError(ResponseContent {
166 status,
167 content,
168 entity,
169 }))
170 }
171}
172
173pub async fn rac_connection_tokens_list(
175 configuration: &configuration::Configuration,
176 endpoint: Option<&str>,
177 ordering: Option<&str>,
178 page: Option<i32>,
179 page_size: Option<i32>,
180 provider: Option<i32>,
181 search: Option<&str>,
182 session__user: Option<i32>,
183) -> Result<models::PaginatedConnectionTokenList, Error<RacConnectionTokensListError>> {
184 let p_query_endpoint = endpoint;
186 let p_query_ordering = ordering;
187 let p_query_page = page;
188 let p_query_page_size = page_size;
189 let p_query_provider = provider;
190 let p_query_search = search;
191 let p_query_session__user = session__user;
192
193 let uri_str = format!("{}/rac/connection_tokens/", configuration.base_path);
194 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
195
196 if let Some(ref param_value) = p_query_endpoint {
197 req_builder = req_builder.query(&[("endpoint", ¶m_value.to_string())]);
198 }
199 if let Some(ref param_value) = p_query_ordering {
200 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
201 }
202 if let Some(ref param_value) = p_query_page {
203 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
204 }
205 if let Some(ref param_value) = p_query_page_size {
206 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
207 }
208 if let Some(ref param_value) = p_query_provider {
209 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
210 }
211 if let Some(ref param_value) = p_query_search {
212 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
213 }
214 if let Some(ref param_value) = p_query_session__user {
215 req_builder = req_builder.query(&[("session__user", ¶m_value.to_string())]);
216 }
217 if let Some(ref user_agent) = configuration.user_agent {
218 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
219 }
220 if let Some(ref token) = configuration.bearer_access_token {
221 req_builder = req_builder.bearer_auth(token.to_owned());
222 };
223
224 let req = req_builder.build()?;
225 let resp = configuration.client.execute(req).await?;
226
227 let status = resp.status();
228 let content_type = resp
229 .headers()
230 .get("content-type")
231 .and_then(|v| v.to_str().ok())
232 .unwrap_or("application/octet-stream");
233 let content_type = super::ContentType::from(content_type);
234
235 if !status.is_client_error() && !status.is_server_error() {
236 let content = resp.text().await?;
237 match content_type {
238 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
239 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedConnectionTokenList`"))),
240 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::PaginatedConnectionTokenList`")))),
241 }
242 } else {
243 let content = resp.text().await?;
244 let entity: Option<RacConnectionTokensListError> = serde_json::from_str(&content).ok();
245 Err(Error::ResponseError(ResponseContent {
246 status,
247 content,
248 entity,
249 }))
250 }
251}
252
253pub async fn rac_connection_tokens_partial_update(
255 configuration: &configuration::Configuration,
256 connection_token_uuid: &str,
257 patched_connection_token_request: Option<models::PatchedConnectionTokenRequest>,
258) -> Result<models::ConnectionToken, Error<RacConnectionTokensPartialUpdateError>> {
259 let p_path_connection_token_uuid = connection_token_uuid;
261 let p_body_patched_connection_token_request = patched_connection_token_request;
262
263 let uri_str = format!(
264 "{}/rac/connection_tokens/{connection_token_uuid}/",
265 configuration.base_path,
266 connection_token_uuid = crate::apis::urlencode(p_path_connection_token_uuid)
267 );
268 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
269
270 if let Some(ref user_agent) = configuration.user_agent {
271 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
272 }
273 if let Some(ref token) = configuration.bearer_access_token {
274 req_builder = req_builder.bearer_auth(token.to_owned());
275 };
276 req_builder = req_builder.json(&p_body_patched_connection_token_request);
277
278 let req = req_builder.build()?;
279 let resp = configuration.client.execute(req).await?;
280
281 let status = resp.status();
282 let content_type = resp
283 .headers()
284 .get("content-type")
285 .and_then(|v| v.to_str().ok())
286 .unwrap_or("application/octet-stream");
287 let content_type = super::ContentType::from(content_type);
288
289 if !status.is_client_error() && !status.is_server_error() {
290 let content = resp.text().await?;
291 match content_type {
292 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
293 ContentType::Text => {
294 return Err(Error::from(serde_json::Error::custom(
295 "Received `text/plain` content type response that cannot be converted to `models::ConnectionToken`",
296 )))
297 }
298 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
299 "Received `{unknown_type}` content type response that cannot be converted to `models::ConnectionToken`"
300 )))),
301 }
302 } else {
303 let content = resp.text().await?;
304 let entity: Option<RacConnectionTokensPartialUpdateError> = serde_json::from_str(&content).ok();
305 Err(Error::ResponseError(ResponseContent {
306 status,
307 content,
308 entity,
309 }))
310 }
311}
312
313pub async fn rac_connection_tokens_retrieve(
315 configuration: &configuration::Configuration,
316 connection_token_uuid: &str,
317) -> Result<models::ConnectionToken, Error<RacConnectionTokensRetrieveError>> {
318 let p_path_connection_token_uuid = connection_token_uuid;
320
321 let uri_str = format!(
322 "{}/rac/connection_tokens/{connection_token_uuid}/",
323 configuration.base_path,
324 connection_token_uuid = crate::apis::urlencode(p_path_connection_token_uuid)
325 );
326 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
327
328 if let Some(ref user_agent) = configuration.user_agent {
329 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
330 }
331 if let Some(ref token) = configuration.bearer_access_token {
332 req_builder = req_builder.bearer_auth(token.to_owned());
333 };
334
335 let req = req_builder.build()?;
336 let resp = configuration.client.execute(req).await?;
337
338 let status = resp.status();
339 let content_type = resp
340 .headers()
341 .get("content-type")
342 .and_then(|v| v.to_str().ok())
343 .unwrap_or("application/octet-stream");
344 let content_type = super::ContentType::from(content_type);
345
346 if !status.is_client_error() && !status.is_server_error() {
347 let content = resp.text().await?;
348 match content_type {
349 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
350 ContentType::Text => {
351 return Err(Error::from(serde_json::Error::custom(
352 "Received `text/plain` content type response that cannot be converted to `models::ConnectionToken`",
353 )))
354 }
355 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
356 "Received `{unknown_type}` content type response that cannot be converted to `models::ConnectionToken`"
357 )))),
358 }
359 } else {
360 let content = resp.text().await?;
361 let entity: Option<RacConnectionTokensRetrieveError> = serde_json::from_str(&content).ok();
362 Err(Error::ResponseError(ResponseContent {
363 status,
364 content,
365 entity,
366 }))
367 }
368}
369
370pub async fn rac_connection_tokens_update(
372 configuration: &configuration::Configuration,
373 connection_token_uuid: &str,
374 connection_token_request: models::ConnectionTokenRequest,
375) -> Result<models::ConnectionToken, Error<RacConnectionTokensUpdateError>> {
376 let p_path_connection_token_uuid = connection_token_uuid;
378 let p_body_connection_token_request = connection_token_request;
379
380 let uri_str = format!(
381 "{}/rac/connection_tokens/{connection_token_uuid}/",
382 configuration.base_path,
383 connection_token_uuid = crate::apis::urlencode(p_path_connection_token_uuid)
384 );
385 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
386
387 if let Some(ref user_agent) = configuration.user_agent {
388 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
389 }
390 if let Some(ref token) = configuration.bearer_access_token {
391 req_builder = req_builder.bearer_auth(token.to_owned());
392 };
393 req_builder = req_builder.json(&p_body_connection_token_request);
394
395 let req = req_builder.build()?;
396 let resp = configuration.client.execute(req).await?;
397
398 let status = resp.status();
399 let content_type = resp
400 .headers()
401 .get("content-type")
402 .and_then(|v| v.to_str().ok())
403 .unwrap_or("application/octet-stream");
404 let content_type = super::ContentType::from(content_type);
405
406 if !status.is_client_error() && !status.is_server_error() {
407 let content = resp.text().await?;
408 match content_type {
409 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
410 ContentType::Text => {
411 return Err(Error::from(serde_json::Error::custom(
412 "Received `text/plain` content type response that cannot be converted to `models::ConnectionToken`",
413 )))
414 }
415 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
416 "Received `{unknown_type}` content type response that cannot be converted to `models::ConnectionToken`"
417 )))),
418 }
419 } else {
420 let content = resp.text().await?;
421 let entity: Option<RacConnectionTokensUpdateError> = serde_json::from_str(&content).ok();
422 Err(Error::ResponseError(ResponseContent {
423 status,
424 content,
425 entity,
426 }))
427 }
428}
429
430pub async fn rac_connection_tokens_used_by_list(
432 configuration: &configuration::Configuration,
433 connection_token_uuid: &str,
434) -> Result<Vec<models::UsedBy>, Error<RacConnectionTokensUsedByListError>> {
435 let p_path_connection_token_uuid = connection_token_uuid;
437
438 let uri_str = format!(
439 "{}/rac/connection_tokens/{connection_token_uuid}/used_by/",
440 configuration.base_path,
441 connection_token_uuid = crate::apis::urlencode(p_path_connection_token_uuid)
442 );
443 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
444
445 if let Some(ref user_agent) = configuration.user_agent {
446 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
447 }
448 if let Some(ref token) = configuration.bearer_access_token {
449 req_builder = req_builder.bearer_auth(token.to_owned());
450 };
451
452 let req = req_builder.build()?;
453 let resp = configuration.client.execute(req).await?;
454
455 let status = resp.status();
456 let content_type = resp
457 .headers()
458 .get("content-type")
459 .and_then(|v| v.to_str().ok())
460 .unwrap_or("application/octet-stream");
461 let content_type = super::ContentType::from(content_type);
462
463 if !status.is_client_error() && !status.is_server_error() {
464 let content = resp.text().await?;
465 match content_type {
466 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
467 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
468 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UsedBy>`")))),
469 }
470 } else {
471 let content = resp.text().await?;
472 let entity: Option<RacConnectionTokensUsedByListError> = serde_json::from_str(&content).ok();
473 Err(Error::ResponseError(ResponseContent {
474 status,
475 content,
476 entity,
477 }))
478 }
479}
480
481pub async fn rac_endpoints_create(
483 configuration: &configuration::Configuration,
484 endpoint_request: models::EndpointRequest,
485) -> Result<models::Endpoint, Error<RacEndpointsCreateError>> {
486 let p_body_endpoint_request = endpoint_request;
488
489 let uri_str = format!("{}/rac/endpoints/", configuration.base_path);
490 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
491
492 if let Some(ref user_agent) = configuration.user_agent {
493 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
494 }
495 if let Some(ref token) = configuration.bearer_access_token {
496 req_builder = req_builder.bearer_auth(token.to_owned());
497 };
498 req_builder = req_builder.json(&p_body_endpoint_request);
499
500 let req = req_builder.build()?;
501 let resp = configuration.client.execute(req).await?;
502
503 let status = resp.status();
504 let content_type = resp
505 .headers()
506 .get("content-type")
507 .and_then(|v| v.to_str().ok())
508 .unwrap_or("application/octet-stream");
509 let content_type = super::ContentType::from(content_type);
510
511 if !status.is_client_error() && !status.is_server_error() {
512 let content = resp.text().await?;
513 match content_type {
514 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
515 ContentType::Text => {
516 return Err(Error::from(serde_json::Error::custom(
517 "Received `text/plain` content type response that cannot be converted to `models::Endpoint`",
518 )))
519 }
520 ContentType::Unsupported(unknown_type) => {
521 return Err(Error::from(serde_json::Error::custom(format!(
522 "Received `{unknown_type}` content type response that cannot be converted to `models::Endpoint`"
523 ))))
524 }
525 }
526 } else {
527 let content = resp.text().await?;
528 let entity: Option<RacEndpointsCreateError> = serde_json::from_str(&content).ok();
529 Err(Error::ResponseError(ResponseContent {
530 status,
531 content,
532 entity,
533 }))
534 }
535}
536
537pub async fn rac_endpoints_destroy(
539 configuration: &configuration::Configuration,
540 pbm_uuid: &str,
541) -> Result<(), Error<RacEndpointsDestroyError>> {
542 let p_path_pbm_uuid = pbm_uuid;
544
545 let uri_str = format!(
546 "{}/rac/endpoints/{pbm_uuid}/",
547 configuration.base_path,
548 pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
549 );
550 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
551
552 if let Some(ref user_agent) = configuration.user_agent {
553 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
554 }
555 if let Some(ref token) = configuration.bearer_access_token {
556 req_builder = req_builder.bearer_auth(token.to_owned());
557 };
558
559 let req = req_builder.build()?;
560 let resp = configuration.client.execute(req).await?;
561
562 let status = resp.status();
563
564 if !status.is_client_error() && !status.is_server_error() {
565 Ok(())
566 } else {
567 let content = resp.text().await?;
568 let entity: Option<RacEndpointsDestroyError> = serde_json::from_str(&content).ok();
569 Err(Error::ResponseError(ResponseContent {
570 status,
571 content,
572 entity,
573 }))
574 }
575}
576
577pub async fn rac_endpoints_list(
579 configuration: &configuration::Configuration,
580 name: Option<&str>,
581 ordering: Option<&str>,
582 page: Option<i32>,
583 page_size: Option<i32>,
584 provider: Option<i32>,
585 search: Option<&str>,
586 superuser_full_list: Option<bool>,
587) -> Result<models::PaginatedEndpointList, Error<RacEndpointsListError>> {
588 let p_query_name = name;
590 let p_query_ordering = ordering;
591 let p_query_page = page;
592 let p_query_page_size = page_size;
593 let p_query_provider = provider;
594 let p_query_search = search;
595 let p_query_superuser_full_list = superuser_full_list;
596
597 let uri_str = format!("{}/rac/endpoints/", configuration.base_path);
598 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
599
600 if let Some(ref param_value) = p_query_name {
601 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
602 }
603 if let Some(ref param_value) = p_query_ordering {
604 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
605 }
606 if let Some(ref param_value) = p_query_page {
607 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
608 }
609 if let Some(ref param_value) = p_query_page_size {
610 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
611 }
612 if let Some(ref param_value) = p_query_provider {
613 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
614 }
615 if let Some(ref param_value) = p_query_search {
616 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
617 }
618 if let Some(ref param_value) = p_query_superuser_full_list {
619 req_builder = req_builder.query(&[("superuser_full_list", ¶m_value.to_string())]);
620 }
621 if let Some(ref user_agent) = configuration.user_agent {
622 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
623 }
624 if let Some(ref token) = configuration.bearer_access_token {
625 req_builder = req_builder.bearer_auth(token.to_owned());
626 };
627
628 let req = req_builder.build()?;
629 let resp = configuration.client.execute(req).await?;
630
631 let status = resp.status();
632 let content_type = resp
633 .headers()
634 .get("content-type")
635 .and_then(|v| v.to_str().ok())
636 .unwrap_or("application/octet-stream");
637 let content_type = super::ContentType::from(content_type);
638
639 if !status.is_client_error() && !status.is_server_error() {
640 let content = resp.text().await?;
641 match content_type {
642 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
643 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedEndpointList`"))),
644 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::PaginatedEndpointList`")))),
645 }
646 } else {
647 let content = resp.text().await?;
648 let entity: Option<RacEndpointsListError> = serde_json::from_str(&content).ok();
649 Err(Error::ResponseError(ResponseContent {
650 status,
651 content,
652 entity,
653 }))
654 }
655}
656
657pub async fn rac_endpoints_partial_update(
659 configuration: &configuration::Configuration,
660 pbm_uuid: &str,
661 patched_endpoint_request: Option<models::PatchedEndpointRequest>,
662) -> Result<models::Endpoint, Error<RacEndpointsPartialUpdateError>> {
663 let p_path_pbm_uuid = pbm_uuid;
665 let p_body_patched_endpoint_request = patched_endpoint_request;
666
667 let uri_str = format!(
668 "{}/rac/endpoints/{pbm_uuid}/",
669 configuration.base_path,
670 pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
671 );
672 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
673
674 if let Some(ref user_agent) = configuration.user_agent {
675 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
676 }
677 if let Some(ref token) = configuration.bearer_access_token {
678 req_builder = req_builder.bearer_auth(token.to_owned());
679 };
680 req_builder = req_builder.json(&p_body_patched_endpoint_request);
681
682 let req = req_builder.build()?;
683 let resp = configuration.client.execute(req).await?;
684
685 let status = resp.status();
686 let content_type = resp
687 .headers()
688 .get("content-type")
689 .and_then(|v| v.to_str().ok())
690 .unwrap_or("application/octet-stream");
691 let content_type = super::ContentType::from(content_type);
692
693 if !status.is_client_error() && !status.is_server_error() {
694 let content = resp.text().await?;
695 match content_type {
696 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
697 ContentType::Text => {
698 return Err(Error::from(serde_json::Error::custom(
699 "Received `text/plain` content type response that cannot be converted to `models::Endpoint`",
700 )))
701 }
702 ContentType::Unsupported(unknown_type) => {
703 return Err(Error::from(serde_json::Error::custom(format!(
704 "Received `{unknown_type}` content type response that cannot be converted to `models::Endpoint`"
705 ))))
706 }
707 }
708 } else {
709 let content = resp.text().await?;
710 let entity: Option<RacEndpointsPartialUpdateError> = serde_json::from_str(&content).ok();
711 Err(Error::ResponseError(ResponseContent {
712 status,
713 content,
714 entity,
715 }))
716 }
717}
718
719pub async fn rac_endpoints_retrieve(
721 configuration: &configuration::Configuration,
722 pbm_uuid: &str,
723) -> Result<models::Endpoint, Error<RacEndpointsRetrieveError>> {
724 let p_path_pbm_uuid = pbm_uuid;
726
727 let uri_str = format!(
728 "{}/rac/endpoints/{pbm_uuid}/",
729 configuration.base_path,
730 pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
731 );
732 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
733
734 if let Some(ref user_agent) = configuration.user_agent {
735 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
736 }
737 if let Some(ref token) = configuration.bearer_access_token {
738 req_builder = req_builder.bearer_auth(token.to_owned());
739 };
740
741 let req = req_builder.build()?;
742 let resp = configuration.client.execute(req).await?;
743
744 let status = resp.status();
745 let content_type = resp
746 .headers()
747 .get("content-type")
748 .and_then(|v| v.to_str().ok())
749 .unwrap_or("application/octet-stream");
750 let content_type = super::ContentType::from(content_type);
751
752 if !status.is_client_error() && !status.is_server_error() {
753 let content = resp.text().await?;
754 match content_type {
755 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
756 ContentType::Text => {
757 return Err(Error::from(serde_json::Error::custom(
758 "Received `text/plain` content type response that cannot be converted to `models::Endpoint`",
759 )))
760 }
761 ContentType::Unsupported(unknown_type) => {
762 return Err(Error::from(serde_json::Error::custom(format!(
763 "Received `{unknown_type}` content type response that cannot be converted to `models::Endpoint`"
764 ))))
765 }
766 }
767 } else {
768 let content = resp.text().await?;
769 let entity: Option<RacEndpointsRetrieveError> = serde_json::from_str(&content).ok();
770 Err(Error::ResponseError(ResponseContent {
771 status,
772 content,
773 entity,
774 }))
775 }
776}
777
778pub async fn rac_endpoints_update(
780 configuration: &configuration::Configuration,
781 pbm_uuid: &str,
782 endpoint_request: models::EndpointRequest,
783) -> Result<models::Endpoint, Error<RacEndpointsUpdateError>> {
784 let p_path_pbm_uuid = pbm_uuid;
786 let p_body_endpoint_request = endpoint_request;
787
788 let uri_str = format!(
789 "{}/rac/endpoints/{pbm_uuid}/",
790 configuration.base_path,
791 pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
792 );
793 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
794
795 if let Some(ref user_agent) = configuration.user_agent {
796 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
797 }
798 if let Some(ref token) = configuration.bearer_access_token {
799 req_builder = req_builder.bearer_auth(token.to_owned());
800 };
801 req_builder = req_builder.json(&p_body_endpoint_request);
802
803 let req = req_builder.build()?;
804 let resp = configuration.client.execute(req).await?;
805
806 let status = resp.status();
807 let content_type = resp
808 .headers()
809 .get("content-type")
810 .and_then(|v| v.to_str().ok())
811 .unwrap_or("application/octet-stream");
812 let content_type = super::ContentType::from(content_type);
813
814 if !status.is_client_error() && !status.is_server_error() {
815 let content = resp.text().await?;
816 match content_type {
817 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
818 ContentType::Text => {
819 return Err(Error::from(serde_json::Error::custom(
820 "Received `text/plain` content type response that cannot be converted to `models::Endpoint`",
821 )))
822 }
823 ContentType::Unsupported(unknown_type) => {
824 return Err(Error::from(serde_json::Error::custom(format!(
825 "Received `{unknown_type}` content type response that cannot be converted to `models::Endpoint`"
826 ))))
827 }
828 }
829 } else {
830 let content = resp.text().await?;
831 let entity: Option<RacEndpointsUpdateError> = serde_json::from_str(&content).ok();
832 Err(Error::ResponseError(ResponseContent {
833 status,
834 content,
835 entity,
836 }))
837 }
838}
839
840pub async fn rac_endpoints_used_by_list(
842 configuration: &configuration::Configuration,
843 pbm_uuid: &str,
844) -> Result<Vec<models::UsedBy>, Error<RacEndpointsUsedByListError>> {
845 let p_path_pbm_uuid = pbm_uuid;
847
848 let uri_str = format!(
849 "{}/rac/endpoints/{pbm_uuid}/used_by/",
850 configuration.base_path,
851 pbm_uuid = crate::apis::urlencode(p_path_pbm_uuid)
852 );
853 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
854
855 if let Some(ref user_agent) = configuration.user_agent {
856 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
857 }
858 if let Some(ref token) = configuration.bearer_access_token {
859 req_builder = req_builder.bearer_auth(token.to_owned());
860 };
861
862 let req = req_builder.build()?;
863 let resp = configuration.client.execute(req).await?;
864
865 let status = resp.status();
866 let content_type = resp
867 .headers()
868 .get("content-type")
869 .and_then(|v| v.to_str().ok())
870 .unwrap_or("application/octet-stream");
871 let content_type = super::ContentType::from(content_type);
872
873 if !status.is_client_error() && !status.is_server_error() {
874 let content = resp.text().await?;
875 match content_type {
876 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
877 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
878 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UsedBy>`")))),
879 }
880 } else {
881 let content = resp.text().await?;
882 let entity: Option<RacEndpointsUsedByListError> = serde_json::from_str(&content).ok();
883 Err(Error::ResponseError(ResponseContent {
884 status,
885 content,
886 entity,
887 }))
888 }
889}