1use super::{configuration, ContentType, Error};
26use crate::{apis::ResponseContent, models};
27use ::qcs_api_client_common::backoff::{
28 duration_from_io_error, duration_from_reqwest_error, duration_from_response, ExponentialBackoff,
29};
30#[cfg(feature = "tracing")]
31use qcs_api_client_common::configuration::tokens::TokenRefresher;
32use reqwest::StatusCode;
33use serde::{Deserialize, Serialize};
34
35#[cfg(feature = "clap")]
36#[allow(unused, reason = "not used in all templates, but required in some")]
37use ::{miette::IntoDiagnostic as _, qcs_api_client_common::clap_utils::JsonMaybeStdin};
38
39#[cfg(feature = "clap")]
41#[derive(Debug, clap::Args)]
42pub struct ActivateUserClapParams {
43 pub activate_user_request: Option<JsonMaybeStdin<crate::models::ActivateUserRequest>>,
44}
45
46#[cfg(feature = "clap")]
47impl ActivateUserClapParams {
48 pub async fn execute(
49 self,
50 configuration: &configuration::Configuration,
51 ) -> Result<models::User, miette::Error> {
52 let request = self
53 .activate_user_request
54 .map(|body| body.into_inner().into_inner());
55
56 activate_user(configuration, request)
57 .await
58 .into_diagnostic()
59 }
60}
61
62#[cfg(feature = "clap")]
64#[derive(Debug, clap::Args)]
65pub struct AddGroupUserClapParams {
66 pub add_group_user_request: JsonMaybeStdin<crate::models::AddGroupUserRequest>,
67}
68
69#[cfg(feature = "clap")]
70impl AddGroupUserClapParams {
71 pub async fn execute(
72 self,
73 configuration: &configuration::Configuration,
74 ) -> Result<(), miette::Error> {
75 let request = self.add_group_user_request.into_inner().into_inner();
76
77 add_group_user(configuration, request)
78 .await
79 .into_diagnostic()
80 }
81}
82
83#[cfg(feature = "clap")]
85#[derive(Debug, clap::Args)]
86pub struct DismissViewerAnnouncementClapParams {
87 #[arg(long)]
89 pub announcement_id: i64,
90}
91
92#[cfg(feature = "clap")]
93impl DismissViewerAnnouncementClapParams {
94 pub async fn execute(
95 self,
96 configuration: &configuration::Configuration,
97 ) -> Result<(), miette::Error> {
98 dismiss_viewer_announcement(configuration, self.announcement_id)
99 .await
100 .into_diagnostic()
101 }
102}
103
104#[cfg(feature = "clap")]
106#[derive(Debug, clap::Args)]
107pub struct GetGroupBalanceClapParams {
108 #[arg(long)]
110 pub group_name: String,
111}
112
113#[cfg(feature = "clap")]
114impl GetGroupBalanceClapParams {
115 pub async fn execute(
116 self,
117 configuration: &configuration::Configuration,
118 ) -> Result<models::AccountBalance, miette::Error> {
119 get_group_balance(configuration, self.group_name.as_str())
120 .await
121 .into_diagnostic()
122 }
123}
124
125#[cfg(feature = "clap")]
127#[derive(Debug, clap::Args)]
128pub struct GetGroupBillingCustomerClapParams {
129 #[arg(long)]
131 pub group_name: String,
132}
133
134#[cfg(feature = "clap")]
135impl GetGroupBillingCustomerClapParams {
136 pub async fn execute(
137 self,
138 configuration: &configuration::Configuration,
139 ) -> Result<models::BillingCustomer, miette::Error> {
140 get_group_billing_customer(configuration, self.group_name.as_str())
141 .await
142 .into_diagnostic()
143 }
144}
145
146#[cfg(feature = "clap")]
148#[derive(Debug, clap::Args)]
149pub struct GetGroupUpcomingBillingInvoiceClapParams {
150 #[arg(long)]
152 pub group_name: String,
153}
154
155#[cfg(feature = "clap")]
156impl GetGroupUpcomingBillingInvoiceClapParams {
157 pub async fn execute(
158 self,
159 configuration: &configuration::Configuration,
160 ) -> Result<models::BillingUpcomingInvoice, miette::Error> {
161 get_group_upcoming_billing_invoice(configuration, self.group_name.as_str())
162 .await
163 .into_diagnostic()
164 }
165}
166
167#[cfg(feature = "clap")]
169#[derive(Debug, clap::Args)]
170pub struct GetUserBalanceClapParams {
171 #[arg(long)]
173 pub user_id: String,
174}
175
176#[cfg(feature = "clap")]
177impl GetUserBalanceClapParams {
178 pub async fn execute(
179 self,
180 configuration: &configuration::Configuration,
181 ) -> Result<models::AccountBalance, miette::Error> {
182 get_user_balance(configuration, self.user_id.as_str())
183 .await
184 .into_diagnostic()
185 }
186}
187
188#[cfg(feature = "clap")]
190#[derive(Debug, clap::Args)]
191pub struct GetUserBillingCustomerClapParams {
192 #[arg(long)]
194 pub user_id: String,
195}
196
197#[cfg(feature = "clap")]
198impl GetUserBillingCustomerClapParams {
199 pub async fn execute(
200 self,
201 configuration: &configuration::Configuration,
202 ) -> Result<models::BillingCustomer, miette::Error> {
203 get_user_billing_customer(configuration, self.user_id.as_str())
204 .await
205 .into_diagnostic()
206 }
207}
208
209#[cfg(feature = "clap")]
211#[derive(Debug, clap::Args)]
212pub struct GetUserEventBillingPriceClapParams {
213 #[arg(long)]
215 pub user_id: String,
216 pub get_account_event_billing_price_request:
217 JsonMaybeStdin<crate::models::GetAccountEventBillingPriceRequest>,
218}
219
220#[cfg(feature = "clap")]
221impl GetUserEventBillingPriceClapParams {
222 pub async fn execute(
223 self,
224 configuration: &configuration::Configuration,
225 ) -> Result<models::EventBillingPriceRate, miette::Error> {
226 let request = self
227 .get_account_event_billing_price_request
228 .into_inner()
229 .into_inner();
230
231 get_user_event_billing_price(configuration, self.user_id.as_str(), request)
232 .await
233 .into_diagnostic()
234 }
235}
236
237#[cfg(feature = "clap")]
239#[derive(Debug, clap::Args)]
240pub struct GetUserUpcomingBillingInvoiceClapParams {
241 #[arg(long)]
243 pub user_id: String,
244}
245
246#[cfg(feature = "clap")]
247impl GetUserUpcomingBillingInvoiceClapParams {
248 pub async fn execute(
249 self,
250 configuration: &configuration::Configuration,
251 ) -> Result<models::BillingUpcomingInvoice, miette::Error> {
252 get_user_upcoming_billing_invoice(configuration, self.user_id.as_str())
253 .await
254 .into_diagnostic()
255 }
256}
257
258#[cfg(feature = "clap")]
260#[derive(Debug, clap::Args)]
261pub struct GetViewerUserOnboardingCompletedClapParams {}
262
263#[cfg(feature = "clap")]
264impl GetViewerUserOnboardingCompletedClapParams {
265 pub async fn execute(
266 self,
267 configuration: &configuration::Configuration,
268 ) -> Result<models::ViewerUserOnboardingCompleted, miette::Error> {
269 get_viewer_user_onboarding_completed(configuration)
270 .await
271 .into_diagnostic()
272 }
273}
274
275#[cfg(feature = "clap")]
277#[derive(Debug, clap::Args)]
278pub struct ListGroupBillingInvoiceLinesClapParams {
279 #[arg(long)]
281 pub group_name: String,
282 #[arg(long)]
284 pub billing_invoice_id: String,
285 #[arg(long)]
287 pub page_token: Option<String>,
288 #[arg(long)]
289 pub page_size: Option<i64>,
290}
291
292#[cfg(feature = "clap")]
293impl ListGroupBillingInvoiceLinesClapParams {
294 pub async fn execute(
295 self,
296 configuration: &configuration::Configuration,
297 ) -> Result<models::ListAccountBillingInvoiceLinesResponse, miette::Error> {
298 list_group_billing_invoice_lines(
299 configuration,
300 self.group_name.as_str(),
301 self.billing_invoice_id.as_str(),
302 self.page_token.as_deref(),
303 self.page_size,
304 )
305 .await
306 .into_diagnostic()
307 }
308}
309
310#[cfg(feature = "clap")]
312#[derive(Debug, clap::Args)]
313pub struct ListGroupBillingInvoicesClapParams {
314 #[arg(long)]
316 pub group_name: String,
317 #[arg(long)]
319 pub page_token: Option<String>,
320 #[arg(long)]
321 pub page_size: Option<i64>,
322}
323
324#[cfg(feature = "clap")]
325impl ListGroupBillingInvoicesClapParams {
326 pub async fn execute(
327 self,
328 configuration: &configuration::Configuration,
329 ) -> Result<models::ListAccountBillingInvoicesResponse, miette::Error> {
330 list_group_billing_invoices(
331 configuration,
332 self.group_name.as_str(),
333 self.page_token.as_deref(),
334 self.page_size,
335 )
336 .await
337 .into_diagnostic()
338 }
339}
340
341#[cfg(feature = "clap")]
343#[derive(Debug, clap::Args)]
344pub struct ListGroupUpcomingBillingInvoiceLinesClapParams {
345 #[arg(long)]
347 pub group_name: String,
348 #[arg(long)]
350 pub page_token: Option<String>,
351 #[arg(long)]
352 pub page_size: Option<i64>,
353}
354
355#[cfg(feature = "clap")]
356impl ListGroupUpcomingBillingInvoiceLinesClapParams {
357 pub async fn execute(
358 self,
359 configuration: &configuration::Configuration,
360 ) -> Result<models::ListAccountBillingInvoiceLinesResponse, miette::Error> {
361 list_group_upcoming_billing_invoice_lines(
362 configuration,
363 self.group_name.as_str(),
364 self.page_token.as_deref(),
365 self.page_size,
366 )
367 .await
368 .into_diagnostic()
369 }
370}
371
372#[cfg(feature = "clap")]
374#[derive(Debug, clap::Args)]
375pub struct ListGroupUsersClapParams {
376 #[arg(long)]
378 pub group_name: String,
379 #[arg(long)]
380 pub page_size: Option<i64>,
381 #[arg(long)]
383 pub page_token: Option<String>,
384}
385
386#[cfg(feature = "clap")]
387impl ListGroupUsersClapParams {
388 pub async fn execute(
389 self,
390 configuration: &configuration::Configuration,
391 ) -> Result<models::ListGroupUsersResponse, miette::Error> {
392 list_group_users(
393 configuration,
394 self.group_name.as_str(),
395 self.page_size,
396 self.page_token.as_deref(),
397 )
398 .await
399 .into_diagnostic()
400 }
401}
402
403#[cfg(feature = "clap")]
405#[derive(Debug, clap::Args)]
406pub struct ListUserBillingInvoiceLinesClapParams {
407 #[arg(long)]
409 pub user_id: String,
410 #[arg(long)]
412 pub billing_invoice_id: String,
413 #[arg(long)]
415 pub page_token: Option<String>,
416 #[arg(long)]
417 pub page_size: Option<i64>,
418}
419
420#[cfg(feature = "clap")]
421impl ListUserBillingInvoiceLinesClapParams {
422 pub async fn execute(
423 self,
424 configuration: &configuration::Configuration,
425 ) -> Result<models::ListAccountBillingInvoiceLinesResponse, miette::Error> {
426 list_user_billing_invoice_lines(
427 configuration,
428 self.user_id.as_str(),
429 self.billing_invoice_id.as_str(),
430 self.page_token.as_deref(),
431 self.page_size,
432 )
433 .await
434 .into_diagnostic()
435 }
436}
437
438#[cfg(feature = "clap")]
440#[derive(Debug, clap::Args)]
441pub struct ListUserBillingInvoicesClapParams {
442 #[arg(long)]
444 pub user_id: String,
445 #[arg(long)]
447 pub page_token: Option<String>,
448 #[arg(long)]
449 pub page_size: Option<i64>,
450}
451
452#[cfg(feature = "clap")]
453impl ListUserBillingInvoicesClapParams {
454 pub async fn execute(
455 self,
456 configuration: &configuration::Configuration,
457 ) -> Result<models::ListAccountBillingInvoicesResponse, miette::Error> {
458 list_user_billing_invoices(
459 configuration,
460 self.user_id.as_str(),
461 self.page_token.as_deref(),
462 self.page_size,
463 )
464 .await
465 .into_diagnostic()
466 }
467}
468
469#[cfg(feature = "clap")]
471#[derive(Debug, clap::Args)]
472pub struct ListUserGroupsClapParams {
473 #[arg(long)]
475 pub user_id: String,
476 #[arg(long)]
477 pub page_size: Option<i64>,
478 #[arg(long)]
480 pub page_token: Option<String>,
481}
482
483#[cfg(feature = "clap")]
484impl ListUserGroupsClapParams {
485 pub async fn execute(
486 self,
487 configuration: &configuration::Configuration,
488 ) -> Result<models::ListGroupsResponse, miette::Error> {
489 list_user_groups(
490 configuration,
491 self.user_id.as_str(),
492 self.page_size,
493 self.page_token.as_deref(),
494 )
495 .await
496 .into_diagnostic()
497 }
498}
499
500#[cfg(feature = "clap")]
502#[derive(Debug, clap::Args)]
503pub struct ListUserUpcomingBillingInvoiceLinesClapParams {
504 #[arg(long)]
506 pub user_id: String,
507 #[arg(long)]
509 pub page_token: Option<String>,
510 #[arg(long)]
511 pub page_size: Option<i64>,
512}
513
514#[cfg(feature = "clap")]
515impl ListUserUpcomingBillingInvoiceLinesClapParams {
516 pub async fn execute(
517 self,
518 configuration: &configuration::Configuration,
519 ) -> Result<models::ListAccountBillingInvoiceLinesResponse, miette::Error> {
520 list_user_upcoming_billing_invoice_lines(
521 configuration,
522 self.user_id.as_str(),
523 self.page_token.as_deref(),
524 self.page_size,
525 )
526 .await
527 .into_diagnostic()
528 }
529}
530
531#[cfg(feature = "clap")]
533#[derive(Debug, clap::Args)]
534pub struct ListViewerAnnouncementsClapParams {
535 #[arg(long)]
536 pub page_size: Option<i64>,
537 #[arg(long)]
539 pub page_token: Option<String>,
540 #[arg(long)]
542 pub include_dismissed: Option<bool>,
543}
544
545#[cfg(feature = "clap")]
546impl ListViewerAnnouncementsClapParams {
547 pub async fn execute(
548 self,
549 configuration: &configuration::Configuration,
550 ) -> Result<models::AnnouncementsResponse, miette::Error> {
551 list_viewer_announcements(
552 configuration,
553 self.page_size,
554 self.page_token.as_deref(),
555 self.include_dismissed,
556 )
557 .await
558 .into_diagnostic()
559 }
560}
561
562#[cfg(feature = "clap")]
564#[derive(Debug, clap::Args)]
565pub struct PutViewerUserOnboardingCompletedClapParams {
566 pub viewer_user_onboarding_completed:
567 Option<JsonMaybeStdin<crate::models::ViewerUserOnboardingCompleted>>,
568}
569
570#[cfg(feature = "clap")]
571impl PutViewerUserOnboardingCompletedClapParams {
572 pub async fn execute(
573 self,
574 configuration: &configuration::Configuration,
575 ) -> Result<models::ViewerUserOnboardingCompleted, miette::Error> {
576 let request = self
577 .viewer_user_onboarding_completed
578 .map(|body| body.into_inner().into_inner());
579
580 put_viewer_user_onboarding_completed(configuration, request)
581 .await
582 .into_diagnostic()
583 }
584}
585
586#[cfg(feature = "clap")]
588#[derive(Debug, clap::Args)]
589pub struct RemoveGroupUserClapParams {
590 pub remove_group_user_request: JsonMaybeStdin<crate::models::RemoveGroupUserRequest>,
591}
592
593#[cfg(feature = "clap")]
594impl RemoveGroupUserClapParams {
595 pub async fn execute(
596 self,
597 configuration: &configuration::Configuration,
598 ) -> Result<(), miette::Error> {
599 let request = self.remove_group_user_request.into_inner().into_inner();
600
601 remove_group_user(configuration, request)
602 .await
603 .into_diagnostic()
604 }
605}
606
607#[cfg(feature = "clap")]
609#[derive(Debug, clap::Args)]
610pub struct UpdateViewerUserProfileClapParams {
611 pub update_viewer_user_profile_request:
612 JsonMaybeStdin<crate::models::UpdateViewerUserProfileRequest>,
613}
614
615#[cfg(feature = "clap")]
616impl UpdateViewerUserProfileClapParams {
617 pub async fn execute(
618 self,
619 configuration: &configuration::Configuration,
620 ) -> Result<models::User, miette::Error> {
621 let request = self
622 .update_viewer_user_profile_request
623 .into_inner()
624 .into_inner();
625
626 update_viewer_user_profile(configuration, request)
627 .await
628 .into_diagnostic()
629 }
630}
631
632#[derive(Debug, Clone, Serialize, Deserialize)]
634#[serde(untagged)]
635pub enum ActivateUserError {
636 Status422(models::Error),
637 UnknownValue(serde_json::Value),
638}
639
640#[derive(Debug, Clone, Serialize, Deserialize)]
642#[serde(untagged)]
643pub enum AddGroupUserError {
644 Status404(models::Error),
645 Status422(models::Error),
646 UnknownValue(serde_json::Value),
647}
648
649#[derive(Debug, Clone, Serialize, Deserialize)]
651#[serde(untagged)]
652pub enum DismissViewerAnnouncementError {
653 Status401(models::Error),
654 Status404(models::Error),
655 UnknownValue(serde_json::Value),
656}
657
658#[derive(Debug, Clone, Serialize, Deserialize)]
660#[serde(untagged)]
661pub enum GetGroupBalanceError {
662 Status403(models::Error),
663 Status404(models::Error),
664 Status422(models::Error),
665 UnknownValue(serde_json::Value),
666}
667
668#[derive(Debug, Clone, Serialize, Deserialize)]
670#[serde(untagged)]
671pub enum GetGroupBillingCustomerError {
672 Status403(models::Error),
673 Status404(models::Error),
674 UnknownValue(serde_json::Value),
675}
676
677#[derive(Debug, Clone, Serialize, Deserialize)]
679#[serde(untagged)]
680pub enum GetGroupUpcomingBillingInvoiceError {
681 Status403(models::Error),
682 Status404(models::Error),
683 UnknownValue(serde_json::Value),
684}
685
686#[derive(Debug, Clone, Serialize, Deserialize)]
688#[serde(untagged)]
689pub enum GetUserBalanceError {
690 Status403(models::Error),
691 Status404(models::Error),
692 Status422(models::Error),
693 UnknownValue(serde_json::Value),
694}
695
696#[derive(Debug, Clone, Serialize, Deserialize)]
698#[serde(untagged)]
699pub enum GetUserBillingCustomerError {
700 Status403(models::Error),
701 Status404(models::Error),
702 UnknownValue(serde_json::Value),
703}
704
705#[derive(Debug, Clone, Serialize, Deserialize)]
707#[serde(untagged)]
708pub enum GetUserEventBillingPriceError {
709 Status403(models::Error),
710 Status404(models::Error),
711 Status422(models::Error),
712 UnknownValue(serde_json::Value),
713}
714
715#[derive(Debug, Clone, Serialize, Deserialize)]
717#[serde(untagged)]
718pub enum GetUserUpcomingBillingInvoiceError {
719 Status403(models::Error),
720 Status404(models::Error),
721 UnknownValue(serde_json::Value),
722}
723
724#[derive(Debug, Clone, Serialize, Deserialize)]
726#[serde(untagged)]
727pub enum GetViewerUserOnboardingCompletedError {
728 Status401(models::Error),
729 UnknownValue(serde_json::Value),
730}
731
732#[derive(Debug, Clone, Serialize, Deserialize)]
734#[serde(untagged)]
735pub enum ListGroupBillingInvoiceLinesError {
736 Status403(models::Error),
737 Status404(models::Error),
738 UnknownValue(serde_json::Value),
739}
740
741#[derive(Debug, Clone, Serialize, Deserialize)]
743#[serde(untagged)]
744pub enum ListGroupBillingInvoicesError {
745 Status403(models::Error),
746 Status404(models::Error),
747 UnknownValue(serde_json::Value),
748}
749
750#[derive(Debug, Clone, Serialize, Deserialize)]
752#[serde(untagged)]
753pub enum ListGroupUpcomingBillingInvoiceLinesError {
754 Status403(models::Error),
755 Status404(models::Error),
756 UnknownValue(serde_json::Value),
757}
758
759#[derive(Debug, Clone, Serialize, Deserialize)]
761#[serde(untagged)]
762pub enum ListGroupUsersError {
763 Status404(models::Error),
764 Status422(models::Error),
765 UnknownValue(serde_json::Value),
766}
767
768#[derive(Debug, Clone, Serialize, Deserialize)]
770#[serde(untagged)]
771pub enum ListUserBillingInvoiceLinesError {
772 Status403(models::Error),
773 Status404(models::Error),
774 UnknownValue(serde_json::Value),
775}
776
777#[derive(Debug, Clone, Serialize, Deserialize)]
779#[serde(untagged)]
780pub enum ListUserBillingInvoicesError {
781 Status403(models::Error),
782 Status404(models::Error),
783 UnknownValue(serde_json::Value),
784}
785
786#[derive(Debug, Clone, Serialize, Deserialize)]
788#[serde(untagged)]
789pub enum ListUserGroupsError {
790 Status422(models::Error),
791 UnknownValue(serde_json::Value),
792}
793
794#[derive(Debug, Clone, Serialize, Deserialize)]
796#[serde(untagged)]
797pub enum ListUserUpcomingBillingInvoiceLinesError {
798 Status403(models::Error),
799 Status404(models::Error),
800 UnknownValue(serde_json::Value),
801}
802
803#[derive(Debug, Clone, Serialize, Deserialize)]
805#[serde(untagged)]
806pub enum ListViewerAnnouncementsError {
807 Status401(models::Error),
808 Status422(models::Error),
809 UnknownValue(serde_json::Value),
810}
811
812#[derive(Debug, Clone, Serialize, Deserialize)]
814#[serde(untagged)]
815pub enum PutViewerUserOnboardingCompletedError {
816 Status401(models::Error),
817 UnknownValue(serde_json::Value),
818}
819
820#[derive(Debug, Clone, Serialize, Deserialize)]
822#[serde(untagged)]
823pub enum RemoveGroupUserError {
824 Status404(models::Error),
825 Status422(models::Error),
826 UnknownValue(serde_json::Value),
827}
828
829#[derive(Debug, Clone, Serialize, Deserialize)]
831#[serde(untagged)]
832pub enum UpdateViewerUserProfileError {
833 Status401(models::Error),
834 Status404(models::Error),
835 Status422(models::Error),
836 UnknownValue(serde_json::Value),
837}
838
839async fn activate_user_inner(
840 configuration: &configuration::Configuration,
841 backoff: &mut ExponentialBackoff,
842 activate_user_request: Option<crate::models::ActivateUserRequest>,
843) -> Result<models::User, Error<ActivateUserError>> {
844 let local_var_configuration = configuration;
845 let p_body_activate_user_request = activate_user_request;
847
848 let local_var_client = &local_var_configuration.client;
849
850 let local_var_uri_str = format!(
851 "{}/v1/users:activate",
852 local_var_configuration.qcs_config.api_url()
853 );
854 let mut local_var_req_builder =
855 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
856
857 #[cfg(feature = "tracing")]
858 {
859 let local_var_do_tracing = local_var_uri_str
862 .parse::<::url::Url>()
863 .ok()
864 .is_none_or(|url| {
865 configuration
866 .qcs_config
867 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
868 });
869
870 if local_var_do_tracing {
871 ::tracing::debug!(
872 url=%local_var_uri_str,
873 method="POST",
874 "making activate_user request",
875 );
876 }
877 }
878
879 {
882 use qcs_api_client_common::configuration::TokenError;
883
884 #[allow(
885 clippy::nonminimal_bool,
886 clippy::eq_op,
887 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
888 )]
889 let is_jwt_bearer_optional: bool = false;
890
891 let token = local_var_configuration
892 .qcs_config
893 .get_bearer_access_token()
894 .await;
895
896 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
897 #[cfg(feature = "tracing")]
899 tracing::debug!(
900 "No client credentials found, but this call does not require authentication."
901 );
902 } else {
903 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
904 }
905 }
906
907 local_var_req_builder = local_var_req_builder.json(&p_body_activate_user_request);
908
909 let local_var_req = local_var_req_builder.build()?;
910 let local_var_resp = local_var_client.execute(local_var_req).await?;
911
912 let local_var_status = local_var_resp.status();
913 let local_var_raw_content_type = local_var_resp
914 .headers()
915 .get("content-type")
916 .and_then(|v| v.to_str().ok())
917 .unwrap_or("application/octet-stream")
918 .to_string();
919 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
920
921 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
922 let local_var_content = local_var_resp.text().await?;
923 match local_var_content_type {
924 ContentType::Json => serde_path_to_error::deserialize(
925 &mut serde_json::Deserializer::from_str(&local_var_content),
926 )
927 .map_err(Error::from),
928 ContentType::Text => Err(Error::InvalidContentType {
929 content_type: local_var_raw_content_type,
930 return_type: "models::User",
931 }),
932 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
933 content_type: unknown_type,
934 return_type: "models::User",
935 }),
936 }
937 } else {
938 let local_var_retry_delay =
939 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
940 let local_var_content = local_var_resp.text().await?;
941 let local_var_entity: Option<ActivateUserError> =
942 serde_json::from_str(&local_var_content).ok();
943 let local_var_error = ResponseContent {
944 status: local_var_status,
945 content: local_var_content,
946 entity: local_var_entity,
947 retry_delay: local_var_retry_delay,
948 };
949 Err(Error::ResponseError(local_var_error))
950 }
951}
952
953pub async fn activate_user(
955 configuration: &configuration::Configuration,
956 activate_user_request: Option<crate::models::ActivateUserRequest>,
957) -> Result<models::User, Error<ActivateUserError>> {
958 let mut backoff = configuration.backoff.clone();
959 let mut refreshed_credentials = false;
960 let method = reqwest::Method::POST;
961 loop {
962 let result =
963 activate_user_inner(configuration, &mut backoff, activate_user_request.clone()).await;
964
965 match result {
966 Ok(result) => return Ok(result),
967 Err(Error::ResponseError(response)) => {
968 if !refreshed_credentials
969 && matches!(
970 response.status,
971 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
972 )
973 {
974 configuration.qcs_config.refresh().await?;
975 refreshed_credentials = true;
976 continue;
977 } else if let Some(duration) = response.retry_delay {
978 tokio::time::sleep(duration).await;
979 continue;
980 }
981
982 return Err(Error::ResponseError(response));
983 }
984 Err(Error::Reqwest(error)) => {
985 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
986 tokio::time::sleep(duration).await;
987 continue;
988 }
989
990 return Err(Error::Reqwest(error));
991 }
992 Err(Error::Io(error)) => {
993 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
994 tokio::time::sleep(duration).await;
995 continue;
996 }
997
998 return Err(Error::Io(error));
999 }
1000 Err(error) => return Err(error),
1001 }
1002 }
1003}
1004async fn add_group_user_inner(
1005 configuration: &configuration::Configuration,
1006 backoff: &mut ExponentialBackoff,
1007 add_group_user_request: crate::models::AddGroupUserRequest,
1008) -> Result<(), Error<AddGroupUserError>> {
1009 let local_var_configuration = configuration;
1010 let p_body_add_group_user_request = add_group_user_request;
1012
1013 let local_var_client = &local_var_configuration.client;
1014
1015 let local_var_uri_str = format!(
1016 "{}/v1/groups:addUser",
1017 local_var_configuration.qcs_config.api_url()
1018 );
1019 let mut local_var_req_builder =
1020 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1021
1022 #[cfg(feature = "tracing")]
1023 {
1024 let local_var_do_tracing = local_var_uri_str
1027 .parse::<::url::Url>()
1028 .ok()
1029 .is_none_or(|url| {
1030 configuration
1031 .qcs_config
1032 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
1033 });
1034
1035 if local_var_do_tracing {
1036 ::tracing::debug!(
1037 url=%local_var_uri_str,
1038 method="POST",
1039 "making add_group_user request",
1040 );
1041 }
1042 }
1043
1044 {
1047 use qcs_api_client_common::configuration::TokenError;
1048
1049 #[allow(
1050 clippy::nonminimal_bool,
1051 clippy::eq_op,
1052 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
1053 )]
1054 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
1055
1056 let token = local_var_configuration
1057 .qcs_config
1058 .get_bearer_access_token()
1059 .await;
1060
1061 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
1062 #[cfg(feature = "tracing")]
1064 tracing::debug!(
1065 "No client credentials found, but this call does not require authentication."
1066 );
1067 } else {
1068 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
1069 }
1070 }
1071
1072 local_var_req_builder = local_var_req_builder.json(&p_body_add_group_user_request);
1073
1074 let local_var_req = local_var_req_builder.build()?;
1075 let local_var_resp = local_var_client.execute(local_var_req).await?;
1076
1077 let local_var_status = local_var_resp.status();
1078
1079 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1080 Ok(())
1081 } else {
1082 let local_var_retry_delay =
1083 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
1084 let local_var_content = local_var_resp.text().await?;
1085 let local_var_entity: Option<AddGroupUserError> =
1086 serde_json::from_str(&local_var_content).ok();
1087 let local_var_error = ResponseContent {
1088 status: local_var_status,
1089 content: local_var_content,
1090 entity: local_var_entity,
1091 retry_delay: local_var_retry_delay,
1092 };
1093 Err(Error::ResponseError(local_var_error))
1094 }
1095}
1096
1097pub async fn add_group_user(
1099 configuration: &configuration::Configuration,
1100 add_group_user_request: crate::models::AddGroupUserRequest,
1101) -> Result<(), Error<AddGroupUserError>> {
1102 let mut backoff = configuration.backoff.clone();
1103 let mut refreshed_credentials = false;
1104 let method = reqwest::Method::POST;
1105 loop {
1106 let result =
1107 add_group_user_inner(configuration, &mut backoff, add_group_user_request.clone()).await;
1108
1109 match result {
1110 Ok(result) => return Ok(result),
1111 Err(Error::ResponseError(response)) => {
1112 if !refreshed_credentials
1113 && matches!(
1114 response.status,
1115 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
1116 )
1117 {
1118 configuration.qcs_config.refresh().await?;
1119 refreshed_credentials = true;
1120 continue;
1121 } else if let Some(duration) = response.retry_delay {
1122 tokio::time::sleep(duration).await;
1123 continue;
1124 }
1125
1126 return Err(Error::ResponseError(response));
1127 }
1128 Err(Error::Reqwest(error)) => {
1129 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
1130 tokio::time::sleep(duration).await;
1131 continue;
1132 }
1133
1134 return Err(Error::Reqwest(error));
1135 }
1136 Err(Error::Io(error)) => {
1137 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
1138 tokio::time::sleep(duration).await;
1139 continue;
1140 }
1141
1142 return Err(Error::Io(error));
1143 }
1144 Err(error) => return Err(error),
1145 }
1146 }
1147}
1148async fn dismiss_viewer_announcement_inner(
1149 configuration: &configuration::Configuration,
1150 backoff: &mut ExponentialBackoff,
1151 announcement_id: i64,
1152) -> Result<(), Error<DismissViewerAnnouncementError>> {
1153 let local_var_configuration = configuration;
1154 let p_path_announcement_id = announcement_id;
1156
1157 let local_var_client = &local_var_configuration.client;
1158
1159 let local_var_uri_str = format!(
1160 "{}/v1/viewer/announcements/{announcementId}",
1161 local_var_configuration.qcs_config.api_url(),
1162 announcementId = p_path_announcement_id
1163 );
1164 let mut local_var_req_builder =
1165 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
1166
1167 #[cfg(feature = "tracing")]
1168 {
1169 let local_var_do_tracing = local_var_uri_str
1172 .parse::<::url::Url>()
1173 .ok()
1174 .is_none_or(|url| {
1175 configuration
1176 .qcs_config
1177 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
1178 });
1179
1180 if local_var_do_tracing {
1181 ::tracing::debug!(
1182 url=%local_var_uri_str,
1183 method="DELETE",
1184 "making dismiss_viewer_announcement request",
1185 );
1186 }
1187 }
1188
1189 {
1192 use qcs_api_client_common::configuration::TokenError;
1193
1194 #[allow(
1195 clippy::nonminimal_bool,
1196 clippy::eq_op,
1197 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
1198 )]
1199 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
1200
1201 let token = local_var_configuration
1202 .qcs_config
1203 .get_bearer_access_token()
1204 .await;
1205
1206 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
1207 #[cfg(feature = "tracing")]
1209 tracing::debug!(
1210 "No client credentials found, but this call does not require authentication."
1211 );
1212 } else {
1213 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
1214 }
1215 }
1216
1217 let local_var_req = local_var_req_builder.build()?;
1218 let local_var_resp = local_var_client.execute(local_var_req).await?;
1219
1220 let local_var_status = local_var_resp.status();
1221
1222 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1223 Ok(())
1224 } else {
1225 let local_var_retry_delay =
1226 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
1227 let local_var_content = local_var_resp.text().await?;
1228 let local_var_entity: Option<DismissViewerAnnouncementError> =
1229 serde_json::from_str(&local_var_content).ok();
1230 let local_var_error = ResponseContent {
1231 status: local_var_status,
1232 content: local_var_content,
1233 entity: local_var_entity,
1234 retry_delay: local_var_retry_delay,
1235 };
1236 Err(Error::ResponseError(local_var_error))
1237 }
1238}
1239
1240pub async fn dismiss_viewer_announcement(
1242 configuration: &configuration::Configuration,
1243 announcement_id: i64,
1244) -> Result<(), Error<DismissViewerAnnouncementError>> {
1245 let mut backoff = configuration.backoff.clone();
1246 let mut refreshed_credentials = false;
1247 let method = reqwest::Method::DELETE;
1248 loop {
1249 let result =
1250 dismiss_viewer_announcement_inner(configuration, &mut backoff, announcement_id.clone())
1251 .await;
1252
1253 match result {
1254 Ok(result) => return Ok(result),
1255 Err(Error::ResponseError(response)) => {
1256 if !refreshed_credentials
1257 && matches!(
1258 response.status,
1259 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
1260 )
1261 {
1262 configuration.qcs_config.refresh().await?;
1263 refreshed_credentials = true;
1264 continue;
1265 } else if let Some(duration) = response.retry_delay {
1266 tokio::time::sleep(duration).await;
1267 continue;
1268 }
1269
1270 return Err(Error::ResponseError(response));
1271 }
1272 Err(Error::Reqwest(error)) => {
1273 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
1274 tokio::time::sleep(duration).await;
1275 continue;
1276 }
1277
1278 return Err(Error::Reqwest(error));
1279 }
1280 Err(Error::Io(error)) => {
1281 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
1282 tokio::time::sleep(duration).await;
1283 continue;
1284 }
1285
1286 return Err(Error::Io(error));
1287 }
1288 Err(error) => return Err(error),
1289 }
1290 }
1291}
1292async fn get_group_balance_inner(
1293 configuration: &configuration::Configuration,
1294 backoff: &mut ExponentialBackoff,
1295 group_name: &str,
1296) -> Result<models::AccountBalance, Error<GetGroupBalanceError>> {
1297 let local_var_configuration = configuration;
1298 let p_path_group_name = group_name;
1300
1301 let local_var_client = &local_var_configuration.client;
1302
1303 let local_var_uri_str = format!(
1304 "{}/v1/groups/{groupName}/balance",
1305 local_var_configuration.qcs_config.api_url(),
1306 groupName = crate::apis::urlencode(p_path_group_name)
1307 );
1308 let mut local_var_req_builder =
1309 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1310
1311 #[cfg(feature = "tracing")]
1312 {
1313 let local_var_do_tracing = local_var_uri_str
1316 .parse::<::url::Url>()
1317 .ok()
1318 .is_none_or(|url| {
1319 configuration
1320 .qcs_config
1321 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
1322 });
1323
1324 if local_var_do_tracing {
1325 ::tracing::debug!(
1326 url=%local_var_uri_str,
1327 method="GET",
1328 "making get_group_balance request",
1329 );
1330 }
1331 }
1332
1333 {
1336 use qcs_api_client_common::configuration::TokenError;
1337
1338 #[allow(
1339 clippy::nonminimal_bool,
1340 clippy::eq_op,
1341 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
1342 )]
1343 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
1344
1345 let token = local_var_configuration
1346 .qcs_config
1347 .get_bearer_access_token()
1348 .await;
1349
1350 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
1351 #[cfg(feature = "tracing")]
1353 tracing::debug!(
1354 "No client credentials found, but this call does not require authentication."
1355 );
1356 } else {
1357 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
1358 }
1359 }
1360
1361 let local_var_req = local_var_req_builder.build()?;
1362 let local_var_resp = local_var_client.execute(local_var_req).await?;
1363
1364 let local_var_status = local_var_resp.status();
1365 let local_var_raw_content_type = local_var_resp
1366 .headers()
1367 .get("content-type")
1368 .and_then(|v| v.to_str().ok())
1369 .unwrap_or("application/octet-stream")
1370 .to_string();
1371 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
1372
1373 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1374 let local_var_content = local_var_resp.text().await?;
1375 match local_var_content_type {
1376 ContentType::Json => serde_path_to_error::deserialize(
1377 &mut serde_json::Deserializer::from_str(&local_var_content),
1378 )
1379 .map_err(Error::from),
1380 ContentType::Text => Err(Error::InvalidContentType {
1381 content_type: local_var_raw_content_type,
1382 return_type: "models::AccountBalance",
1383 }),
1384 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
1385 content_type: unknown_type,
1386 return_type: "models::AccountBalance",
1387 }),
1388 }
1389 } else {
1390 let local_var_retry_delay =
1391 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
1392 let local_var_content = local_var_resp.text().await?;
1393 let local_var_entity: Option<GetGroupBalanceError> =
1394 serde_json::from_str(&local_var_content).ok();
1395 let local_var_error = ResponseContent {
1396 status: local_var_status,
1397 content: local_var_content,
1398 entity: local_var_entity,
1399 retry_delay: local_var_retry_delay,
1400 };
1401 Err(Error::ResponseError(local_var_error))
1402 }
1403}
1404
1405pub async fn get_group_balance(
1407 configuration: &configuration::Configuration,
1408 group_name: &str,
1409) -> Result<models::AccountBalance, Error<GetGroupBalanceError>> {
1410 let mut backoff = configuration.backoff.clone();
1411 let mut refreshed_credentials = false;
1412 let method = reqwest::Method::GET;
1413 loop {
1414 let result = get_group_balance_inner(configuration, &mut backoff, group_name.clone()).await;
1415
1416 match result {
1417 Ok(result) => return Ok(result),
1418 Err(Error::ResponseError(response)) => {
1419 if !refreshed_credentials
1420 && matches!(
1421 response.status,
1422 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
1423 )
1424 {
1425 configuration.qcs_config.refresh().await?;
1426 refreshed_credentials = true;
1427 continue;
1428 } else if let Some(duration) = response.retry_delay {
1429 tokio::time::sleep(duration).await;
1430 continue;
1431 }
1432
1433 return Err(Error::ResponseError(response));
1434 }
1435 Err(Error::Reqwest(error)) => {
1436 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
1437 tokio::time::sleep(duration).await;
1438 continue;
1439 }
1440
1441 return Err(Error::Reqwest(error));
1442 }
1443 Err(Error::Io(error)) => {
1444 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
1445 tokio::time::sleep(duration).await;
1446 continue;
1447 }
1448
1449 return Err(Error::Io(error));
1450 }
1451 Err(error) => return Err(error),
1452 }
1453 }
1454}
1455async fn get_group_billing_customer_inner(
1456 configuration: &configuration::Configuration,
1457 backoff: &mut ExponentialBackoff,
1458 group_name: &str,
1459) -> Result<models::BillingCustomer, Error<GetGroupBillingCustomerError>> {
1460 let local_var_configuration = configuration;
1461 let p_path_group_name = group_name;
1463
1464 let local_var_client = &local_var_configuration.client;
1465
1466 let local_var_uri_str = format!(
1467 "{}/v1/groups/{groupName}/billingCustomer",
1468 local_var_configuration.qcs_config.api_url(),
1469 groupName = crate::apis::urlencode(p_path_group_name)
1470 );
1471 let mut local_var_req_builder =
1472 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1473
1474 #[cfg(feature = "tracing")]
1475 {
1476 let local_var_do_tracing = local_var_uri_str
1479 .parse::<::url::Url>()
1480 .ok()
1481 .is_none_or(|url| {
1482 configuration
1483 .qcs_config
1484 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
1485 });
1486
1487 if local_var_do_tracing {
1488 ::tracing::debug!(
1489 url=%local_var_uri_str,
1490 method="GET",
1491 "making get_group_billing_customer request",
1492 );
1493 }
1494 }
1495
1496 {
1499 use qcs_api_client_common::configuration::TokenError;
1500
1501 #[allow(
1502 clippy::nonminimal_bool,
1503 clippy::eq_op,
1504 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
1505 )]
1506 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
1507
1508 let token = local_var_configuration
1509 .qcs_config
1510 .get_bearer_access_token()
1511 .await;
1512
1513 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
1514 #[cfg(feature = "tracing")]
1516 tracing::debug!(
1517 "No client credentials found, but this call does not require authentication."
1518 );
1519 } else {
1520 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
1521 }
1522 }
1523
1524 let local_var_req = local_var_req_builder.build()?;
1525 let local_var_resp = local_var_client.execute(local_var_req).await?;
1526
1527 let local_var_status = local_var_resp.status();
1528 let local_var_raw_content_type = local_var_resp
1529 .headers()
1530 .get("content-type")
1531 .and_then(|v| v.to_str().ok())
1532 .unwrap_or("application/octet-stream")
1533 .to_string();
1534 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
1535
1536 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1537 let local_var_content = local_var_resp.text().await?;
1538 match local_var_content_type {
1539 ContentType::Json => serde_path_to_error::deserialize(
1540 &mut serde_json::Deserializer::from_str(&local_var_content),
1541 )
1542 .map_err(Error::from),
1543 ContentType::Text => Err(Error::InvalidContentType {
1544 content_type: local_var_raw_content_type,
1545 return_type: "models::BillingCustomer",
1546 }),
1547 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
1548 content_type: unknown_type,
1549 return_type: "models::BillingCustomer",
1550 }),
1551 }
1552 } else {
1553 let local_var_retry_delay =
1554 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
1555 let local_var_content = local_var_resp.text().await?;
1556 let local_var_entity: Option<GetGroupBillingCustomerError> =
1557 serde_json::from_str(&local_var_content).ok();
1558 let local_var_error = ResponseContent {
1559 status: local_var_status,
1560 content: local_var_content,
1561 entity: local_var_entity,
1562 retry_delay: local_var_retry_delay,
1563 };
1564 Err(Error::ResponseError(local_var_error))
1565 }
1566}
1567
1568pub async fn get_group_billing_customer(
1570 configuration: &configuration::Configuration,
1571 group_name: &str,
1572) -> Result<models::BillingCustomer, Error<GetGroupBillingCustomerError>> {
1573 let mut backoff = configuration.backoff.clone();
1574 let mut refreshed_credentials = false;
1575 let method = reqwest::Method::GET;
1576 loop {
1577 let result =
1578 get_group_billing_customer_inner(configuration, &mut backoff, group_name.clone()).await;
1579
1580 match result {
1581 Ok(result) => return Ok(result),
1582 Err(Error::ResponseError(response)) => {
1583 if !refreshed_credentials
1584 && matches!(
1585 response.status,
1586 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
1587 )
1588 {
1589 configuration.qcs_config.refresh().await?;
1590 refreshed_credentials = true;
1591 continue;
1592 } else if let Some(duration) = response.retry_delay {
1593 tokio::time::sleep(duration).await;
1594 continue;
1595 }
1596
1597 return Err(Error::ResponseError(response));
1598 }
1599 Err(Error::Reqwest(error)) => {
1600 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
1601 tokio::time::sleep(duration).await;
1602 continue;
1603 }
1604
1605 return Err(Error::Reqwest(error));
1606 }
1607 Err(Error::Io(error)) => {
1608 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
1609 tokio::time::sleep(duration).await;
1610 continue;
1611 }
1612
1613 return Err(Error::Io(error));
1614 }
1615 Err(error) => return Err(error),
1616 }
1617 }
1618}
1619async fn get_group_upcoming_billing_invoice_inner(
1620 configuration: &configuration::Configuration,
1621 backoff: &mut ExponentialBackoff,
1622 group_name: &str,
1623) -> Result<models::BillingUpcomingInvoice, Error<GetGroupUpcomingBillingInvoiceError>> {
1624 let local_var_configuration = configuration;
1625 let p_path_group_name = group_name;
1627
1628 let local_var_client = &local_var_configuration.client;
1629
1630 let local_var_uri_str = format!(
1631 "{}/v1/groups/{groupName}/billingInvoices:getUpcoming",
1632 local_var_configuration.qcs_config.api_url(),
1633 groupName = crate::apis::urlencode(p_path_group_name)
1634 );
1635 let mut local_var_req_builder =
1636 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1637
1638 #[cfg(feature = "tracing")]
1639 {
1640 let local_var_do_tracing = local_var_uri_str
1643 .parse::<::url::Url>()
1644 .ok()
1645 .is_none_or(|url| {
1646 configuration
1647 .qcs_config
1648 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
1649 });
1650
1651 if local_var_do_tracing {
1652 ::tracing::debug!(
1653 url=%local_var_uri_str,
1654 method="GET",
1655 "making get_group_upcoming_billing_invoice request",
1656 );
1657 }
1658 }
1659
1660 {
1663 use qcs_api_client_common::configuration::TokenError;
1664
1665 #[allow(
1666 clippy::nonminimal_bool,
1667 clippy::eq_op,
1668 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
1669 )]
1670 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
1671
1672 let token = local_var_configuration
1673 .qcs_config
1674 .get_bearer_access_token()
1675 .await;
1676
1677 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
1678 #[cfg(feature = "tracing")]
1680 tracing::debug!(
1681 "No client credentials found, but this call does not require authentication."
1682 );
1683 } else {
1684 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
1685 }
1686 }
1687
1688 let local_var_req = local_var_req_builder.build()?;
1689 let local_var_resp = local_var_client.execute(local_var_req).await?;
1690
1691 let local_var_status = local_var_resp.status();
1692 let local_var_raw_content_type = local_var_resp
1693 .headers()
1694 .get("content-type")
1695 .and_then(|v| v.to_str().ok())
1696 .unwrap_or("application/octet-stream")
1697 .to_string();
1698 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
1699
1700 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1701 let local_var_content = local_var_resp.text().await?;
1702 match local_var_content_type {
1703 ContentType::Json => serde_path_to_error::deserialize(
1704 &mut serde_json::Deserializer::from_str(&local_var_content),
1705 )
1706 .map_err(Error::from),
1707 ContentType::Text => Err(Error::InvalidContentType {
1708 content_type: local_var_raw_content_type,
1709 return_type: "models::BillingUpcomingInvoice",
1710 }),
1711 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
1712 content_type: unknown_type,
1713 return_type: "models::BillingUpcomingInvoice",
1714 }),
1715 }
1716 } else {
1717 let local_var_retry_delay =
1718 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
1719 let local_var_content = local_var_resp.text().await?;
1720 let local_var_entity: Option<GetGroupUpcomingBillingInvoiceError> =
1721 serde_json::from_str(&local_var_content).ok();
1722 let local_var_error = ResponseContent {
1723 status: local_var_status,
1724 content: local_var_content,
1725 entity: local_var_entity,
1726 retry_delay: local_var_retry_delay,
1727 };
1728 Err(Error::ResponseError(local_var_error))
1729 }
1730}
1731
1732pub async fn get_group_upcoming_billing_invoice(
1734 configuration: &configuration::Configuration,
1735 group_name: &str,
1736) -> Result<models::BillingUpcomingInvoice, Error<GetGroupUpcomingBillingInvoiceError>> {
1737 let mut backoff = configuration.backoff.clone();
1738 let mut refreshed_credentials = false;
1739 let method = reqwest::Method::GET;
1740 loop {
1741 let result = get_group_upcoming_billing_invoice_inner(
1742 configuration,
1743 &mut backoff,
1744 group_name.clone(),
1745 )
1746 .await;
1747
1748 match result {
1749 Ok(result) => return Ok(result),
1750 Err(Error::ResponseError(response)) => {
1751 if !refreshed_credentials
1752 && matches!(
1753 response.status,
1754 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
1755 )
1756 {
1757 configuration.qcs_config.refresh().await?;
1758 refreshed_credentials = true;
1759 continue;
1760 } else if let Some(duration) = response.retry_delay {
1761 tokio::time::sleep(duration).await;
1762 continue;
1763 }
1764
1765 return Err(Error::ResponseError(response));
1766 }
1767 Err(Error::Reqwest(error)) => {
1768 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
1769 tokio::time::sleep(duration).await;
1770 continue;
1771 }
1772
1773 return Err(Error::Reqwest(error));
1774 }
1775 Err(Error::Io(error)) => {
1776 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
1777 tokio::time::sleep(duration).await;
1778 continue;
1779 }
1780
1781 return Err(Error::Io(error));
1782 }
1783 Err(error) => return Err(error),
1784 }
1785 }
1786}
1787async fn get_user_balance_inner(
1788 configuration: &configuration::Configuration,
1789 backoff: &mut ExponentialBackoff,
1790 user_id: &str,
1791) -> Result<models::AccountBalance, Error<GetUserBalanceError>> {
1792 let local_var_configuration = configuration;
1793 let p_path_user_id = user_id;
1795
1796 let local_var_client = &local_var_configuration.client;
1797
1798 let local_var_uri_str = format!(
1799 "{}/v1/users/{userId}/balance",
1800 local_var_configuration.qcs_config.api_url(),
1801 userId = crate::apis::urlencode(p_path_user_id)
1802 );
1803 let mut local_var_req_builder =
1804 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1805
1806 #[cfg(feature = "tracing")]
1807 {
1808 let local_var_do_tracing = local_var_uri_str
1811 .parse::<::url::Url>()
1812 .ok()
1813 .is_none_or(|url| {
1814 configuration
1815 .qcs_config
1816 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
1817 });
1818
1819 if local_var_do_tracing {
1820 ::tracing::debug!(
1821 url=%local_var_uri_str,
1822 method="GET",
1823 "making get_user_balance request",
1824 );
1825 }
1826 }
1827
1828 {
1831 use qcs_api_client_common::configuration::TokenError;
1832
1833 #[allow(
1834 clippy::nonminimal_bool,
1835 clippy::eq_op,
1836 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
1837 )]
1838 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
1839
1840 let token = local_var_configuration
1841 .qcs_config
1842 .get_bearer_access_token()
1843 .await;
1844
1845 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
1846 #[cfg(feature = "tracing")]
1848 tracing::debug!(
1849 "No client credentials found, but this call does not require authentication."
1850 );
1851 } else {
1852 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
1853 }
1854 }
1855
1856 let local_var_req = local_var_req_builder.build()?;
1857 let local_var_resp = local_var_client.execute(local_var_req).await?;
1858
1859 let local_var_status = local_var_resp.status();
1860 let local_var_raw_content_type = local_var_resp
1861 .headers()
1862 .get("content-type")
1863 .and_then(|v| v.to_str().ok())
1864 .unwrap_or("application/octet-stream")
1865 .to_string();
1866 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
1867
1868 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1869 let local_var_content = local_var_resp.text().await?;
1870 match local_var_content_type {
1871 ContentType::Json => serde_path_to_error::deserialize(
1872 &mut serde_json::Deserializer::from_str(&local_var_content),
1873 )
1874 .map_err(Error::from),
1875 ContentType::Text => Err(Error::InvalidContentType {
1876 content_type: local_var_raw_content_type,
1877 return_type: "models::AccountBalance",
1878 }),
1879 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
1880 content_type: unknown_type,
1881 return_type: "models::AccountBalance",
1882 }),
1883 }
1884 } else {
1885 let local_var_retry_delay =
1886 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
1887 let local_var_content = local_var_resp.text().await?;
1888 let local_var_entity: Option<GetUserBalanceError> =
1889 serde_json::from_str(&local_var_content).ok();
1890 let local_var_error = ResponseContent {
1891 status: local_var_status,
1892 content: local_var_content,
1893 entity: local_var_entity,
1894 retry_delay: local_var_retry_delay,
1895 };
1896 Err(Error::ResponseError(local_var_error))
1897 }
1898}
1899
1900pub async fn get_user_balance(
1902 configuration: &configuration::Configuration,
1903 user_id: &str,
1904) -> Result<models::AccountBalance, Error<GetUserBalanceError>> {
1905 let mut backoff = configuration.backoff.clone();
1906 let mut refreshed_credentials = false;
1907 let method = reqwest::Method::GET;
1908 loop {
1909 let result = get_user_balance_inner(configuration, &mut backoff, user_id.clone()).await;
1910
1911 match result {
1912 Ok(result) => return Ok(result),
1913 Err(Error::ResponseError(response)) => {
1914 if !refreshed_credentials
1915 && matches!(
1916 response.status,
1917 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
1918 )
1919 {
1920 configuration.qcs_config.refresh().await?;
1921 refreshed_credentials = true;
1922 continue;
1923 } else if let Some(duration) = response.retry_delay {
1924 tokio::time::sleep(duration).await;
1925 continue;
1926 }
1927
1928 return Err(Error::ResponseError(response));
1929 }
1930 Err(Error::Reqwest(error)) => {
1931 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
1932 tokio::time::sleep(duration).await;
1933 continue;
1934 }
1935
1936 return Err(Error::Reqwest(error));
1937 }
1938 Err(Error::Io(error)) => {
1939 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
1940 tokio::time::sleep(duration).await;
1941 continue;
1942 }
1943
1944 return Err(Error::Io(error));
1945 }
1946 Err(error) => return Err(error),
1947 }
1948 }
1949}
1950async fn get_user_billing_customer_inner(
1951 configuration: &configuration::Configuration,
1952 backoff: &mut ExponentialBackoff,
1953 user_id: &str,
1954) -> Result<models::BillingCustomer, Error<GetUserBillingCustomerError>> {
1955 let local_var_configuration = configuration;
1956 let p_path_user_id = user_id;
1958
1959 let local_var_client = &local_var_configuration.client;
1960
1961 let local_var_uri_str = format!(
1962 "{}/v1/users/{userId}/billingCustomer",
1963 local_var_configuration.qcs_config.api_url(),
1964 userId = crate::apis::urlencode(p_path_user_id)
1965 );
1966 let mut local_var_req_builder =
1967 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1968
1969 #[cfg(feature = "tracing")]
1970 {
1971 let local_var_do_tracing = local_var_uri_str
1974 .parse::<::url::Url>()
1975 .ok()
1976 .is_none_or(|url| {
1977 configuration
1978 .qcs_config
1979 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
1980 });
1981
1982 if local_var_do_tracing {
1983 ::tracing::debug!(
1984 url=%local_var_uri_str,
1985 method="GET",
1986 "making get_user_billing_customer request",
1987 );
1988 }
1989 }
1990
1991 {
1994 use qcs_api_client_common::configuration::TokenError;
1995
1996 #[allow(
1997 clippy::nonminimal_bool,
1998 clippy::eq_op,
1999 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
2000 )]
2001 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
2002
2003 let token = local_var_configuration
2004 .qcs_config
2005 .get_bearer_access_token()
2006 .await;
2007
2008 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
2009 #[cfg(feature = "tracing")]
2011 tracing::debug!(
2012 "No client credentials found, but this call does not require authentication."
2013 );
2014 } else {
2015 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
2016 }
2017 }
2018
2019 let local_var_req = local_var_req_builder.build()?;
2020 let local_var_resp = local_var_client.execute(local_var_req).await?;
2021
2022 let local_var_status = local_var_resp.status();
2023 let local_var_raw_content_type = local_var_resp
2024 .headers()
2025 .get("content-type")
2026 .and_then(|v| v.to_str().ok())
2027 .unwrap_or("application/octet-stream")
2028 .to_string();
2029 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
2030
2031 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2032 let local_var_content = local_var_resp.text().await?;
2033 match local_var_content_type {
2034 ContentType::Json => serde_path_to_error::deserialize(
2035 &mut serde_json::Deserializer::from_str(&local_var_content),
2036 )
2037 .map_err(Error::from),
2038 ContentType::Text => Err(Error::InvalidContentType {
2039 content_type: local_var_raw_content_type,
2040 return_type: "models::BillingCustomer",
2041 }),
2042 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
2043 content_type: unknown_type,
2044 return_type: "models::BillingCustomer",
2045 }),
2046 }
2047 } else {
2048 let local_var_retry_delay =
2049 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
2050 let local_var_content = local_var_resp.text().await?;
2051 let local_var_entity: Option<GetUserBillingCustomerError> =
2052 serde_json::from_str(&local_var_content).ok();
2053 let local_var_error = ResponseContent {
2054 status: local_var_status,
2055 content: local_var_content,
2056 entity: local_var_entity,
2057 retry_delay: local_var_retry_delay,
2058 };
2059 Err(Error::ResponseError(local_var_error))
2060 }
2061}
2062
2063pub async fn get_user_billing_customer(
2065 configuration: &configuration::Configuration,
2066 user_id: &str,
2067) -> Result<models::BillingCustomer, Error<GetUserBillingCustomerError>> {
2068 let mut backoff = configuration.backoff.clone();
2069 let mut refreshed_credentials = false;
2070 let method = reqwest::Method::GET;
2071 loop {
2072 let result =
2073 get_user_billing_customer_inner(configuration, &mut backoff, user_id.clone()).await;
2074
2075 match result {
2076 Ok(result) => return Ok(result),
2077 Err(Error::ResponseError(response)) => {
2078 if !refreshed_credentials
2079 && matches!(
2080 response.status,
2081 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
2082 )
2083 {
2084 configuration.qcs_config.refresh().await?;
2085 refreshed_credentials = true;
2086 continue;
2087 } else if let Some(duration) = response.retry_delay {
2088 tokio::time::sleep(duration).await;
2089 continue;
2090 }
2091
2092 return Err(Error::ResponseError(response));
2093 }
2094 Err(Error::Reqwest(error)) => {
2095 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
2096 tokio::time::sleep(duration).await;
2097 continue;
2098 }
2099
2100 return Err(Error::Reqwest(error));
2101 }
2102 Err(Error::Io(error)) => {
2103 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
2104 tokio::time::sleep(duration).await;
2105 continue;
2106 }
2107
2108 return Err(Error::Io(error));
2109 }
2110 Err(error) => return Err(error),
2111 }
2112 }
2113}
2114async fn get_user_event_billing_price_inner(
2115 configuration: &configuration::Configuration,
2116 backoff: &mut ExponentialBackoff,
2117 user_id: &str,
2118 get_account_event_billing_price_request: crate::models::GetAccountEventBillingPriceRequest,
2119) -> Result<models::EventBillingPriceRate, Error<GetUserEventBillingPriceError>> {
2120 let local_var_configuration = configuration;
2121 let p_path_user_id = user_id;
2123 let p_body_get_account_event_billing_price_request = get_account_event_billing_price_request;
2124
2125 let local_var_client = &local_var_configuration.client;
2126
2127 let local_var_uri_str = format!(
2128 "{}/v1/users/{userId}/eventBillingPrices:get",
2129 local_var_configuration.qcs_config.api_url(),
2130 userId = crate::apis::urlencode(p_path_user_id)
2131 );
2132 let mut local_var_req_builder =
2133 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2134
2135 #[cfg(feature = "tracing")]
2136 {
2137 let local_var_do_tracing = local_var_uri_str
2140 .parse::<::url::Url>()
2141 .ok()
2142 .is_none_or(|url| {
2143 configuration
2144 .qcs_config
2145 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
2146 });
2147
2148 if local_var_do_tracing {
2149 ::tracing::debug!(
2150 url=%local_var_uri_str,
2151 method="POST",
2152 "making get_user_event_billing_price request",
2153 );
2154 }
2155 }
2156
2157 {
2160 use qcs_api_client_common::configuration::TokenError;
2161
2162 #[allow(
2163 clippy::nonminimal_bool,
2164 clippy::eq_op,
2165 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
2166 )]
2167 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
2168
2169 let token = local_var_configuration
2170 .qcs_config
2171 .get_bearer_access_token()
2172 .await;
2173
2174 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
2175 #[cfg(feature = "tracing")]
2177 tracing::debug!(
2178 "No client credentials found, but this call does not require authentication."
2179 );
2180 } else {
2181 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
2182 }
2183 }
2184
2185 local_var_req_builder =
2186 local_var_req_builder.json(&p_body_get_account_event_billing_price_request);
2187
2188 let local_var_req = local_var_req_builder.build()?;
2189 let local_var_resp = local_var_client.execute(local_var_req).await?;
2190
2191 let local_var_status = local_var_resp.status();
2192 let local_var_raw_content_type = local_var_resp
2193 .headers()
2194 .get("content-type")
2195 .and_then(|v| v.to_str().ok())
2196 .unwrap_or("application/octet-stream")
2197 .to_string();
2198 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
2199
2200 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2201 let local_var_content = local_var_resp.text().await?;
2202 match local_var_content_type {
2203 ContentType::Json => serde_path_to_error::deserialize(
2204 &mut serde_json::Deserializer::from_str(&local_var_content),
2205 )
2206 .map_err(Error::from),
2207 ContentType::Text => Err(Error::InvalidContentType {
2208 content_type: local_var_raw_content_type,
2209 return_type: "models::EventBillingPriceRate",
2210 }),
2211 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
2212 content_type: unknown_type,
2213 return_type: "models::EventBillingPriceRate",
2214 }),
2215 }
2216 } else {
2217 let local_var_retry_delay =
2218 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
2219 let local_var_content = local_var_resp.text().await?;
2220 let local_var_entity: Option<GetUserEventBillingPriceError> =
2221 serde_json::from_str(&local_var_content).ok();
2222 let local_var_error = ResponseContent {
2223 status: local_var_status,
2224 content: local_var_content,
2225 entity: local_var_entity,
2226 retry_delay: local_var_retry_delay,
2227 };
2228 Err(Error::ResponseError(local_var_error))
2229 }
2230}
2231
2232pub async fn get_user_event_billing_price(
2234 configuration: &configuration::Configuration,
2235 user_id: &str,
2236 get_account_event_billing_price_request: crate::models::GetAccountEventBillingPriceRequest,
2237) -> Result<models::EventBillingPriceRate, Error<GetUserEventBillingPriceError>> {
2238 let mut backoff = configuration.backoff.clone();
2239 let mut refreshed_credentials = false;
2240 let method = reqwest::Method::POST;
2241 loop {
2242 let result = get_user_event_billing_price_inner(
2243 configuration,
2244 &mut backoff,
2245 user_id.clone(),
2246 get_account_event_billing_price_request.clone(),
2247 )
2248 .await;
2249
2250 match result {
2251 Ok(result) => return Ok(result),
2252 Err(Error::ResponseError(response)) => {
2253 if !refreshed_credentials
2254 && matches!(
2255 response.status,
2256 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
2257 )
2258 {
2259 configuration.qcs_config.refresh().await?;
2260 refreshed_credentials = true;
2261 continue;
2262 } else if let Some(duration) = response.retry_delay {
2263 tokio::time::sleep(duration).await;
2264 continue;
2265 }
2266
2267 return Err(Error::ResponseError(response));
2268 }
2269 Err(Error::Reqwest(error)) => {
2270 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
2271 tokio::time::sleep(duration).await;
2272 continue;
2273 }
2274
2275 return Err(Error::Reqwest(error));
2276 }
2277 Err(Error::Io(error)) => {
2278 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
2279 tokio::time::sleep(duration).await;
2280 continue;
2281 }
2282
2283 return Err(Error::Io(error));
2284 }
2285 Err(error) => return Err(error),
2286 }
2287 }
2288}
2289async fn get_user_upcoming_billing_invoice_inner(
2290 configuration: &configuration::Configuration,
2291 backoff: &mut ExponentialBackoff,
2292 user_id: &str,
2293) -> Result<models::BillingUpcomingInvoice, Error<GetUserUpcomingBillingInvoiceError>> {
2294 let local_var_configuration = configuration;
2295 let p_path_user_id = user_id;
2297
2298 let local_var_client = &local_var_configuration.client;
2299
2300 let local_var_uri_str = format!(
2301 "{}/v1/users/{userId}/billingInvoices:getUpcoming",
2302 local_var_configuration.qcs_config.api_url(),
2303 userId = crate::apis::urlencode(p_path_user_id)
2304 );
2305 let mut local_var_req_builder =
2306 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
2307
2308 #[cfg(feature = "tracing")]
2309 {
2310 let local_var_do_tracing = local_var_uri_str
2313 .parse::<::url::Url>()
2314 .ok()
2315 .is_none_or(|url| {
2316 configuration
2317 .qcs_config
2318 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
2319 });
2320
2321 if local_var_do_tracing {
2322 ::tracing::debug!(
2323 url=%local_var_uri_str,
2324 method="GET",
2325 "making get_user_upcoming_billing_invoice request",
2326 );
2327 }
2328 }
2329
2330 {
2333 use qcs_api_client_common::configuration::TokenError;
2334
2335 #[allow(
2336 clippy::nonminimal_bool,
2337 clippy::eq_op,
2338 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
2339 )]
2340 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
2341
2342 let token = local_var_configuration
2343 .qcs_config
2344 .get_bearer_access_token()
2345 .await;
2346
2347 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
2348 #[cfg(feature = "tracing")]
2350 tracing::debug!(
2351 "No client credentials found, but this call does not require authentication."
2352 );
2353 } else {
2354 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
2355 }
2356 }
2357
2358 let local_var_req = local_var_req_builder.build()?;
2359 let local_var_resp = local_var_client.execute(local_var_req).await?;
2360
2361 let local_var_status = local_var_resp.status();
2362 let local_var_raw_content_type = local_var_resp
2363 .headers()
2364 .get("content-type")
2365 .and_then(|v| v.to_str().ok())
2366 .unwrap_or("application/octet-stream")
2367 .to_string();
2368 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
2369
2370 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2371 let local_var_content = local_var_resp.text().await?;
2372 match local_var_content_type {
2373 ContentType::Json => serde_path_to_error::deserialize(
2374 &mut serde_json::Deserializer::from_str(&local_var_content),
2375 )
2376 .map_err(Error::from),
2377 ContentType::Text => Err(Error::InvalidContentType {
2378 content_type: local_var_raw_content_type,
2379 return_type: "models::BillingUpcomingInvoice",
2380 }),
2381 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
2382 content_type: unknown_type,
2383 return_type: "models::BillingUpcomingInvoice",
2384 }),
2385 }
2386 } else {
2387 let local_var_retry_delay =
2388 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
2389 let local_var_content = local_var_resp.text().await?;
2390 let local_var_entity: Option<GetUserUpcomingBillingInvoiceError> =
2391 serde_json::from_str(&local_var_content).ok();
2392 let local_var_error = ResponseContent {
2393 status: local_var_status,
2394 content: local_var_content,
2395 entity: local_var_entity,
2396 retry_delay: local_var_retry_delay,
2397 };
2398 Err(Error::ResponseError(local_var_error))
2399 }
2400}
2401
2402pub async fn get_user_upcoming_billing_invoice(
2404 configuration: &configuration::Configuration,
2405 user_id: &str,
2406) -> Result<models::BillingUpcomingInvoice, Error<GetUserUpcomingBillingInvoiceError>> {
2407 let mut backoff = configuration.backoff.clone();
2408 let mut refreshed_credentials = false;
2409 let method = reqwest::Method::GET;
2410 loop {
2411 let result =
2412 get_user_upcoming_billing_invoice_inner(configuration, &mut backoff, user_id.clone())
2413 .await;
2414
2415 match result {
2416 Ok(result) => return Ok(result),
2417 Err(Error::ResponseError(response)) => {
2418 if !refreshed_credentials
2419 && matches!(
2420 response.status,
2421 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
2422 )
2423 {
2424 configuration.qcs_config.refresh().await?;
2425 refreshed_credentials = true;
2426 continue;
2427 } else if let Some(duration) = response.retry_delay {
2428 tokio::time::sleep(duration).await;
2429 continue;
2430 }
2431
2432 return Err(Error::ResponseError(response));
2433 }
2434 Err(Error::Reqwest(error)) => {
2435 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
2436 tokio::time::sleep(duration).await;
2437 continue;
2438 }
2439
2440 return Err(Error::Reqwest(error));
2441 }
2442 Err(Error::Io(error)) => {
2443 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
2444 tokio::time::sleep(duration).await;
2445 continue;
2446 }
2447
2448 return Err(Error::Io(error));
2449 }
2450 Err(error) => return Err(error),
2451 }
2452 }
2453}
2454async fn get_viewer_user_onboarding_completed_inner(
2455 configuration: &configuration::Configuration,
2456 backoff: &mut ExponentialBackoff,
2457) -> Result<models::ViewerUserOnboardingCompleted, Error<GetViewerUserOnboardingCompletedError>> {
2458 let local_var_configuration = configuration;
2459
2460 let local_var_client = &local_var_configuration.client;
2461
2462 let local_var_uri_str = format!(
2463 "{}/v1/viewer/onboardingCompleted",
2464 local_var_configuration.qcs_config.api_url()
2465 );
2466 let mut local_var_req_builder =
2467 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
2468
2469 #[cfg(feature = "tracing")]
2470 {
2471 let local_var_do_tracing = local_var_uri_str
2474 .parse::<::url::Url>()
2475 .ok()
2476 .is_none_or(|url| {
2477 configuration
2478 .qcs_config
2479 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
2480 });
2481
2482 if local_var_do_tracing {
2483 ::tracing::debug!(
2484 url=%local_var_uri_str,
2485 method="GET",
2486 "making get_viewer_user_onboarding_completed request",
2487 );
2488 }
2489 }
2490
2491 {
2494 use qcs_api_client_common::configuration::TokenError;
2495
2496 #[allow(
2497 clippy::nonminimal_bool,
2498 clippy::eq_op,
2499 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
2500 )]
2501 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
2502
2503 let token = local_var_configuration
2504 .qcs_config
2505 .get_bearer_access_token()
2506 .await;
2507
2508 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
2509 #[cfg(feature = "tracing")]
2511 tracing::debug!(
2512 "No client credentials found, but this call does not require authentication."
2513 );
2514 } else {
2515 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
2516 }
2517 }
2518
2519 let local_var_req = local_var_req_builder.build()?;
2520 let local_var_resp = local_var_client.execute(local_var_req).await?;
2521
2522 let local_var_status = local_var_resp.status();
2523 let local_var_raw_content_type = local_var_resp
2524 .headers()
2525 .get("content-type")
2526 .and_then(|v| v.to_str().ok())
2527 .unwrap_or("application/octet-stream")
2528 .to_string();
2529 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
2530
2531 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2532 let local_var_content = local_var_resp.text().await?;
2533 match local_var_content_type {
2534 ContentType::Json => serde_path_to_error::deserialize(
2535 &mut serde_json::Deserializer::from_str(&local_var_content),
2536 )
2537 .map_err(Error::from),
2538 ContentType::Text => Err(Error::InvalidContentType {
2539 content_type: local_var_raw_content_type,
2540 return_type: "models::ViewerUserOnboardingCompleted",
2541 }),
2542 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
2543 content_type: unknown_type,
2544 return_type: "models::ViewerUserOnboardingCompleted",
2545 }),
2546 }
2547 } else {
2548 let local_var_retry_delay =
2549 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
2550 let local_var_content = local_var_resp.text().await?;
2551 let local_var_entity: Option<GetViewerUserOnboardingCompletedError> =
2552 serde_json::from_str(&local_var_content).ok();
2553 let local_var_error = ResponseContent {
2554 status: local_var_status,
2555 content: local_var_content,
2556 entity: local_var_entity,
2557 retry_delay: local_var_retry_delay,
2558 };
2559 Err(Error::ResponseError(local_var_error))
2560 }
2561}
2562
2563pub async fn get_viewer_user_onboarding_completed(
2565 configuration: &configuration::Configuration,
2566) -> Result<models::ViewerUserOnboardingCompleted, Error<GetViewerUserOnboardingCompletedError>> {
2567 let mut backoff = configuration.backoff.clone();
2568 let mut refreshed_credentials = false;
2569 let method = reqwest::Method::GET;
2570 loop {
2571 let result = get_viewer_user_onboarding_completed_inner(configuration, &mut backoff).await;
2572
2573 match result {
2574 Ok(result) => return Ok(result),
2575 Err(Error::ResponseError(response)) => {
2576 if !refreshed_credentials
2577 && matches!(
2578 response.status,
2579 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
2580 )
2581 {
2582 configuration.qcs_config.refresh().await?;
2583 refreshed_credentials = true;
2584 continue;
2585 } else if let Some(duration) = response.retry_delay {
2586 tokio::time::sleep(duration).await;
2587 continue;
2588 }
2589
2590 return Err(Error::ResponseError(response));
2591 }
2592 Err(Error::Reqwest(error)) => {
2593 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
2594 tokio::time::sleep(duration).await;
2595 continue;
2596 }
2597
2598 return Err(Error::Reqwest(error));
2599 }
2600 Err(Error::Io(error)) => {
2601 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
2602 tokio::time::sleep(duration).await;
2603 continue;
2604 }
2605
2606 return Err(Error::Io(error));
2607 }
2608 Err(error) => return Err(error),
2609 }
2610 }
2611}
2612async fn list_group_billing_invoice_lines_inner(
2613 configuration: &configuration::Configuration,
2614 backoff: &mut ExponentialBackoff,
2615 group_name: &str,
2616 billing_invoice_id: &str,
2617 page_token: Option<&str>,
2618 page_size: Option<i64>,
2619) -> Result<models::ListAccountBillingInvoiceLinesResponse, Error<ListGroupBillingInvoiceLinesError>>
2620{
2621 let local_var_configuration = configuration;
2622 let p_path_group_name = group_name;
2624 let p_path_billing_invoice_id = billing_invoice_id;
2625 let p_query_page_token = page_token;
2626 let p_query_page_size = page_size;
2627
2628 let local_var_client = &local_var_configuration.client;
2629
2630 let local_var_uri_str = format!(
2631 "{}/v1/groups/{groupName}/billingInvoices/{billingInvoiceId}/lines",
2632 local_var_configuration.qcs_config.api_url(),
2633 groupName = crate::apis::urlencode(p_path_group_name),
2634 billingInvoiceId = crate::apis::urlencode(p_path_billing_invoice_id)
2635 );
2636 let mut local_var_req_builder =
2637 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
2638
2639 #[cfg(feature = "tracing")]
2640 {
2641 let local_var_do_tracing = local_var_uri_str
2644 .parse::<::url::Url>()
2645 .ok()
2646 .is_none_or(|url| {
2647 configuration
2648 .qcs_config
2649 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
2650 });
2651
2652 if local_var_do_tracing {
2653 ::tracing::debug!(
2654 url=%local_var_uri_str,
2655 method="GET",
2656 "making list_group_billing_invoice_lines request",
2657 );
2658 }
2659 }
2660
2661 if let Some(ref local_var_str) = p_query_page_token {
2662 local_var_req_builder =
2663 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
2664 }
2665 if let Some(ref local_var_str) = p_query_page_size {
2666 local_var_req_builder =
2667 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
2668 }
2669
2670 {
2673 use qcs_api_client_common::configuration::TokenError;
2674
2675 #[allow(
2676 clippy::nonminimal_bool,
2677 clippy::eq_op,
2678 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
2679 )]
2680 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
2681
2682 let token = local_var_configuration
2683 .qcs_config
2684 .get_bearer_access_token()
2685 .await;
2686
2687 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
2688 #[cfg(feature = "tracing")]
2690 tracing::debug!(
2691 "No client credentials found, but this call does not require authentication."
2692 );
2693 } else {
2694 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
2695 }
2696 }
2697
2698 let local_var_req = local_var_req_builder.build()?;
2699 let local_var_resp = local_var_client.execute(local_var_req).await?;
2700
2701 let local_var_status = local_var_resp.status();
2702 let local_var_raw_content_type = local_var_resp
2703 .headers()
2704 .get("content-type")
2705 .and_then(|v| v.to_str().ok())
2706 .unwrap_or("application/octet-stream")
2707 .to_string();
2708 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
2709
2710 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2711 let local_var_content = local_var_resp.text().await?;
2712 match local_var_content_type {
2713 ContentType::Json => serde_path_to_error::deserialize(
2714 &mut serde_json::Deserializer::from_str(&local_var_content),
2715 )
2716 .map_err(Error::from),
2717 ContentType::Text => Err(Error::InvalidContentType {
2718 content_type: local_var_raw_content_type,
2719 return_type: "models::ListAccountBillingInvoiceLinesResponse",
2720 }),
2721 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
2722 content_type: unknown_type,
2723 return_type: "models::ListAccountBillingInvoiceLinesResponse",
2724 }),
2725 }
2726 } else {
2727 let local_var_retry_delay =
2728 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
2729 let local_var_content = local_var_resp.text().await?;
2730 let local_var_entity: Option<ListGroupBillingInvoiceLinesError> =
2731 serde_json::from_str(&local_var_content).ok();
2732 let local_var_error = ResponseContent {
2733 status: local_var_status,
2734 content: local_var_content,
2735 entity: local_var_entity,
2736 retry_delay: local_var_retry_delay,
2737 };
2738 Err(Error::ResponseError(local_var_error))
2739 }
2740}
2741
2742pub async fn list_group_billing_invoice_lines(
2744 configuration: &configuration::Configuration,
2745 group_name: &str,
2746 billing_invoice_id: &str,
2747 page_token: Option<&str>,
2748 page_size: Option<i64>,
2749) -> Result<models::ListAccountBillingInvoiceLinesResponse, Error<ListGroupBillingInvoiceLinesError>>
2750{
2751 let mut backoff = configuration.backoff.clone();
2752 let mut refreshed_credentials = false;
2753 let method = reqwest::Method::GET;
2754 loop {
2755 let result = list_group_billing_invoice_lines_inner(
2756 configuration,
2757 &mut backoff,
2758 group_name.clone(),
2759 billing_invoice_id.clone(),
2760 page_token.clone(),
2761 page_size.clone(),
2762 )
2763 .await;
2764
2765 match result {
2766 Ok(result) => return Ok(result),
2767 Err(Error::ResponseError(response)) => {
2768 if !refreshed_credentials
2769 && matches!(
2770 response.status,
2771 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
2772 )
2773 {
2774 configuration.qcs_config.refresh().await?;
2775 refreshed_credentials = true;
2776 continue;
2777 } else if let Some(duration) = response.retry_delay {
2778 tokio::time::sleep(duration).await;
2779 continue;
2780 }
2781
2782 return Err(Error::ResponseError(response));
2783 }
2784 Err(Error::Reqwest(error)) => {
2785 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
2786 tokio::time::sleep(duration).await;
2787 continue;
2788 }
2789
2790 return Err(Error::Reqwest(error));
2791 }
2792 Err(Error::Io(error)) => {
2793 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
2794 tokio::time::sleep(duration).await;
2795 continue;
2796 }
2797
2798 return Err(Error::Io(error));
2799 }
2800 Err(error) => return Err(error),
2801 }
2802 }
2803}
2804async fn list_group_billing_invoices_inner(
2805 configuration: &configuration::Configuration,
2806 backoff: &mut ExponentialBackoff,
2807 group_name: &str,
2808 page_token: Option<&str>,
2809 page_size: Option<i64>,
2810) -> Result<models::ListAccountBillingInvoicesResponse, Error<ListGroupBillingInvoicesError>> {
2811 let local_var_configuration = configuration;
2812 let p_path_group_name = group_name;
2814 let p_query_page_token = page_token;
2815 let p_query_page_size = page_size;
2816
2817 let local_var_client = &local_var_configuration.client;
2818
2819 let local_var_uri_str = format!(
2820 "{}/v1/groups/{groupName}/billingInvoices",
2821 local_var_configuration.qcs_config.api_url(),
2822 groupName = crate::apis::urlencode(p_path_group_name)
2823 );
2824 let mut local_var_req_builder =
2825 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
2826
2827 #[cfg(feature = "tracing")]
2828 {
2829 let local_var_do_tracing = local_var_uri_str
2832 .parse::<::url::Url>()
2833 .ok()
2834 .is_none_or(|url| {
2835 configuration
2836 .qcs_config
2837 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
2838 });
2839
2840 if local_var_do_tracing {
2841 ::tracing::debug!(
2842 url=%local_var_uri_str,
2843 method="GET",
2844 "making list_group_billing_invoices request",
2845 );
2846 }
2847 }
2848
2849 if let Some(ref local_var_str) = p_query_page_token {
2850 local_var_req_builder =
2851 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
2852 }
2853 if let Some(ref local_var_str) = p_query_page_size {
2854 local_var_req_builder =
2855 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
2856 }
2857
2858 {
2861 use qcs_api_client_common::configuration::TokenError;
2862
2863 #[allow(
2864 clippy::nonminimal_bool,
2865 clippy::eq_op,
2866 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
2867 )]
2868 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
2869
2870 let token = local_var_configuration
2871 .qcs_config
2872 .get_bearer_access_token()
2873 .await;
2874
2875 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
2876 #[cfg(feature = "tracing")]
2878 tracing::debug!(
2879 "No client credentials found, but this call does not require authentication."
2880 );
2881 } else {
2882 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
2883 }
2884 }
2885
2886 let local_var_req = local_var_req_builder.build()?;
2887 let local_var_resp = local_var_client.execute(local_var_req).await?;
2888
2889 let local_var_status = local_var_resp.status();
2890 let local_var_raw_content_type = local_var_resp
2891 .headers()
2892 .get("content-type")
2893 .and_then(|v| v.to_str().ok())
2894 .unwrap_or("application/octet-stream")
2895 .to_string();
2896 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
2897
2898 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2899 let local_var_content = local_var_resp.text().await?;
2900 match local_var_content_type {
2901 ContentType::Json => serde_path_to_error::deserialize(
2902 &mut serde_json::Deserializer::from_str(&local_var_content),
2903 )
2904 .map_err(Error::from),
2905 ContentType::Text => Err(Error::InvalidContentType {
2906 content_type: local_var_raw_content_type,
2907 return_type: "models::ListAccountBillingInvoicesResponse",
2908 }),
2909 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
2910 content_type: unknown_type,
2911 return_type: "models::ListAccountBillingInvoicesResponse",
2912 }),
2913 }
2914 } else {
2915 let local_var_retry_delay =
2916 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
2917 let local_var_content = local_var_resp.text().await?;
2918 let local_var_entity: Option<ListGroupBillingInvoicesError> =
2919 serde_json::from_str(&local_var_content).ok();
2920 let local_var_error = ResponseContent {
2921 status: local_var_status,
2922 content: local_var_content,
2923 entity: local_var_entity,
2924 retry_delay: local_var_retry_delay,
2925 };
2926 Err(Error::ResponseError(local_var_error))
2927 }
2928}
2929
2930pub async fn list_group_billing_invoices(
2932 configuration: &configuration::Configuration,
2933 group_name: &str,
2934 page_token: Option<&str>,
2935 page_size: Option<i64>,
2936) -> Result<models::ListAccountBillingInvoicesResponse, Error<ListGroupBillingInvoicesError>> {
2937 let mut backoff = configuration.backoff.clone();
2938 let mut refreshed_credentials = false;
2939 let method = reqwest::Method::GET;
2940 loop {
2941 let result = list_group_billing_invoices_inner(
2942 configuration,
2943 &mut backoff,
2944 group_name.clone(),
2945 page_token.clone(),
2946 page_size.clone(),
2947 )
2948 .await;
2949
2950 match result {
2951 Ok(result) => return Ok(result),
2952 Err(Error::ResponseError(response)) => {
2953 if !refreshed_credentials
2954 && matches!(
2955 response.status,
2956 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
2957 )
2958 {
2959 configuration.qcs_config.refresh().await?;
2960 refreshed_credentials = true;
2961 continue;
2962 } else if let Some(duration) = response.retry_delay {
2963 tokio::time::sleep(duration).await;
2964 continue;
2965 }
2966
2967 return Err(Error::ResponseError(response));
2968 }
2969 Err(Error::Reqwest(error)) => {
2970 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
2971 tokio::time::sleep(duration).await;
2972 continue;
2973 }
2974
2975 return Err(Error::Reqwest(error));
2976 }
2977 Err(Error::Io(error)) => {
2978 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
2979 tokio::time::sleep(duration).await;
2980 continue;
2981 }
2982
2983 return Err(Error::Io(error));
2984 }
2985 Err(error) => return Err(error),
2986 }
2987 }
2988}
2989async fn list_group_upcoming_billing_invoice_lines_inner(
2990 configuration: &configuration::Configuration,
2991 backoff: &mut ExponentialBackoff,
2992 group_name: &str,
2993 page_token: Option<&str>,
2994 page_size: Option<i64>,
2995) -> Result<
2996 models::ListAccountBillingInvoiceLinesResponse,
2997 Error<ListGroupUpcomingBillingInvoiceLinesError>,
2998> {
2999 let local_var_configuration = configuration;
3000 let p_path_group_name = group_name;
3002 let p_query_page_token = page_token;
3003 let p_query_page_size = page_size;
3004
3005 let local_var_client = &local_var_configuration.client;
3006
3007 let local_var_uri_str = format!(
3008 "{}/v1/groups/{groupName}/billingInvoices:listUpcomingLines",
3009 local_var_configuration.qcs_config.api_url(),
3010 groupName = crate::apis::urlencode(p_path_group_name)
3011 );
3012 let mut local_var_req_builder =
3013 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3014
3015 #[cfg(feature = "tracing")]
3016 {
3017 let local_var_do_tracing = local_var_uri_str
3020 .parse::<::url::Url>()
3021 .ok()
3022 .is_none_or(|url| {
3023 configuration
3024 .qcs_config
3025 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
3026 });
3027
3028 if local_var_do_tracing {
3029 ::tracing::debug!(
3030 url=%local_var_uri_str,
3031 method="GET",
3032 "making list_group_upcoming_billing_invoice_lines request",
3033 );
3034 }
3035 }
3036
3037 if let Some(ref local_var_str) = p_query_page_token {
3038 local_var_req_builder =
3039 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
3040 }
3041 if let Some(ref local_var_str) = p_query_page_size {
3042 local_var_req_builder =
3043 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
3044 }
3045
3046 {
3049 use qcs_api_client_common::configuration::TokenError;
3050
3051 #[allow(
3052 clippy::nonminimal_bool,
3053 clippy::eq_op,
3054 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
3055 )]
3056 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
3057
3058 let token = local_var_configuration
3059 .qcs_config
3060 .get_bearer_access_token()
3061 .await;
3062
3063 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
3064 #[cfg(feature = "tracing")]
3066 tracing::debug!(
3067 "No client credentials found, but this call does not require authentication."
3068 );
3069 } else {
3070 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
3071 }
3072 }
3073
3074 let local_var_req = local_var_req_builder.build()?;
3075 let local_var_resp = local_var_client.execute(local_var_req).await?;
3076
3077 let local_var_status = local_var_resp.status();
3078 let local_var_raw_content_type = local_var_resp
3079 .headers()
3080 .get("content-type")
3081 .and_then(|v| v.to_str().ok())
3082 .unwrap_or("application/octet-stream")
3083 .to_string();
3084 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
3085
3086 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3087 let local_var_content = local_var_resp.text().await?;
3088 match local_var_content_type {
3089 ContentType::Json => serde_path_to_error::deserialize(
3090 &mut serde_json::Deserializer::from_str(&local_var_content),
3091 )
3092 .map_err(Error::from),
3093 ContentType::Text => Err(Error::InvalidContentType {
3094 content_type: local_var_raw_content_type,
3095 return_type: "models::ListAccountBillingInvoiceLinesResponse",
3096 }),
3097 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
3098 content_type: unknown_type,
3099 return_type: "models::ListAccountBillingInvoiceLinesResponse",
3100 }),
3101 }
3102 } else {
3103 let local_var_retry_delay =
3104 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
3105 let local_var_content = local_var_resp.text().await?;
3106 let local_var_entity: Option<ListGroupUpcomingBillingInvoiceLinesError> =
3107 serde_json::from_str(&local_var_content).ok();
3108 let local_var_error = ResponseContent {
3109 status: local_var_status,
3110 content: local_var_content,
3111 entity: local_var_entity,
3112 retry_delay: local_var_retry_delay,
3113 };
3114 Err(Error::ResponseError(local_var_error))
3115 }
3116}
3117
3118pub async fn list_group_upcoming_billing_invoice_lines(
3120 configuration: &configuration::Configuration,
3121 group_name: &str,
3122 page_token: Option<&str>,
3123 page_size: Option<i64>,
3124) -> Result<
3125 models::ListAccountBillingInvoiceLinesResponse,
3126 Error<ListGroupUpcomingBillingInvoiceLinesError>,
3127> {
3128 let mut backoff = configuration.backoff.clone();
3129 let mut refreshed_credentials = false;
3130 let method = reqwest::Method::GET;
3131 loop {
3132 let result = list_group_upcoming_billing_invoice_lines_inner(
3133 configuration,
3134 &mut backoff,
3135 group_name.clone(),
3136 page_token.clone(),
3137 page_size.clone(),
3138 )
3139 .await;
3140
3141 match result {
3142 Ok(result) => return Ok(result),
3143 Err(Error::ResponseError(response)) => {
3144 if !refreshed_credentials
3145 && matches!(
3146 response.status,
3147 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
3148 )
3149 {
3150 configuration.qcs_config.refresh().await?;
3151 refreshed_credentials = true;
3152 continue;
3153 } else if let Some(duration) = response.retry_delay {
3154 tokio::time::sleep(duration).await;
3155 continue;
3156 }
3157
3158 return Err(Error::ResponseError(response));
3159 }
3160 Err(Error::Reqwest(error)) => {
3161 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
3162 tokio::time::sleep(duration).await;
3163 continue;
3164 }
3165
3166 return Err(Error::Reqwest(error));
3167 }
3168 Err(Error::Io(error)) => {
3169 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
3170 tokio::time::sleep(duration).await;
3171 continue;
3172 }
3173
3174 return Err(Error::Io(error));
3175 }
3176 Err(error) => return Err(error),
3177 }
3178 }
3179}
3180async fn list_group_users_inner(
3181 configuration: &configuration::Configuration,
3182 backoff: &mut ExponentialBackoff,
3183 group_name: &str,
3184 page_size: Option<i64>,
3185 page_token: Option<&str>,
3186) -> Result<models::ListGroupUsersResponse, Error<ListGroupUsersError>> {
3187 let local_var_configuration = configuration;
3188 let p_path_group_name = group_name;
3190 let p_query_page_size = page_size;
3191 let p_query_page_token = page_token;
3192
3193 let local_var_client = &local_var_configuration.client;
3194
3195 let local_var_uri_str = format!(
3196 "{}/v1/groups/{groupName}/users",
3197 local_var_configuration.qcs_config.api_url(),
3198 groupName = crate::apis::urlencode(p_path_group_name)
3199 );
3200 let mut local_var_req_builder =
3201 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3202
3203 #[cfg(feature = "tracing")]
3204 {
3205 let local_var_do_tracing = local_var_uri_str
3208 .parse::<::url::Url>()
3209 .ok()
3210 .is_none_or(|url| {
3211 configuration
3212 .qcs_config
3213 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
3214 });
3215
3216 if local_var_do_tracing {
3217 ::tracing::debug!(
3218 url=%local_var_uri_str,
3219 method="GET",
3220 "making list_group_users request",
3221 );
3222 }
3223 }
3224
3225 if let Some(ref local_var_str) = p_query_page_size {
3226 local_var_req_builder =
3227 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
3228 }
3229 if let Some(ref local_var_str) = p_query_page_token {
3230 local_var_req_builder =
3231 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
3232 }
3233
3234 {
3237 use qcs_api_client_common::configuration::TokenError;
3238
3239 #[allow(
3240 clippy::nonminimal_bool,
3241 clippy::eq_op,
3242 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
3243 )]
3244 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
3245
3246 let token = local_var_configuration
3247 .qcs_config
3248 .get_bearer_access_token()
3249 .await;
3250
3251 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
3252 #[cfg(feature = "tracing")]
3254 tracing::debug!(
3255 "No client credentials found, but this call does not require authentication."
3256 );
3257 } else {
3258 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
3259 }
3260 }
3261
3262 let local_var_req = local_var_req_builder.build()?;
3263 let local_var_resp = local_var_client.execute(local_var_req).await?;
3264
3265 let local_var_status = local_var_resp.status();
3266 let local_var_raw_content_type = local_var_resp
3267 .headers()
3268 .get("content-type")
3269 .and_then(|v| v.to_str().ok())
3270 .unwrap_or("application/octet-stream")
3271 .to_string();
3272 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
3273
3274 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3275 let local_var_content = local_var_resp.text().await?;
3276 match local_var_content_type {
3277 ContentType::Json => serde_path_to_error::deserialize(
3278 &mut serde_json::Deserializer::from_str(&local_var_content),
3279 )
3280 .map_err(Error::from),
3281 ContentType::Text => Err(Error::InvalidContentType {
3282 content_type: local_var_raw_content_type,
3283 return_type: "models::ListGroupUsersResponse",
3284 }),
3285 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
3286 content_type: unknown_type,
3287 return_type: "models::ListGroupUsersResponse",
3288 }),
3289 }
3290 } else {
3291 let local_var_retry_delay =
3292 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
3293 let local_var_content = local_var_resp.text().await?;
3294 let local_var_entity: Option<ListGroupUsersError> =
3295 serde_json::from_str(&local_var_content).ok();
3296 let local_var_error = ResponseContent {
3297 status: local_var_status,
3298 content: local_var_content,
3299 entity: local_var_entity,
3300 retry_delay: local_var_retry_delay,
3301 };
3302 Err(Error::ResponseError(local_var_error))
3303 }
3304}
3305
3306pub async fn list_group_users(
3308 configuration: &configuration::Configuration,
3309 group_name: &str,
3310 page_size: Option<i64>,
3311 page_token: Option<&str>,
3312) -> Result<models::ListGroupUsersResponse, Error<ListGroupUsersError>> {
3313 let mut backoff = configuration.backoff.clone();
3314 let mut refreshed_credentials = false;
3315 let method = reqwest::Method::GET;
3316 loop {
3317 let result = list_group_users_inner(
3318 configuration,
3319 &mut backoff,
3320 group_name.clone(),
3321 page_size.clone(),
3322 page_token.clone(),
3323 )
3324 .await;
3325
3326 match result {
3327 Ok(result) => return Ok(result),
3328 Err(Error::ResponseError(response)) => {
3329 if !refreshed_credentials
3330 && matches!(
3331 response.status,
3332 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
3333 )
3334 {
3335 configuration.qcs_config.refresh().await?;
3336 refreshed_credentials = true;
3337 continue;
3338 } else if let Some(duration) = response.retry_delay {
3339 tokio::time::sleep(duration).await;
3340 continue;
3341 }
3342
3343 return Err(Error::ResponseError(response));
3344 }
3345 Err(Error::Reqwest(error)) => {
3346 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
3347 tokio::time::sleep(duration).await;
3348 continue;
3349 }
3350
3351 return Err(Error::Reqwest(error));
3352 }
3353 Err(Error::Io(error)) => {
3354 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
3355 tokio::time::sleep(duration).await;
3356 continue;
3357 }
3358
3359 return Err(Error::Io(error));
3360 }
3361 Err(error) => return Err(error),
3362 }
3363 }
3364}
3365async fn list_user_billing_invoice_lines_inner(
3366 configuration: &configuration::Configuration,
3367 backoff: &mut ExponentialBackoff,
3368 user_id: &str,
3369 billing_invoice_id: &str,
3370 page_token: Option<&str>,
3371 page_size: Option<i64>,
3372) -> Result<models::ListAccountBillingInvoiceLinesResponse, Error<ListUserBillingInvoiceLinesError>>
3373{
3374 let local_var_configuration = configuration;
3375 let p_path_user_id = user_id;
3377 let p_path_billing_invoice_id = billing_invoice_id;
3378 let p_query_page_token = page_token;
3379 let p_query_page_size = page_size;
3380
3381 let local_var_client = &local_var_configuration.client;
3382
3383 let local_var_uri_str = format!(
3384 "{}/v1/users/{userId}/billingInvoices/{billingInvoiceId}/lines",
3385 local_var_configuration.qcs_config.api_url(),
3386 userId = crate::apis::urlencode(p_path_user_id),
3387 billingInvoiceId = crate::apis::urlencode(p_path_billing_invoice_id)
3388 );
3389 let mut local_var_req_builder =
3390 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3391
3392 #[cfg(feature = "tracing")]
3393 {
3394 let local_var_do_tracing = local_var_uri_str
3397 .parse::<::url::Url>()
3398 .ok()
3399 .is_none_or(|url| {
3400 configuration
3401 .qcs_config
3402 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
3403 });
3404
3405 if local_var_do_tracing {
3406 ::tracing::debug!(
3407 url=%local_var_uri_str,
3408 method="GET",
3409 "making list_user_billing_invoice_lines request",
3410 );
3411 }
3412 }
3413
3414 if let Some(ref local_var_str) = p_query_page_token {
3415 local_var_req_builder =
3416 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
3417 }
3418 if let Some(ref local_var_str) = p_query_page_size {
3419 local_var_req_builder =
3420 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
3421 }
3422
3423 {
3426 use qcs_api_client_common::configuration::TokenError;
3427
3428 #[allow(
3429 clippy::nonminimal_bool,
3430 clippy::eq_op,
3431 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
3432 )]
3433 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
3434
3435 let token = local_var_configuration
3436 .qcs_config
3437 .get_bearer_access_token()
3438 .await;
3439
3440 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
3441 #[cfg(feature = "tracing")]
3443 tracing::debug!(
3444 "No client credentials found, but this call does not require authentication."
3445 );
3446 } else {
3447 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
3448 }
3449 }
3450
3451 let local_var_req = local_var_req_builder.build()?;
3452 let local_var_resp = local_var_client.execute(local_var_req).await?;
3453
3454 let local_var_status = local_var_resp.status();
3455 let local_var_raw_content_type = local_var_resp
3456 .headers()
3457 .get("content-type")
3458 .and_then(|v| v.to_str().ok())
3459 .unwrap_or("application/octet-stream")
3460 .to_string();
3461 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
3462
3463 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3464 let local_var_content = local_var_resp.text().await?;
3465 match local_var_content_type {
3466 ContentType::Json => serde_path_to_error::deserialize(
3467 &mut serde_json::Deserializer::from_str(&local_var_content),
3468 )
3469 .map_err(Error::from),
3470 ContentType::Text => Err(Error::InvalidContentType {
3471 content_type: local_var_raw_content_type,
3472 return_type: "models::ListAccountBillingInvoiceLinesResponse",
3473 }),
3474 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
3475 content_type: unknown_type,
3476 return_type: "models::ListAccountBillingInvoiceLinesResponse",
3477 }),
3478 }
3479 } else {
3480 let local_var_retry_delay =
3481 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
3482 let local_var_content = local_var_resp.text().await?;
3483 let local_var_entity: Option<ListUserBillingInvoiceLinesError> =
3484 serde_json::from_str(&local_var_content).ok();
3485 let local_var_error = ResponseContent {
3486 status: local_var_status,
3487 content: local_var_content,
3488 entity: local_var_entity,
3489 retry_delay: local_var_retry_delay,
3490 };
3491 Err(Error::ResponseError(local_var_error))
3492 }
3493}
3494
3495pub async fn list_user_billing_invoice_lines(
3497 configuration: &configuration::Configuration,
3498 user_id: &str,
3499 billing_invoice_id: &str,
3500 page_token: Option<&str>,
3501 page_size: Option<i64>,
3502) -> Result<models::ListAccountBillingInvoiceLinesResponse, Error<ListUserBillingInvoiceLinesError>>
3503{
3504 let mut backoff = configuration.backoff.clone();
3505 let mut refreshed_credentials = false;
3506 let method = reqwest::Method::GET;
3507 loop {
3508 let result = list_user_billing_invoice_lines_inner(
3509 configuration,
3510 &mut backoff,
3511 user_id.clone(),
3512 billing_invoice_id.clone(),
3513 page_token.clone(),
3514 page_size.clone(),
3515 )
3516 .await;
3517
3518 match result {
3519 Ok(result) => return Ok(result),
3520 Err(Error::ResponseError(response)) => {
3521 if !refreshed_credentials
3522 && matches!(
3523 response.status,
3524 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
3525 )
3526 {
3527 configuration.qcs_config.refresh().await?;
3528 refreshed_credentials = true;
3529 continue;
3530 } else if let Some(duration) = response.retry_delay {
3531 tokio::time::sleep(duration).await;
3532 continue;
3533 }
3534
3535 return Err(Error::ResponseError(response));
3536 }
3537 Err(Error::Reqwest(error)) => {
3538 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
3539 tokio::time::sleep(duration).await;
3540 continue;
3541 }
3542
3543 return Err(Error::Reqwest(error));
3544 }
3545 Err(Error::Io(error)) => {
3546 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
3547 tokio::time::sleep(duration).await;
3548 continue;
3549 }
3550
3551 return Err(Error::Io(error));
3552 }
3553 Err(error) => return Err(error),
3554 }
3555 }
3556}
3557async fn list_user_billing_invoices_inner(
3558 configuration: &configuration::Configuration,
3559 backoff: &mut ExponentialBackoff,
3560 user_id: &str,
3561 page_token: Option<&str>,
3562 page_size: Option<i64>,
3563) -> Result<models::ListAccountBillingInvoicesResponse, Error<ListUserBillingInvoicesError>> {
3564 let local_var_configuration = configuration;
3565 let p_path_user_id = user_id;
3567 let p_query_page_token = page_token;
3568 let p_query_page_size = page_size;
3569
3570 let local_var_client = &local_var_configuration.client;
3571
3572 let local_var_uri_str = format!(
3573 "{}/v1/users/{userId}/billingInvoices",
3574 local_var_configuration.qcs_config.api_url(),
3575 userId = crate::apis::urlencode(p_path_user_id)
3576 );
3577 let mut local_var_req_builder =
3578 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3579
3580 #[cfg(feature = "tracing")]
3581 {
3582 let local_var_do_tracing = local_var_uri_str
3585 .parse::<::url::Url>()
3586 .ok()
3587 .is_none_or(|url| {
3588 configuration
3589 .qcs_config
3590 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
3591 });
3592
3593 if local_var_do_tracing {
3594 ::tracing::debug!(
3595 url=%local_var_uri_str,
3596 method="GET",
3597 "making list_user_billing_invoices request",
3598 );
3599 }
3600 }
3601
3602 if let Some(ref local_var_str) = p_query_page_token {
3603 local_var_req_builder =
3604 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
3605 }
3606 if let Some(ref local_var_str) = p_query_page_size {
3607 local_var_req_builder =
3608 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
3609 }
3610
3611 {
3614 use qcs_api_client_common::configuration::TokenError;
3615
3616 #[allow(
3617 clippy::nonminimal_bool,
3618 clippy::eq_op,
3619 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
3620 )]
3621 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
3622
3623 let token = local_var_configuration
3624 .qcs_config
3625 .get_bearer_access_token()
3626 .await;
3627
3628 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
3629 #[cfg(feature = "tracing")]
3631 tracing::debug!(
3632 "No client credentials found, but this call does not require authentication."
3633 );
3634 } else {
3635 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
3636 }
3637 }
3638
3639 let local_var_req = local_var_req_builder.build()?;
3640 let local_var_resp = local_var_client.execute(local_var_req).await?;
3641
3642 let local_var_status = local_var_resp.status();
3643 let local_var_raw_content_type = local_var_resp
3644 .headers()
3645 .get("content-type")
3646 .and_then(|v| v.to_str().ok())
3647 .unwrap_or("application/octet-stream")
3648 .to_string();
3649 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
3650
3651 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3652 let local_var_content = local_var_resp.text().await?;
3653 match local_var_content_type {
3654 ContentType::Json => serde_path_to_error::deserialize(
3655 &mut serde_json::Deserializer::from_str(&local_var_content),
3656 )
3657 .map_err(Error::from),
3658 ContentType::Text => Err(Error::InvalidContentType {
3659 content_type: local_var_raw_content_type,
3660 return_type: "models::ListAccountBillingInvoicesResponse",
3661 }),
3662 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
3663 content_type: unknown_type,
3664 return_type: "models::ListAccountBillingInvoicesResponse",
3665 }),
3666 }
3667 } else {
3668 let local_var_retry_delay =
3669 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
3670 let local_var_content = local_var_resp.text().await?;
3671 let local_var_entity: Option<ListUserBillingInvoicesError> =
3672 serde_json::from_str(&local_var_content).ok();
3673 let local_var_error = ResponseContent {
3674 status: local_var_status,
3675 content: local_var_content,
3676 entity: local_var_entity,
3677 retry_delay: local_var_retry_delay,
3678 };
3679 Err(Error::ResponseError(local_var_error))
3680 }
3681}
3682
3683pub async fn list_user_billing_invoices(
3685 configuration: &configuration::Configuration,
3686 user_id: &str,
3687 page_token: Option<&str>,
3688 page_size: Option<i64>,
3689) -> Result<models::ListAccountBillingInvoicesResponse, Error<ListUserBillingInvoicesError>> {
3690 let mut backoff = configuration.backoff.clone();
3691 let mut refreshed_credentials = false;
3692 let method = reqwest::Method::GET;
3693 loop {
3694 let result = list_user_billing_invoices_inner(
3695 configuration,
3696 &mut backoff,
3697 user_id.clone(),
3698 page_token.clone(),
3699 page_size.clone(),
3700 )
3701 .await;
3702
3703 match result {
3704 Ok(result) => return Ok(result),
3705 Err(Error::ResponseError(response)) => {
3706 if !refreshed_credentials
3707 && matches!(
3708 response.status,
3709 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
3710 )
3711 {
3712 configuration.qcs_config.refresh().await?;
3713 refreshed_credentials = true;
3714 continue;
3715 } else if let Some(duration) = response.retry_delay {
3716 tokio::time::sleep(duration).await;
3717 continue;
3718 }
3719
3720 return Err(Error::ResponseError(response));
3721 }
3722 Err(Error::Reqwest(error)) => {
3723 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
3724 tokio::time::sleep(duration).await;
3725 continue;
3726 }
3727
3728 return Err(Error::Reqwest(error));
3729 }
3730 Err(Error::Io(error)) => {
3731 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
3732 tokio::time::sleep(duration).await;
3733 continue;
3734 }
3735
3736 return Err(Error::Io(error));
3737 }
3738 Err(error) => return Err(error),
3739 }
3740 }
3741}
3742async fn list_user_groups_inner(
3743 configuration: &configuration::Configuration,
3744 backoff: &mut ExponentialBackoff,
3745 user_id: &str,
3746 page_size: Option<i64>,
3747 page_token: Option<&str>,
3748) -> Result<models::ListGroupsResponse, Error<ListUserGroupsError>> {
3749 let local_var_configuration = configuration;
3750 let p_path_user_id = user_id;
3752 let p_query_page_size = page_size;
3753 let p_query_page_token = page_token;
3754
3755 let local_var_client = &local_var_configuration.client;
3756
3757 let local_var_uri_str = format!(
3758 "{}/v1/users/{userId}/groups",
3759 local_var_configuration.qcs_config.api_url(),
3760 userId = crate::apis::urlencode(p_path_user_id)
3761 );
3762 let mut local_var_req_builder =
3763 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3764
3765 #[cfg(feature = "tracing")]
3766 {
3767 let local_var_do_tracing = local_var_uri_str
3770 .parse::<::url::Url>()
3771 .ok()
3772 .is_none_or(|url| {
3773 configuration
3774 .qcs_config
3775 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
3776 });
3777
3778 if local_var_do_tracing {
3779 ::tracing::debug!(
3780 url=%local_var_uri_str,
3781 method="GET",
3782 "making list_user_groups request",
3783 );
3784 }
3785 }
3786
3787 if let Some(ref local_var_str) = p_query_page_size {
3788 local_var_req_builder =
3789 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
3790 }
3791 if let Some(ref local_var_str) = p_query_page_token {
3792 local_var_req_builder =
3793 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
3794 }
3795
3796 {
3799 use qcs_api_client_common::configuration::TokenError;
3800
3801 #[allow(
3802 clippy::nonminimal_bool,
3803 clippy::eq_op,
3804 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
3805 )]
3806 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
3807
3808 let token = local_var_configuration
3809 .qcs_config
3810 .get_bearer_access_token()
3811 .await;
3812
3813 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
3814 #[cfg(feature = "tracing")]
3816 tracing::debug!(
3817 "No client credentials found, but this call does not require authentication."
3818 );
3819 } else {
3820 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
3821 }
3822 }
3823
3824 let local_var_req = local_var_req_builder.build()?;
3825 let local_var_resp = local_var_client.execute(local_var_req).await?;
3826
3827 let local_var_status = local_var_resp.status();
3828 let local_var_raw_content_type = local_var_resp
3829 .headers()
3830 .get("content-type")
3831 .and_then(|v| v.to_str().ok())
3832 .unwrap_or("application/octet-stream")
3833 .to_string();
3834 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
3835
3836 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3837 let local_var_content = local_var_resp.text().await?;
3838 match local_var_content_type {
3839 ContentType::Json => serde_path_to_error::deserialize(
3840 &mut serde_json::Deserializer::from_str(&local_var_content),
3841 )
3842 .map_err(Error::from),
3843 ContentType::Text => Err(Error::InvalidContentType {
3844 content_type: local_var_raw_content_type,
3845 return_type: "models::ListGroupsResponse",
3846 }),
3847 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
3848 content_type: unknown_type,
3849 return_type: "models::ListGroupsResponse",
3850 }),
3851 }
3852 } else {
3853 let local_var_retry_delay =
3854 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
3855 let local_var_content = local_var_resp.text().await?;
3856 let local_var_entity: Option<ListUserGroupsError> =
3857 serde_json::from_str(&local_var_content).ok();
3858 let local_var_error = ResponseContent {
3859 status: local_var_status,
3860 content: local_var_content,
3861 entity: local_var_entity,
3862 retry_delay: local_var_retry_delay,
3863 };
3864 Err(Error::ResponseError(local_var_error))
3865 }
3866}
3867
3868pub async fn list_user_groups(
3870 configuration: &configuration::Configuration,
3871 user_id: &str,
3872 page_size: Option<i64>,
3873 page_token: Option<&str>,
3874) -> Result<models::ListGroupsResponse, Error<ListUserGroupsError>> {
3875 let mut backoff = configuration.backoff.clone();
3876 let mut refreshed_credentials = false;
3877 let method = reqwest::Method::GET;
3878 loop {
3879 let result = list_user_groups_inner(
3880 configuration,
3881 &mut backoff,
3882 user_id.clone(),
3883 page_size.clone(),
3884 page_token.clone(),
3885 )
3886 .await;
3887
3888 match result {
3889 Ok(result) => return Ok(result),
3890 Err(Error::ResponseError(response)) => {
3891 if !refreshed_credentials
3892 && matches!(
3893 response.status,
3894 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
3895 )
3896 {
3897 configuration.qcs_config.refresh().await?;
3898 refreshed_credentials = true;
3899 continue;
3900 } else if let Some(duration) = response.retry_delay {
3901 tokio::time::sleep(duration).await;
3902 continue;
3903 }
3904
3905 return Err(Error::ResponseError(response));
3906 }
3907 Err(Error::Reqwest(error)) => {
3908 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
3909 tokio::time::sleep(duration).await;
3910 continue;
3911 }
3912
3913 return Err(Error::Reqwest(error));
3914 }
3915 Err(Error::Io(error)) => {
3916 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
3917 tokio::time::sleep(duration).await;
3918 continue;
3919 }
3920
3921 return Err(Error::Io(error));
3922 }
3923 Err(error) => return Err(error),
3924 }
3925 }
3926}
3927async fn list_user_upcoming_billing_invoice_lines_inner(
3928 configuration: &configuration::Configuration,
3929 backoff: &mut ExponentialBackoff,
3930 user_id: &str,
3931 page_token: Option<&str>,
3932 page_size: Option<i64>,
3933) -> Result<
3934 models::ListAccountBillingInvoiceLinesResponse,
3935 Error<ListUserUpcomingBillingInvoiceLinesError>,
3936> {
3937 let local_var_configuration = configuration;
3938 let p_path_user_id = user_id;
3940 let p_query_page_token = page_token;
3941 let p_query_page_size = page_size;
3942
3943 let local_var_client = &local_var_configuration.client;
3944
3945 let local_var_uri_str = format!(
3946 "{}/v1/users/{userId}/billingInvoices:listUpcomingLines",
3947 local_var_configuration.qcs_config.api_url(),
3948 userId = crate::apis::urlencode(p_path_user_id)
3949 );
3950 let mut local_var_req_builder =
3951 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3952
3953 #[cfg(feature = "tracing")]
3954 {
3955 let local_var_do_tracing = local_var_uri_str
3958 .parse::<::url::Url>()
3959 .ok()
3960 .is_none_or(|url| {
3961 configuration
3962 .qcs_config
3963 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
3964 });
3965
3966 if local_var_do_tracing {
3967 ::tracing::debug!(
3968 url=%local_var_uri_str,
3969 method="GET",
3970 "making list_user_upcoming_billing_invoice_lines request",
3971 );
3972 }
3973 }
3974
3975 if let Some(ref local_var_str) = p_query_page_token {
3976 local_var_req_builder =
3977 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
3978 }
3979 if let Some(ref local_var_str) = p_query_page_size {
3980 local_var_req_builder =
3981 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
3982 }
3983
3984 {
3987 use qcs_api_client_common::configuration::TokenError;
3988
3989 #[allow(
3990 clippy::nonminimal_bool,
3991 clippy::eq_op,
3992 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
3993 )]
3994 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
3995
3996 let token = local_var_configuration
3997 .qcs_config
3998 .get_bearer_access_token()
3999 .await;
4000
4001 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
4002 #[cfg(feature = "tracing")]
4004 tracing::debug!(
4005 "No client credentials found, but this call does not require authentication."
4006 );
4007 } else {
4008 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
4009 }
4010 }
4011
4012 let local_var_req = local_var_req_builder.build()?;
4013 let local_var_resp = local_var_client.execute(local_var_req).await?;
4014
4015 let local_var_status = local_var_resp.status();
4016 let local_var_raw_content_type = local_var_resp
4017 .headers()
4018 .get("content-type")
4019 .and_then(|v| v.to_str().ok())
4020 .unwrap_or("application/octet-stream")
4021 .to_string();
4022 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
4023
4024 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4025 let local_var_content = local_var_resp.text().await?;
4026 match local_var_content_type {
4027 ContentType::Json => serde_path_to_error::deserialize(
4028 &mut serde_json::Deserializer::from_str(&local_var_content),
4029 )
4030 .map_err(Error::from),
4031 ContentType::Text => Err(Error::InvalidContentType {
4032 content_type: local_var_raw_content_type,
4033 return_type: "models::ListAccountBillingInvoiceLinesResponse",
4034 }),
4035 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
4036 content_type: unknown_type,
4037 return_type: "models::ListAccountBillingInvoiceLinesResponse",
4038 }),
4039 }
4040 } else {
4041 let local_var_retry_delay =
4042 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
4043 let local_var_content = local_var_resp.text().await?;
4044 let local_var_entity: Option<ListUserUpcomingBillingInvoiceLinesError> =
4045 serde_json::from_str(&local_var_content).ok();
4046 let local_var_error = ResponseContent {
4047 status: local_var_status,
4048 content: local_var_content,
4049 entity: local_var_entity,
4050 retry_delay: local_var_retry_delay,
4051 };
4052 Err(Error::ResponseError(local_var_error))
4053 }
4054}
4055
4056pub async fn list_user_upcoming_billing_invoice_lines(
4058 configuration: &configuration::Configuration,
4059 user_id: &str,
4060 page_token: Option<&str>,
4061 page_size: Option<i64>,
4062) -> Result<
4063 models::ListAccountBillingInvoiceLinesResponse,
4064 Error<ListUserUpcomingBillingInvoiceLinesError>,
4065> {
4066 let mut backoff = configuration.backoff.clone();
4067 let mut refreshed_credentials = false;
4068 let method = reqwest::Method::GET;
4069 loop {
4070 let result = list_user_upcoming_billing_invoice_lines_inner(
4071 configuration,
4072 &mut backoff,
4073 user_id.clone(),
4074 page_token.clone(),
4075 page_size.clone(),
4076 )
4077 .await;
4078
4079 match result {
4080 Ok(result) => return Ok(result),
4081 Err(Error::ResponseError(response)) => {
4082 if !refreshed_credentials
4083 && matches!(
4084 response.status,
4085 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
4086 )
4087 {
4088 configuration.qcs_config.refresh().await?;
4089 refreshed_credentials = true;
4090 continue;
4091 } else if let Some(duration) = response.retry_delay {
4092 tokio::time::sleep(duration).await;
4093 continue;
4094 }
4095
4096 return Err(Error::ResponseError(response));
4097 }
4098 Err(Error::Reqwest(error)) => {
4099 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
4100 tokio::time::sleep(duration).await;
4101 continue;
4102 }
4103
4104 return Err(Error::Reqwest(error));
4105 }
4106 Err(Error::Io(error)) => {
4107 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
4108 tokio::time::sleep(duration).await;
4109 continue;
4110 }
4111
4112 return Err(Error::Io(error));
4113 }
4114 Err(error) => return Err(error),
4115 }
4116 }
4117}
4118async fn list_viewer_announcements_inner(
4119 configuration: &configuration::Configuration,
4120 backoff: &mut ExponentialBackoff,
4121 page_size: Option<i64>,
4122 page_token: Option<&str>,
4123 include_dismissed: Option<bool>,
4124) -> Result<models::AnnouncementsResponse, Error<ListViewerAnnouncementsError>> {
4125 let local_var_configuration = configuration;
4126 let p_query_page_size = page_size;
4128 let p_query_page_token = page_token;
4129 let p_query_include_dismissed = include_dismissed;
4130
4131 let local_var_client = &local_var_configuration.client;
4132
4133 let local_var_uri_str = format!(
4134 "{}/v1/viewer/announcements",
4135 local_var_configuration.qcs_config.api_url()
4136 );
4137 let mut local_var_req_builder =
4138 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
4139
4140 #[cfg(feature = "tracing")]
4141 {
4142 let local_var_do_tracing = local_var_uri_str
4145 .parse::<::url::Url>()
4146 .ok()
4147 .is_none_or(|url| {
4148 configuration
4149 .qcs_config
4150 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
4151 });
4152
4153 if local_var_do_tracing {
4154 ::tracing::debug!(
4155 url=%local_var_uri_str,
4156 method="GET",
4157 "making list_viewer_announcements request",
4158 );
4159 }
4160 }
4161
4162 if let Some(ref local_var_str) = p_query_page_size {
4163 local_var_req_builder =
4164 local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
4165 }
4166 if let Some(ref local_var_str) = p_query_page_token {
4167 local_var_req_builder =
4168 local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
4169 }
4170 if let Some(ref local_var_str) = p_query_include_dismissed {
4171 local_var_req_builder =
4172 local_var_req_builder.query(&[("includeDismissed", &local_var_str.to_string())]);
4173 }
4174
4175 {
4178 use qcs_api_client_common::configuration::TokenError;
4179
4180 #[allow(
4181 clippy::nonminimal_bool,
4182 clippy::eq_op,
4183 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
4184 )]
4185 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
4186
4187 let token = local_var_configuration
4188 .qcs_config
4189 .get_bearer_access_token()
4190 .await;
4191
4192 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
4193 #[cfg(feature = "tracing")]
4195 tracing::debug!(
4196 "No client credentials found, but this call does not require authentication."
4197 );
4198 } else {
4199 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
4200 }
4201 }
4202
4203 let local_var_req = local_var_req_builder.build()?;
4204 let local_var_resp = local_var_client.execute(local_var_req).await?;
4205
4206 let local_var_status = local_var_resp.status();
4207 let local_var_raw_content_type = local_var_resp
4208 .headers()
4209 .get("content-type")
4210 .and_then(|v| v.to_str().ok())
4211 .unwrap_or("application/octet-stream")
4212 .to_string();
4213 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
4214
4215 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4216 let local_var_content = local_var_resp.text().await?;
4217 match local_var_content_type {
4218 ContentType::Json => serde_path_to_error::deserialize(
4219 &mut serde_json::Deserializer::from_str(&local_var_content),
4220 )
4221 .map_err(Error::from),
4222 ContentType::Text => Err(Error::InvalidContentType {
4223 content_type: local_var_raw_content_type,
4224 return_type: "models::AnnouncementsResponse",
4225 }),
4226 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
4227 content_type: unknown_type,
4228 return_type: "models::AnnouncementsResponse",
4229 }),
4230 }
4231 } else {
4232 let local_var_retry_delay =
4233 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
4234 let local_var_content = local_var_resp.text().await?;
4235 let local_var_entity: Option<ListViewerAnnouncementsError> =
4236 serde_json::from_str(&local_var_content).ok();
4237 let local_var_error = ResponseContent {
4238 status: local_var_status,
4239 content: local_var_content,
4240 entity: local_var_entity,
4241 retry_delay: local_var_retry_delay,
4242 };
4243 Err(Error::ResponseError(local_var_error))
4244 }
4245}
4246
4247pub async fn list_viewer_announcements(
4249 configuration: &configuration::Configuration,
4250 page_size: Option<i64>,
4251 page_token: Option<&str>,
4252 include_dismissed: Option<bool>,
4253) -> Result<models::AnnouncementsResponse, Error<ListViewerAnnouncementsError>> {
4254 let mut backoff = configuration.backoff.clone();
4255 let mut refreshed_credentials = false;
4256 let method = reqwest::Method::GET;
4257 loop {
4258 let result = list_viewer_announcements_inner(
4259 configuration,
4260 &mut backoff,
4261 page_size.clone(),
4262 page_token.clone(),
4263 include_dismissed.clone(),
4264 )
4265 .await;
4266
4267 match result {
4268 Ok(result) => return Ok(result),
4269 Err(Error::ResponseError(response)) => {
4270 if !refreshed_credentials
4271 && matches!(
4272 response.status,
4273 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
4274 )
4275 {
4276 configuration.qcs_config.refresh().await?;
4277 refreshed_credentials = true;
4278 continue;
4279 } else if let Some(duration) = response.retry_delay {
4280 tokio::time::sleep(duration).await;
4281 continue;
4282 }
4283
4284 return Err(Error::ResponseError(response));
4285 }
4286 Err(Error::Reqwest(error)) => {
4287 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
4288 tokio::time::sleep(duration).await;
4289 continue;
4290 }
4291
4292 return Err(Error::Reqwest(error));
4293 }
4294 Err(Error::Io(error)) => {
4295 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
4296 tokio::time::sleep(duration).await;
4297 continue;
4298 }
4299
4300 return Err(Error::Io(error));
4301 }
4302 Err(error) => return Err(error),
4303 }
4304 }
4305}
4306async fn put_viewer_user_onboarding_completed_inner(
4307 configuration: &configuration::Configuration,
4308 backoff: &mut ExponentialBackoff,
4309 viewer_user_onboarding_completed: Option<crate::models::ViewerUserOnboardingCompleted>,
4310) -> Result<models::ViewerUserOnboardingCompleted, Error<PutViewerUserOnboardingCompletedError>> {
4311 let local_var_configuration = configuration;
4312 let p_body_viewer_user_onboarding_completed = viewer_user_onboarding_completed;
4314
4315 let local_var_client = &local_var_configuration.client;
4316
4317 let local_var_uri_str = format!(
4318 "{}/v1/viewer/onboardingCompleted",
4319 local_var_configuration.qcs_config.api_url()
4320 );
4321 let mut local_var_req_builder =
4322 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
4323
4324 #[cfg(feature = "tracing")]
4325 {
4326 let local_var_do_tracing = local_var_uri_str
4329 .parse::<::url::Url>()
4330 .ok()
4331 .is_none_or(|url| {
4332 configuration
4333 .qcs_config
4334 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
4335 });
4336
4337 if local_var_do_tracing {
4338 ::tracing::debug!(
4339 url=%local_var_uri_str,
4340 method="PUT",
4341 "making put_viewer_user_onboarding_completed request",
4342 );
4343 }
4344 }
4345
4346 {
4349 use qcs_api_client_common::configuration::TokenError;
4350
4351 #[allow(
4352 clippy::nonminimal_bool,
4353 clippy::eq_op,
4354 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
4355 )]
4356 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
4357
4358 let token = local_var_configuration
4359 .qcs_config
4360 .get_bearer_access_token()
4361 .await;
4362
4363 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
4364 #[cfg(feature = "tracing")]
4366 tracing::debug!(
4367 "No client credentials found, but this call does not require authentication."
4368 );
4369 } else {
4370 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
4371 }
4372 }
4373
4374 local_var_req_builder = local_var_req_builder.json(&p_body_viewer_user_onboarding_completed);
4375
4376 let local_var_req = local_var_req_builder.build()?;
4377 let local_var_resp = local_var_client.execute(local_var_req).await?;
4378
4379 let local_var_status = local_var_resp.status();
4380 let local_var_raw_content_type = local_var_resp
4381 .headers()
4382 .get("content-type")
4383 .and_then(|v| v.to_str().ok())
4384 .unwrap_or("application/octet-stream")
4385 .to_string();
4386 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
4387
4388 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4389 let local_var_content = local_var_resp.text().await?;
4390 match local_var_content_type {
4391 ContentType::Json => serde_path_to_error::deserialize(
4392 &mut serde_json::Deserializer::from_str(&local_var_content),
4393 )
4394 .map_err(Error::from),
4395 ContentType::Text => Err(Error::InvalidContentType {
4396 content_type: local_var_raw_content_type,
4397 return_type: "models::ViewerUserOnboardingCompleted",
4398 }),
4399 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
4400 content_type: unknown_type,
4401 return_type: "models::ViewerUserOnboardingCompleted",
4402 }),
4403 }
4404 } else {
4405 let local_var_retry_delay =
4406 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
4407 let local_var_content = local_var_resp.text().await?;
4408 let local_var_entity: Option<PutViewerUserOnboardingCompletedError> =
4409 serde_json::from_str(&local_var_content).ok();
4410 let local_var_error = ResponseContent {
4411 status: local_var_status,
4412 content: local_var_content,
4413 entity: local_var_entity,
4414 retry_delay: local_var_retry_delay,
4415 };
4416 Err(Error::ResponseError(local_var_error))
4417 }
4418}
4419
4420pub async fn put_viewer_user_onboarding_completed(
4422 configuration: &configuration::Configuration,
4423 viewer_user_onboarding_completed: Option<crate::models::ViewerUserOnboardingCompleted>,
4424) -> Result<models::ViewerUserOnboardingCompleted, Error<PutViewerUserOnboardingCompletedError>> {
4425 let mut backoff = configuration.backoff.clone();
4426 let mut refreshed_credentials = false;
4427 let method = reqwest::Method::PUT;
4428 loop {
4429 let result = put_viewer_user_onboarding_completed_inner(
4430 configuration,
4431 &mut backoff,
4432 viewer_user_onboarding_completed.clone(),
4433 )
4434 .await;
4435
4436 match result {
4437 Ok(result) => return Ok(result),
4438 Err(Error::ResponseError(response)) => {
4439 if !refreshed_credentials
4440 && matches!(
4441 response.status,
4442 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
4443 )
4444 {
4445 configuration.qcs_config.refresh().await?;
4446 refreshed_credentials = true;
4447 continue;
4448 } else if let Some(duration) = response.retry_delay {
4449 tokio::time::sleep(duration).await;
4450 continue;
4451 }
4452
4453 return Err(Error::ResponseError(response));
4454 }
4455 Err(Error::Reqwest(error)) => {
4456 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
4457 tokio::time::sleep(duration).await;
4458 continue;
4459 }
4460
4461 return Err(Error::Reqwest(error));
4462 }
4463 Err(Error::Io(error)) => {
4464 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
4465 tokio::time::sleep(duration).await;
4466 continue;
4467 }
4468
4469 return Err(Error::Io(error));
4470 }
4471 Err(error) => return Err(error),
4472 }
4473 }
4474}
4475async fn remove_group_user_inner(
4476 configuration: &configuration::Configuration,
4477 backoff: &mut ExponentialBackoff,
4478 remove_group_user_request: crate::models::RemoveGroupUserRequest,
4479) -> Result<(), Error<RemoveGroupUserError>> {
4480 let local_var_configuration = configuration;
4481 let p_body_remove_group_user_request = remove_group_user_request;
4483
4484 let local_var_client = &local_var_configuration.client;
4485
4486 let local_var_uri_str = format!(
4487 "{}/v1/groups:removeUser",
4488 local_var_configuration.qcs_config.api_url()
4489 );
4490 let mut local_var_req_builder =
4491 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
4492
4493 #[cfg(feature = "tracing")]
4494 {
4495 let local_var_do_tracing = local_var_uri_str
4498 .parse::<::url::Url>()
4499 .ok()
4500 .is_none_or(|url| {
4501 configuration
4502 .qcs_config
4503 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
4504 });
4505
4506 if local_var_do_tracing {
4507 ::tracing::debug!(
4508 url=%local_var_uri_str,
4509 method="POST",
4510 "making remove_group_user request",
4511 );
4512 }
4513 }
4514
4515 {
4518 use qcs_api_client_common::configuration::TokenError;
4519
4520 #[allow(
4521 clippy::nonminimal_bool,
4522 clippy::eq_op,
4523 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
4524 )]
4525 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
4526
4527 let token = local_var_configuration
4528 .qcs_config
4529 .get_bearer_access_token()
4530 .await;
4531
4532 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
4533 #[cfg(feature = "tracing")]
4535 tracing::debug!(
4536 "No client credentials found, but this call does not require authentication."
4537 );
4538 } else {
4539 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
4540 }
4541 }
4542
4543 local_var_req_builder = local_var_req_builder.json(&p_body_remove_group_user_request);
4544
4545 let local_var_req = local_var_req_builder.build()?;
4546 let local_var_resp = local_var_client.execute(local_var_req).await?;
4547
4548 let local_var_status = local_var_resp.status();
4549
4550 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4551 Ok(())
4552 } else {
4553 let local_var_retry_delay =
4554 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
4555 let local_var_content = local_var_resp.text().await?;
4556 let local_var_entity: Option<RemoveGroupUserError> =
4557 serde_json::from_str(&local_var_content).ok();
4558 let local_var_error = ResponseContent {
4559 status: local_var_status,
4560 content: local_var_content,
4561 entity: local_var_entity,
4562 retry_delay: local_var_retry_delay,
4563 };
4564 Err(Error::ResponseError(local_var_error))
4565 }
4566}
4567
4568pub async fn remove_group_user(
4570 configuration: &configuration::Configuration,
4571 remove_group_user_request: crate::models::RemoveGroupUserRequest,
4572) -> Result<(), Error<RemoveGroupUserError>> {
4573 let mut backoff = configuration.backoff.clone();
4574 let mut refreshed_credentials = false;
4575 let method = reqwest::Method::POST;
4576 loop {
4577 let result = remove_group_user_inner(
4578 configuration,
4579 &mut backoff,
4580 remove_group_user_request.clone(),
4581 )
4582 .await;
4583
4584 match result {
4585 Ok(result) => return Ok(result),
4586 Err(Error::ResponseError(response)) => {
4587 if !refreshed_credentials
4588 && matches!(
4589 response.status,
4590 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
4591 )
4592 {
4593 configuration.qcs_config.refresh().await?;
4594 refreshed_credentials = true;
4595 continue;
4596 } else if let Some(duration) = response.retry_delay {
4597 tokio::time::sleep(duration).await;
4598 continue;
4599 }
4600
4601 return Err(Error::ResponseError(response));
4602 }
4603 Err(Error::Reqwest(error)) => {
4604 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
4605 tokio::time::sleep(duration).await;
4606 continue;
4607 }
4608
4609 return Err(Error::Reqwest(error));
4610 }
4611 Err(Error::Io(error)) => {
4612 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
4613 tokio::time::sleep(duration).await;
4614 continue;
4615 }
4616
4617 return Err(Error::Io(error));
4618 }
4619 Err(error) => return Err(error),
4620 }
4621 }
4622}
4623async fn update_viewer_user_profile_inner(
4624 configuration: &configuration::Configuration,
4625 backoff: &mut ExponentialBackoff,
4626 update_viewer_user_profile_request: crate::models::UpdateViewerUserProfileRequest,
4627) -> Result<models::User, Error<UpdateViewerUserProfileError>> {
4628 let local_var_configuration = configuration;
4629 let p_body_update_viewer_user_profile_request = update_viewer_user_profile_request;
4631
4632 let local_var_client = &local_var_configuration.client;
4633
4634 let local_var_uri_str = format!(
4635 "{}/v1/viewer/userProfile",
4636 local_var_configuration.qcs_config.api_url()
4637 );
4638 let mut local_var_req_builder =
4639 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
4640
4641 #[cfg(feature = "tracing")]
4642 {
4643 let local_var_do_tracing = local_var_uri_str
4646 .parse::<::url::Url>()
4647 .ok()
4648 .is_none_or(|url| {
4649 configuration
4650 .qcs_config
4651 .should_trace(&::urlpattern::UrlPatternMatchInput::Url(url))
4652 });
4653
4654 if local_var_do_tracing {
4655 ::tracing::debug!(
4656 url=%local_var_uri_str,
4657 method="PUT",
4658 "making update_viewer_user_profile request",
4659 );
4660 }
4661 }
4662
4663 {
4666 use qcs_api_client_common::configuration::TokenError;
4667
4668 #[allow(
4669 clippy::nonminimal_bool,
4670 clippy::eq_op,
4671 reason = "Logic must be done at runtime since it cannot be handled by the mustache template engine."
4672 )]
4673 let is_jwt_bearer_optional: bool = false || "JWTBearer" == "JWTBearerOptional";
4674
4675 let token = local_var_configuration
4676 .qcs_config
4677 .get_bearer_access_token()
4678 .await;
4679
4680 if is_jwt_bearer_optional && matches!(token, Err(TokenError::NoCredentials)) {
4681 #[cfg(feature = "tracing")]
4683 tracing::debug!(
4684 "No client credentials found, but this call does not require authentication."
4685 );
4686 } else {
4687 local_var_req_builder = local_var_req_builder.bearer_auth(token?.secret());
4688 }
4689 }
4690
4691 local_var_req_builder = local_var_req_builder.json(&p_body_update_viewer_user_profile_request);
4692
4693 let local_var_req = local_var_req_builder.build()?;
4694 let local_var_resp = local_var_client.execute(local_var_req).await?;
4695
4696 let local_var_status = local_var_resp.status();
4697 let local_var_raw_content_type = local_var_resp
4698 .headers()
4699 .get("content-type")
4700 .and_then(|v| v.to_str().ok())
4701 .unwrap_or("application/octet-stream")
4702 .to_string();
4703 let local_var_content_type = super::ContentType::from(local_var_raw_content_type.as_str());
4704
4705 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4706 let local_var_content = local_var_resp.text().await?;
4707 match local_var_content_type {
4708 ContentType::Json => serde_path_to_error::deserialize(
4709 &mut serde_json::Deserializer::from_str(&local_var_content),
4710 )
4711 .map_err(Error::from),
4712 ContentType::Text => Err(Error::InvalidContentType {
4713 content_type: local_var_raw_content_type,
4714 return_type: "models::User",
4715 }),
4716 ContentType::Unsupported(unknown_type) => Err(Error::InvalidContentType {
4717 content_type: unknown_type,
4718 return_type: "models::User",
4719 }),
4720 }
4721 } else {
4722 let local_var_retry_delay =
4723 duration_from_response(local_var_resp.status(), local_var_resp.headers(), backoff);
4724 let local_var_content = local_var_resp.text().await?;
4725 let local_var_entity: Option<UpdateViewerUserProfileError> =
4726 serde_json::from_str(&local_var_content).ok();
4727 let local_var_error = ResponseContent {
4728 status: local_var_status,
4729 content: local_var_content,
4730 entity: local_var_entity,
4731 retry_delay: local_var_retry_delay,
4732 };
4733 Err(Error::ResponseError(local_var_error))
4734 }
4735}
4736
4737pub async fn update_viewer_user_profile(
4739 configuration: &configuration::Configuration,
4740 update_viewer_user_profile_request: crate::models::UpdateViewerUserProfileRequest,
4741) -> Result<models::User, Error<UpdateViewerUserProfileError>> {
4742 let mut backoff = configuration.backoff.clone();
4743 let mut refreshed_credentials = false;
4744 let method = reqwest::Method::PUT;
4745 loop {
4746 let result = update_viewer_user_profile_inner(
4747 configuration,
4748 &mut backoff,
4749 update_viewer_user_profile_request.clone(),
4750 )
4751 .await;
4752
4753 match result {
4754 Ok(result) => return Ok(result),
4755 Err(Error::ResponseError(response)) => {
4756 if !refreshed_credentials
4757 && matches!(
4758 response.status,
4759 StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED
4760 )
4761 {
4762 configuration.qcs_config.refresh().await?;
4763 refreshed_credentials = true;
4764 continue;
4765 } else if let Some(duration) = response.retry_delay {
4766 tokio::time::sleep(duration).await;
4767 continue;
4768 }
4769
4770 return Err(Error::ResponseError(response));
4771 }
4772 Err(Error::Reqwest(error)) => {
4773 if let Some(duration) = duration_from_reqwest_error(&method, &error, &mut backoff) {
4774 tokio::time::sleep(duration).await;
4775 continue;
4776 }
4777
4778 return Err(Error::Reqwest(error));
4779 }
4780 Err(Error::Io(error)) => {
4781 if let Some(duration) = duration_from_io_error(&method, &error, &mut backoff) {
4782 tokio::time::sleep(duration).await;
4783 continue;
4784 }
4785
4786 return Err(Error::Io(error));
4787 }
4788 Err(error) => return Err(error),
4789 }
4790 }
4791}