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 EnterpriseLicenseCreateError {
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 EnterpriseLicenseDestroyError {
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 EnterpriseLicenseForecastRetrieveError {
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 EnterpriseLicenseInstallIdRetrieveError {
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 EnterpriseLicenseListError {
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 EnterpriseLicensePartialUpdateError {
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 EnterpriseLicenseRetrieveError {
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 EnterpriseLicenseSummaryRetrieveError {
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 EnterpriseLicenseUpdateError {
92 Status400(models::ValidationError),
93 Status403(models::GenericError),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum EnterpriseLicenseUsedByListError {
101 Status400(models::ValidationError),
102 Status403(models::GenericError),
103 UnknownValue(serde_json::Value),
104}
105
106pub async fn enterprise_license_create(
108 configuration: &configuration::Configuration,
109 license_request: models::LicenseRequest,
110) -> Result<models::License, Error<EnterpriseLicenseCreateError>> {
111 let p_body_license_request = license_request;
113
114 let uri_str = format!("{}/enterprise/license/", configuration.base_path);
115 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
116
117 if let Some(ref user_agent) = configuration.user_agent {
118 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
119 }
120 if let Some(ref token) = configuration.bearer_access_token {
121 req_builder = req_builder.bearer_auth(token.to_owned());
122 };
123 req_builder = req_builder.json(&p_body_license_request);
124
125 let req = req_builder.build()?;
126 let resp = configuration.client.execute(req).await?;
127
128 let status = resp.status();
129 let content_type = resp
130 .headers()
131 .get("content-type")
132 .and_then(|v| v.to_str().ok())
133 .unwrap_or("application/octet-stream");
134 let content_type = super::ContentType::from(content_type);
135
136 if !status.is_client_error() && !status.is_server_error() {
137 let content = resp.text().await?;
138 match content_type {
139 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
140 ContentType::Text => {
141 return Err(Error::from(serde_json::Error::custom(
142 "Received `text/plain` content type response that cannot be converted to `models::License`",
143 )))
144 }
145 ContentType::Unsupported(unknown_type) => {
146 return Err(Error::from(serde_json::Error::custom(format!(
147 "Received `{unknown_type}` content type response that cannot be converted to `models::License`"
148 ))))
149 }
150 }
151 } else {
152 let content = resp.text().await?;
153 let entity: Option<EnterpriseLicenseCreateError> = serde_json::from_str(&content).ok();
154 Err(Error::ResponseError(ResponseContent {
155 status,
156 content,
157 entity,
158 }))
159 }
160}
161
162pub async fn enterprise_license_destroy(
164 configuration: &configuration::Configuration,
165 license_uuid: &str,
166) -> Result<(), Error<EnterpriseLicenseDestroyError>> {
167 let p_path_license_uuid = license_uuid;
169
170 let uri_str = format!(
171 "{}/enterprise/license/{license_uuid}/",
172 configuration.base_path,
173 license_uuid = crate::apis::urlencode(p_path_license_uuid)
174 );
175 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
176
177 if let Some(ref user_agent) = configuration.user_agent {
178 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
179 }
180 if let Some(ref token) = configuration.bearer_access_token {
181 req_builder = req_builder.bearer_auth(token.to_owned());
182 };
183
184 let req = req_builder.build()?;
185 let resp = configuration.client.execute(req).await?;
186
187 let status = resp.status();
188
189 if !status.is_client_error() && !status.is_server_error() {
190 Ok(())
191 } else {
192 let content = resp.text().await?;
193 let entity: Option<EnterpriseLicenseDestroyError> = serde_json::from_str(&content).ok();
194 Err(Error::ResponseError(ResponseContent {
195 status,
196 content,
197 entity,
198 }))
199 }
200}
201
202pub async fn enterprise_license_forecast_retrieve(
204 configuration: &configuration::Configuration,
205) -> Result<models::LicenseForecast, Error<EnterpriseLicenseForecastRetrieveError>> {
206 let uri_str = format!("{}/enterprise/license/forecast/", configuration.base_path);
207 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
208
209 if let Some(ref user_agent) = configuration.user_agent {
210 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
211 }
212 if let Some(ref token) = configuration.bearer_access_token {
213 req_builder = req_builder.bearer_auth(token.to_owned());
214 };
215
216 let req = req_builder.build()?;
217 let resp = configuration.client.execute(req).await?;
218
219 let status = resp.status();
220 let content_type = resp
221 .headers()
222 .get("content-type")
223 .and_then(|v| v.to_str().ok())
224 .unwrap_or("application/octet-stream");
225 let content_type = super::ContentType::from(content_type);
226
227 if !status.is_client_error() && !status.is_server_error() {
228 let content = resp.text().await?;
229 match content_type {
230 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
231 ContentType::Text => {
232 return Err(Error::from(serde_json::Error::custom(
233 "Received `text/plain` content type response that cannot be converted to `models::LicenseForecast`",
234 )))
235 }
236 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
237 "Received `{unknown_type}` content type response that cannot be converted to `models::LicenseForecast`"
238 )))),
239 }
240 } else {
241 let content = resp.text().await?;
242 let entity: Option<EnterpriseLicenseForecastRetrieveError> = serde_json::from_str(&content).ok();
243 Err(Error::ResponseError(ResponseContent {
244 status,
245 content,
246 entity,
247 }))
248 }
249}
250
251pub async fn enterprise_license_install_id_retrieve(
253 configuration: &configuration::Configuration,
254) -> Result<models::InstallId, Error<EnterpriseLicenseInstallIdRetrieveError>> {
255 let uri_str = format!("{}/enterprise/license/install_id/", configuration.base_path);
256 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
257
258 if let Some(ref user_agent) = configuration.user_agent {
259 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
260 }
261 if let Some(ref token) = configuration.bearer_access_token {
262 req_builder = req_builder.bearer_auth(token.to_owned());
263 };
264
265 let req = req_builder.build()?;
266 let resp = configuration.client.execute(req).await?;
267
268 let status = resp.status();
269 let content_type = resp
270 .headers()
271 .get("content-type")
272 .and_then(|v| v.to_str().ok())
273 .unwrap_or("application/octet-stream");
274 let content_type = super::ContentType::from(content_type);
275
276 if !status.is_client_error() && !status.is_server_error() {
277 let content = resp.text().await?;
278 match content_type {
279 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
280 ContentType::Text => {
281 return Err(Error::from(serde_json::Error::custom(
282 "Received `text/plain` content type response that cannot be converted to `models::InstallId`",
283 )))
284 }
285 ContentType::Unsupported(unknown_type) => {
286 return Err(Error::from(serde_json::Error::custom(format!(
287 "Received `{unknown_type}` content type response that cannot be converted to `models::InstallId`"
288 ))))
289 }
290 }
291 } else {
292 let content = resp.text().await?;
293 let entity: Option<EnterpriseLicenseInstallIdRetrieveError> = serde_json::from_str(&content).ok();
294 Err(Error::ResponseError(ResponseContent {
295 status,
296 content,
297 entity,
298 }))
299 }
300}
301
302pub async fn enterprise_license_list(
304 configuration: &configuration::Configuration,
305 name: Option<&str>,
306 ordering: Option<&str>,
307 page: Option<i32>,
308 page_size: Option<i32>,
309 search: Option<&str>,
310) -> Result<models::PaginatedLicenseList, Error<EnterpriseLicenseListError>> {
311 let p_query_name = name;
313 let p_query_ordering = ordering;
314 let p_query_page = page;
315 let p_query_page_size = page_size;
316 let p_query_search = search;
317
318 let uri_str = format!("{}/enterprise/license/", configuration.base_path);
319 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
320
321 if let Some(ref param_value) = p_query_name {
322 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
323 }
324 if let Some(ref param_value) = p_query_ordering {
325 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
326 }
327 if let Some(ref param_value) = p_query_page {
328 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
329 }
330 if let Some(ref param_value) = p_query_page_size {
331 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
332 }
333 if let Some(ref param_value) = p_query_search {
334 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
335 }
336 if let Some(ref user_agent) = configuration.user_agent {
337 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
338 }
339 if let Some(ref token) = configuration.bearer_access_token {
340 req_builder = req_builder.bearer_auth(token.to_owned());
341 };
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347 let content_type = resp
348 .headers()
349 .get("content-type")
350 .and_then(|v| v.to_str().ok())
351 .unwrap_or("application/octet-stream");
352 let content_type = super::ContentType::from(content_type);
353
354 if !status.is_client_error() && !status.is_server_error() {
355 let content = resp.text().await?;
356 match content_type {
357 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
358 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedLicenseList`"))),
359 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::PaginatedLicenseList`")))),
360 }
361 } else {
362 let content = resp.text().await?;
363 let entity: Option<EnterpriseLicenseListError> = serde_json::from_str(&content).ok();
364 Err(Error::ResponseError(ResponseContent {
365 status,
366 content,
367 entity,
368 }))
369 }
370}
371
372pub async fn enterprise_license_partial_update(
374 configuration: &configuration::Configuration,
375 license_uuid: &str,
376 patched_license_request: Option<models::PatchedLicenseRequest>,
377) -> Result<models::License, Error<EnterpriseLicensePartialUpdateError>> {
378 let p_path_license_uuid = license_uuid;
380 let p_body_patched_license_request = patched_license_request;
381
382 let uri_str = format!(
383 "{}/enterprise/license/{license_uuid}/",
384 configuration.base_path,
385 license_uuid = crate::apis::urlencode(p_path_license_uuid)
386 );
387 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
388
389 if let Some(ref user_agent) = configuration.user_agent {
390 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
391 }
392 if let Some(ref token) = configuration.bearer_access_token {
393 req_builder = req_builder.bearer_auth(token.to_owned());
394 };
395 req_builder = req_builder.json(&p_body_patched_license_request);
396
397 let req = req_builder.build()?;
398 let resp = configuration.client.execute(req).await?;
399
400 let status = resp.status();
401 let content_type = resp
402 .headers()
403 .get("content-type")
404 .and_then(|v| v.to_str().ok())
405 .unwrap_or("application/octet-stream");
406 let content_type = super::ContentType::from(content_type);
407
408 if !status.is_client_error() && !status.is_server_error() {
409 let content = resp.text().await?;
410 match content_type {
411 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
412 ContentType::Text => {
413 return Err(Error::from(serde_json::Error::custom(
414 "Received `text/plain` content type response that cannot be converted to `models::License`",
415 )))
416 }
417 ContentType::Unsupported(unknown_type) => {
418 return Err(Error::from(serde_json::Error::custom(format!(
419 "Received `{unknown_type}` content type response that cannot be converted to `models::License`"
420 ))))
421 }
422 }
423 } else {
424 let content = resp.text().await?;
425 let entity: Option<EnterpriseLicensePartialUpdateError> = serde_json::from_str(&content).ok();
426 Err(Error::ResponseError(ResponseContent {
427 status,
428 content,
429 entity,
430 }))
431 }
432}
433
434pub async fn enterprise_license_retrieve(
436 configuration: &configuration::Configuration,
437 license_uuid: &str,
438) -> Result<models::License, Error<EnterpriseLicenseRetrieveError>> {
439 let p_path_license_uuid = license_uuid;
441
442 let uri_str = format!(
443 "{}/enterprise/license/{license_uuid}/",
444 configuration.base_path,
445 license_uuid = crate::apis::urlencode(p_path_license_uuid)
446 );
447 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
448
449 if let Some(ref user_agent) = configuration.user_agent {
450 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
451 }
452 if let Some(ref token) = configuration.bearer_access_token {
453 req_builder = req_builder.bearer_auth(token.to_owned());
454 };
455
456 let req = req_builder.build()?;
457 let resp = configuration.client.execute(req).await?;
458
459 let status = resp.status();
460 let content_type = resp
461 .headers()
462 .get("content-type")
463 .and_then(|v| v.to_str().ok())
464 .unwrap_or("application/octet-stream");
465 let content_type = super::ContentType::from(content_type);
466
467 if !status.is_client_error() && !status.is_server_error() {
468 let content = resp.text().await?;
469 match content_type {
470 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
471 ContentType::Text => {
472 return Err(Error::from(serde_json::Error::custom(
473 "Received `text/plain` content type response that cannot be converted to `models::License`",
474 )))
475 }
476 ContentType::Unsupported(unknown_type) => {
477 return Err(Error::from(serde_json::Error::custom(format!(
478 "Received `{unknown_type}` content type response that cannot be converted to `models::License`"
479 ))))
480 }
481 }
482 } else {
483 let content = resp.text().await?;
484 let entity: Option<EnterpriseLicenseRetrieveError> = serde_json::from_str(&content).ok();
485 Err(Error::ResponseError(ResponseContent {
486 status,
487 content,
488 entity,
489 }))
490 }
491}
492
493pub async fn enterprise_license_summary_retrieve(
495 configuration: &configuration::Configuration,
496 cached: Option<bool>,
497) -> Result<models::LicenseSummary, Error<EnterpriseLicenseSummaryRetrieveError>> {
498 let p_query_cached = cached;
500
501 let uri_str = format!("{}/enterprise/license/summary/", configuration.base_path);
502 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
503
504 if let Some(ref param_value) = p_query_cached {
505 req_builder = req_builder.query(&[("cached", ¶m_value.to_string())]);
506 }
507 if let Some(ref user_agent) = configuration.user_agent {
508 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
509 }
510 if let Some(ref token) = configuration.bearer_access_token {
511 req_builder = req_builder.bearer_auth(token.to_owned());
512 };
513
514 let req = req_builder.build()?;
515 let resp = configuration.client.execute(req).await?;
516
517 let status = resp.status();
518 let content_type = resp
519 .headers()
520 .get("content-type")
521 .and_then(|v| v.to_str().ok())
522 .unwrap_or("application/octet-stream");
523 let content_type = super::ContentType::from(content_type);
524
525 if !status.is_client_error() && !status.is_server_error() {
526 let content = resp.text().await?;
527 match content_type {
528 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
529 ContentType::Text => {
530 return Err(Error::from(serde_json::Error::custom(
531 "Received `text/plain` content type response that cannot be converted to `models::LicenseSummary`",
532 )))
533 }
534 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
535 "Received `{unknown_type}` content type response that cannot be converted to `models::LicenseSummary`"
536 )))),
537 }
538 } else {
539 let content = resp.text().await?;
540 let entity: Option<EnterpriseLicenseSummaryRetrieveError> = serde_json::from_str(&content).ok();
541 Err(Error::ResponseError(ResponseContent {
542 status,
543 content,
544 entity,
545 }))
546 }
547}
548
549pub async fn enterprise_license_update(
551 configuration: &configuration::Configuration,
552 license_uuid: &str,
553 license_request: models::LicenseRequest,
554) -> Result<models::License, Error<EnterpriseLicenseUpdateError>> {
555 let p_path_license_uuid = license_uuid;
557 let p_body_license_request = license_request;
558
559 let uri_str = format!(
560 "{}/enterprise/license/{license_uuid}/",
561 configuration.base_path,
562 license_uuid = crate::apis::urlencode(p_path_license_uuid)
563 );
564 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
565
566 if let Some(ref user_agent) = configuration.user_agent {
567 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
568 }
569 if let Some(ref token) = configuration.bearer_access_token {
570 req_builder = req_builder.bearer_auth(token.to_owned());
571 };
572 req_builder = req_builder.json(&p_body_license_request);
573
574 let req = req_builder.build()?;
575 let resp = configuration.client.execute(req).await?;
576
577 let status = resp.status();
578 let content_type = resp
579 .headers()
580 .get("content-type")
581 .and_then(|v| v.to_str().ok())
582 .unwrap_or("application/octet-stream");
583 let content_type = super::ContentType::from(content_type);
584
585 if !status.is_client_error() && !status.is_server_error() {
586 let content = resp.text().await?;
587 match content_type {
588 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
589 ContentType::Text => {
590 return Err(Error::from(serde_json::Error::custom(
591 "Received `text/plain` content type response that cannot be converted to `models::License`",
592 )))
593 }
594 ContentType::Unsupported(unknown_type) => {
595 return Err(Error::from(serde_json::Error::custom(format!(
596 "Received `{unknown_type}` content type response that cannot be converted to `models::License`"
597 ))))
598 }
599 }
600 } else {
601 let content = resp.text().await?;
602 let entity: Option<EnterpriseLicenseUpdateError> = serde_json::from_str(&content).ok();
603 Err(Error::ResponseError(ResponseContent {
604 status,
605 content,
606 entity,
607 }))
608 }
609}
610
611pub async fn enterprise_license_used_by_list(
613 configuration: &configuration::Configuration,
614 license_uuid: &str,
615) -> Result<Vec<models::UsedBy>, Error<EnterpriseLicenseUsedByListError>> {
616 let p_path_license_uuid = license_uuid;
618
619 let uri_str = format!(
620 "{}/enterprise/license/{license_uuid}/used_by/",
621 configuration.base_path,
622 license_uuid = crate::apis::urlencode(p_path_license_uuid)
623 );
624 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
625
626 if let Some(ref user_agent) = configuration.user_agent {
627 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
628 }
629 if let Some(ref token) = configuration.bearer_access_token {
630 req_builder = req_builder.bearer_auth(token.to_owned());
631 };
632
633 let req = req_builder.build()?;
634 let resp = configuration.client.execute(req).await?;
635
636 let status = resp.status();
637 let content_type = resp
638 .headers()
639 .get("content-type")
640 .and_then(|v| v.to_str().ok())
641 .unwrap_or("application/octet-stream");
642 let content_type = super::ContentType::from(content_type);
643
644 if !status.is_client_error() && !status.is_server_error() {
645 let content = resp.text().await?;
646 match content_type {
647 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
648 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
649 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>`")))),
650 }
651 } else {
652 let content = resp.text().await?;
653 let entity: Option<EnterpriseLicenseUsedByListError> = serde_json::from_str(&content).ok();
654 Err(Error::ResponseError(ResponseContent {
655 status,
656 content,
657 entity,
658 }))
659 }
660}