qcs_api_client_openapi/apis/
account_api.rs

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