1use super::types::*;
4use crate::{
5 error::DfnsError,
6 models::generic::DfnsApiClientOptions,
7 utils::{fetch::simple_fetch, url::build_path_and_query, user_action_fetch::user_action_fetch},
8};
9use std::collections::HashMap;
10
11pub struct AuthClient {
12 api_options: DfnsApiClientOptions,
13}
14
15impl AuthClient {
16 pub fn new(api_options: DfnsApiClientOptions) -> Self {
17 Self { api_options }
18 }
19
20 pub async fn activate_application(
21 &self,
22 request: ActivateApplicationRequest,
23 ) -> Result<ActivateApplicationResponse, DfnsError> {
24 let path = build_path_and_query(
25 "/auth/apps/:app_id/activate",
26 &crate::utils::url::PathAndQueryParams {
27 path: {
28 let mut map = HashMap::new();
29 map.insert("app_id".to_string(), request.app_id);
30 map
31 },
32 query: HashMap::new(),
33 },
34 );
35
36 user_action_fetch(
37 &path,
38 crate::utils::fetch::FetchOptions {
39 method: crate::utils::fetch::HttpMethod::PUT,
40 headers: None,
41 body: Some(serde_json::json!({})),
42 api_options: self.api_options.clone(),
43 },
44 )
45 .await
46 }
47
48 pub async fn activate_credential(
49 &self,
50 request: ActivateCredentialRequest,
51 ) -> Result<ActivateCredentialResponse, DfnsError> {
52 let path = build_path_and_query(
53 "/auth/credentials/activate",
54 &crate::utils::url::PathAndQueryParams {
55 path: HashMap::new(),
56 query: HashMap::new(),
57 },
58 );
59
60 user_action_fetch(
61 &path,
62 crate::utils::fetch::FetchOptions {
63 method: crate::utils::fetch::HttpMethod::PUT,
64 headers: None,
65 body: Some(serde_json::to_value(&request.body)?),
66 api_options: self.api_options.clone(),
67 },
68 )
69 .await
70 }
71
72 pub async fn activate_personal_access_token(
73 &self,
74 request: ActivatePersonalAccessTokenRequest,
75 ) -> Result<ActivatePersonalAccessTokenResponse, DfnsError> {
76 let path = build_path_and_query(
77 "/auth/pats/:token_id/activate",
78 &crate::utils::url::PathAndQueryParams {
79 path: {
80 let mut map = HashMap::new();
81 map.insert("token_id".to_string(), request.token_id);
82 map
83 },
84 query: HashMap::new(),
85 },
86 );
87
88 user_action_fetch(
89 &path,
90 crate::utils::fetch::FetchOptions {
91 method: crate::utils::fetch::HttpMethod::PUT,
92 headers: None,
93 body: Some(serde_json::json!({})),
94 api_options: self.api_options.clone(),
95 },
96 )
97 .await
98 }
99
100 pub async fn activate_service_account(
101 &self,
102 request: ActivateServiceAccountRequest,
103 ) -> Result<ActivateServiceAccountResponse, DfnsError> {
104 let path = build_path_and_query(
105 "/auth/service-accounts/:service_account_id/activate",
106 &crate::utils::url::PathAndQueryParams {
107 path: {
108 let mut map = HashMap::new();
109 map.insert("service_account_id".to_string(), request.service_account_id);
110 map
111 },
112 query: HashMap::new(),
113 },
114 );
115
116 user_action_fetch(
117 &path,
118 crate::utils::fetch::FetchOptions {
119 method: crate::utils::fetch::HttpMethod::PUT,
120 headers: None,
121 body: Some(serde_json::json!({})),
122 api_options: self.api_options.clone(),
123 },
124 )
125 .await
126 }
127
128 pub async fn activate_user(
129 &self,
130 request: ActivateUserRequest,
131 ) -> Result<ActivateUserResponse, DfnsError> {
132 let path = build_path_and_query(
133 "/auth/users/:user_id/activate",
134 &crate::utils::url::PathAndQueryParams {
135 path: {
136 let mut map = HashMap::new();
137 map.insert("user_id".to_string(), request.user_id);
138 map
139 },
140 query: HashMap::new(),
141 },
142 );
143
144 user_action_fetch(
145 &path,
146 crate::utils::fetch::FetchOptions {
147 method: crate::utils::fetch::HttpMethod::PUT,
148 headers: None,
149 body: Some(serde_json::json!({})),
150 api_options: self.api_options.clone(),
151 },
152 )
153 .await
154 }
155
156 pub async fn archive_application(
157 &self,
158 request: ArchiveApplicationRequest,
159 ) -> Result<ArchiveApplicationResponse, DfnsError> {
160 let path = build_path_and_query(
161 "/auth/apps/:app_id/archive",
162 &crate::utils::url::PathAndQueryParams {
163 path: {
164 let mut map = HashMap::new();
165 map.insert("app_id".to_string(), request.app_id);
166 map
167 },
168 query: HashMap::new(),
169 },
170 );
171
172 user_action_fetch(
173 &path,
174 crate::utils::fetch::FetchOptions {
175 method: crate::utils::fetch::HttpMethod::PUT,
176 headers: None,
177 body: Some(serde_json::json!({})),
178 api_options: self.api_options.clone(),
179 },
180 )
181 .await
182 }
183
184 pub async fn archive_personal_access_token(
185 &self,
186 request: ArchivePersonalAccessTokenRequest,
187 ) -> Result<ArchivePersonalAccessTokenResponse, DfnsError> {
188 let path = build_path_and_query(
189 "/auth/pats/:token_id/archive",
190 &crate::utils::url::PathAndQueryParams {
191 path: {
192 let mut map = HashMap::new();
193 map.insert("token_id".to_string(), request.token_id);
194 map
195 },
196 query: HashMap::new(),
197 },
198 );
199
200 user_action_fetch(
201 &path,
202 crate::utils::fetch::FetchOptions {
203 method: crate::utils::fetch::HttpMethod::PUT,
204 headers: None,
205 body: Some(serde_json::json!({})),
206 api_options: self.api_options.clone(),
207 },
208 )
209 .await
210 }
211
212 pub async fn archive_service_account(
213 &self,
214 request: ArchiveServiceAccountRequest,
215 ) -> Result<ArchiveServiceAccountResponse, DfnsError> {
216 let path = build_path_and_query(
217 "/auth/service-accounts/:service_account_id/archive",
218 &crate::utils::url::PathAndQueryParams {
219 path: {
220 let mut map = HashMap::new();
221 map.insert("service_account_id".to_string(), request.service_account_id);
222 map
223 },
224 query: HashMap::new(),
225 },
226 );
227
228 user_action_fetch(
229 &path,
230 crate::utils::fetch::FetchOptions {
231 method: crate::utils::fetch::HttpMethod::PUT,
232 headers: None,
233 body: Some(serde_json::json!({})),
234 api_options: self.api_options.clone(),
235 },
236 )
237 .await
238 }
239
240 pub async fn archive_user(
241 &self,
242 request: ArchiveUserRequest,
243 ) -> Result<ArchiveUserResponse, DfnsError> {
244 let path = build_path_and_query(
245 "/auth/users/:user_id/archive",
246 &crate::utils::url::PathAndQueryParams {
247 path: {
248 let mut map = HashMap::new();
249 map.insert("user_id".to_string(), request.user_id);
250 map
251 },
252 query: HashMap::new(),
253 },
254 );
255
256 user_action_fetch(
257 &path,
258 crate::utils::fetch::FetchOptions {
259 method: crate::utils::fetch::HttpMethod::PUT,
260 headers: None,
261 body: Some(serde_json::json!({})),
262 api_options: self.api_options.clone(),
263 },
264 )
265 .await
266 }
267
268 pub async fn create_application(
269 &self,
270 request: CreateApplicationRequest,
271 ) -> Result<CreateApplicationResponse, DfnsError> {
272 let path = build_path_and_query(
273 "/auth/apps",
274 &crate::utils::url::PathAndQueryParams {
275 path: HashMap::new(),
276 query: HashMap::new(),
277 },
278 );
279
280 user_action_fetch(
281 &path,
282 crate::utils::fetch::FetchOptions {
283 method: crate::utils::fetch::HttpMethod::POST,
284 headers: None,
285 body: Some(serde_json::to_value(&request.body)?),
286 api_options: self.api_options.clone(),
287 },
288 )
289 .await
290 }
291
292 pub async fn create_credential(
293 &self,
294 request: CreateCredentialRequest,
295 ) -> Result<CreateCredentialResponse, DfnsError> {
296 let path = build_path_and_query(
297 "/auth/credentials",
298 &crate::utils::url::PathAndQueryParams {
299 path: HashMap::new(),
300 query: HashMap::new(),
301 },
302 );
303
304 user_action_fetch(
305 &path,
306 crate::utils::fetch::FetchOptions {
307 method: crate::utils::fetch::HttpMethod::POST,
308 headers: None,
309 body: Some(serde_json::to_value(&request.body)?),
310 api_options: self.api_options.clone(),
311 },
312 )
313 .await
314 }
315
316 pub async fn create_credential_challenge(
317 &self,
318 request: CreateCredentialChallengeRequest,
319 ) -> Result<CreateCredentialChallengeResponse, DfnsError> {
320 let path = build_path_and_query(
321 "/auth/credentials/init",
322 &crate::utils::url::PathAndQueryParams {
323 path: HashMap::new(),
324 query: HashMap::new(),
325 },
326 );
327
328 simple_fetch(
329 &path,
330 crate::utils::fetch::FetchOptions {
331 method: crate::utils::fetch::HttpMethod::POST,
332 headers: None,
333 body: Some(serde_json::to_value(&request.body)?),
334 api_options: self.api_options.base.clone(),
335 },
336 )
337 .await
338 }
339
340 pub async fn create_credential_challenge_with_code(
341 &self,
342 request: CreateCredentialChallengeWithCodeRequest,
343 ) -> Result<CreateCredentialChallengeWithCodeResponse, DfnsError> {
344 let path = build_path_and_query(
345 "/auth/credentials/code/init",
346 &crate::utils::url::PathAndQueryParams {
347 path: HashMap::new(),
348 query: HashMap::new(),
349 },
350 );
351
352 simple_fetch(
353 &path,
354 crate::utils::fetch::FetchOptions {
355 method: crate::utils::fetch::HttpMethod::POST,
356 headers: None,
357 body: Some(serde_json::to_value(&request.body)?),
358 api_options: self.api_options.base.clone(),
359 },
360 )
361 .await
362 }
363
364 pub async fn create_credential_code(
365 &self,
366 request: CreateCredentialCodeRequest,
367 ) -> Result<CreateCredentialCodeResponse, DfnsError> {
368 let path = build_path_and_query(
369 "/auth/credentials/code",
370 &crate::utils::url::PathAndQueryParams {
371 path: HashMap::new(),
372 query: HashMap::new(),
373 },
374 );
375
376 user_action_fetch(
377 &path,
378 crate::utils::fetch::FetchOptions {
379 method: crate::utils::fetch::HttpMethod::POST,
380 headers: None,
381 body: Some(serde_json::to_value(&request.body)?),
382 api_options: self.api_options.clone(),
383 },
384 )
385 .await
386 }
387
388 pub async fn create_credential_with_code(
389 &self,
390 request: CreateCredentialWithCodeRequest,
391 ) -> Result<CreateCredentialWithCodeResponse, DfnsError> {
392 let path = build_path_and_query(
393 "/auth/credentials/code/verify",
394 &crate::utils::url::PathAndQueryParams {
395 path: HashMap::new(),
396 query: HashMap::new(),
397 },
398 );
399
400 simple_fetch(
401 &path,
402 crate::utils::fetch::FetchOptions {
403 method: crate::utils::fetch::HttpMethod::POST,
404 headers: None,
405 body: Some(serde_json::to_value(&request.body)?),
406 api_options: self.api_options.base.clone(),
407 },
408 )
409 .await
410 }
411
412 pub async fn create_delegated_recovery_challenge(
413 &self,
414 request: CreateDelegatedRecoveryChallengeRequest,
415 ) -> Result<CreateDelegatedRecoveryChallengeResponse, DfnsError> {
416 let path = build_path_and_query(
417 "/auth/recover/user/delegated",
418 &crate::utils::url::PathAndQueryParams {
419 path: HashMap::new(),
420 query: HashMap::new(),
421 },
422 );
423
424 user_action_fetch(
425 &path,
426 crate::utils::fetch::FetchOptions {
427 method: crate::utils::fetch::HttpMethod::POST,
428 headers: None,
429 body: Some(serde_json::to_value(&request.body)?),
430 api_options: self.api_options.clone(),
431 },
432 )
433 .await
434 }
435
436 pub async fn create_delegated_registration_challenge(
437 &self,
438 request: CreateDelegatedRegistrationChallengeRequest,
439 ) -> Result<CreateDelegatedRegistrationChallengeResponse, DfnsError> {
440 let path = build_path_and_query(
441 "/auth/registration/delegated",
442 &crate::utils::url::PathAndQueryParams {
443 path: HashMap::new(),
444 query: HashMap::new(),
445 },
446 );
447
448 user_action_fetch(
449 &path,
450 crate::utils::fetch::FetchOptions {
451 method: crate::utils::fetch::HttpMethod::POST,
452 headers: None,
453 body: Some(serde_json::to_value(&request.body)?),
454 api_options: self.api_options.clone(),
455 },
456 )
457 .await
458 }
459
460 pub async fn create_login_challenge(
461 &self,
462 request: CreateLoginChallengeRequest,
463 ) -> Result<CreateLoginChallengeResponse, DfnsError> {
464 let path = build_path_and_query(
465 "/auth/login/init",
466 &crate::utils::url::PathAndQueryParams {
467 path: HashMap::new(),
468 query: HashMap::new(),
469 },
470 );
471
472 simple_fetch(
473 &path,
474 crate::utils::fetch::FetchOptions {
475 method: crate::utils::fetch::HttpMethod::POST,
476 headers: None,
477 body: Some(serde_json::to_value(&request.body)?),
478 api_options: self.api_options.base.clone(),
479 },
480 )
481 .await
482 }
483
484 pub async fn create_personal_access_token(
485 &self,
486 request: CreatePersonalAccessTokenRequest,
487 ) -> Result<CreatePersonalAccessTokenResponse, DfnsError> {
488 let path = build_path_and_query(
489 "/auth/pats",
490 &crate::utils::url::PathAndQueryParams {
491 path: HashMap::new(),
492 query: HashMap::new(),
493 },
494 );
495
496 user_action_fetch(
497 &path,
498 crate::utils::fetch::FetchOptions {
499 method: crate::utils::fetch::HttpMethod::POST,
500 headers: None,
501 body: Some(serde_json::to_value(&request.body)?),
502 api_options: self.api_options.clone(),
503 },
504 )
505 .await
506 }
507
508 pub async fn create_recovery_challenge(
509 &self,
510 request: CreateRecoveryChallengeRequest,
511 ) -> Result<CreateRecoveryChallengeResponse, DfnsError> {
512 let path = build_path_and_query(
513 "/auth/recover/user/init",
514 &crate::utils::url::PathAndQueryParams {
515 path: HashMap::new(),
516 query: HashMap::new(),
517 },
518 );
519
520 simple_fetch(
521 &path,
522 crate::utils::fetch::FetchOptions {
523 method: crate::utils::fetch::HttpMethod::POST,
524 headers: None,
525 body: Some(serde_json::to_value(&request.body)?),
526 api_options: self.api_options.base.clone(),
527 },
528 )
529 .await
530 }
531
532 pub async fn create_registration_challenge(
533 &self,
534 request: CreateRegistrationChallengeRequest,
535 ) -> Result<CreateRegistrationChallengeResponse, DfnsError> {
536 let path = build_path_and_query(
537 "/auth/registration/init",
538 &crate::utils::url::PathAndQueryParams {
539 path: HashMap::new(),
540 query: HashMap::new(),
541 },
542 );
543
544 simple_fetch(
545 &path,
546 crate::utils::fetch::FetchOptions {
547 method: crate::utils::fetch::HttpMethod::POST,
548 headers: None,
549 body: Some(serde_json::to_value(&request.body)?),
550 api_options: self.api_options.base.clone(),
551 },
552 )
553 .await
554 }
555
556 pub async fn create_service_account(
557 &self,
558 request: CreateServiceAccountRequest,
559 ) -> Result<CreateServiceAccountResponse, DfnsError> {
560 let path = build_path_and_query(
561 "/auth/service-accounts",
562 &crate::utils::url::PathAndQueryParams {
563 path: HashMap::new(),
564 query: HashMap::new(),
565 },
566 );
567
568 user_action_fetch(
569 &path,
570 crate::utils::fetch::FetchOptions {
571 method: crate::utils::fetch::HttpMethod::POST,
572 headers: None,
573 body: Some(serde_json::to_value(&request.body)?),
574 api_options: self.api_options.clone(),
575 },
576 )
577 .await
578 }
579
580 pub async fn create_social_registration_challenge(
581 &self,
582 request: CreateSocialRegistrationChallengeRequest,
583 ) -> Result<CreateSocialRegistrationChallengeResponse, DfnsError> {
584 let path = build_path_and_query(
585 "/auth/registration/social",
586 &crate::utils::url::PathAndQueryParams {
587 path: HashMap::new(),
588 query: HashMap::new(),
589 },
590 );
591
592 simple_fetch(
593 &path,
594 crate::utils::fetch::FetchOptions {
595 method: crate::utils::fetch::HttpMethod::POST,
596 headers: None,
597 body: Some(serde_json::to_value(&request.body)?),
598 api_options: self.api_options.base.clone(),
599 },
600 )
601 .await
602 }
603
604 pub async fn create_user(
605 &self,
606 request: CreateUserRequest,
607 ) -> Result<CreateUserResponse, DfnsError> {
608 let path = build_path_and_query(
609 "/auth/users",
610 &crate::utils::url::PathAndQueryParams {
611 path: HashMap::new(),
612 query: HashMap::new(),
613 },
614 );
615
616 user_action_fetch(
617 &path,
618 crate::utils::fetch::FetchOptions {
619 method: crate::utils::fetch::HttpMethod::POST,
620 headers: None,
621 body: Some(serde_json::to_value(&request.body)?),
622 api_options: self.api_options.clone(),
623 },
624 )
625 .await
626 }
627
628 pub async fn create_user_action_challenge(
629 &self,
630 request: CreateUserActionChallengeRequest,
631 ) -> Result<CreateUserActionChallengeResponse, DfnsError> {
632 let path = build_path_and_query(
633 "/auth/action/init",
634 &crate::utils::url::PathAndQueryParams {
635 path: HashMap::new(),
636 query: HashMap::new(),
637 },
638 );
639
640 simple_fetch(
641 &path,
642 crate::utils::fetch::FetchOptions {
643 method: crate::utils::fetch::HttpMethod::POST,
644 headers: None,
645 body: Some(serde_json::to_value(&request.body)?),
646 api_options: self.api_options.base.clone(),
647 },
648 )
649 .await
650 }
651
652 pub async fn create_user_action_signature(
653 &self,
654 request: CreateUserActionSignatureRequest,
655 ) -> Result<CreateUserActionSignatureResponse, DfnsError> {
656 let path = build_path_and_query(
657 "/auth/action",
658 &crate::utils::url::PathAndQueryParams {
659 path: HashMap::new(),
660 query: HashMap::new(),
661 },
662 );
663
664 simple_fetch(
665 &path,
666 crate::utils::fetch::FetchOptions {
667 method: crate::utils::fetch::HttpMethod::POST,
668 headers: None,
669 body: Some(serde_json::to_value(&request.body)?),
670 api_options: self.api_options.base.clone(),
671 },
672 )
673 .await
674 }
675
676 pub async fn deactivate_application(
677 &self,
678 request: DeactivateApplicationRequest,
679 ) -> Result<DeactivateApplicationResponse, DfnsError> {
680 let path = build_path_and_query(
681 "/auth/apps/:app_id/deactivate",
682 &crate::utils::url::PathAndQueryParams {
683 path: {
684 let mut map = HashMap::new();
685 map.insert("app_id".to_string(), request.app_id);
686 map
687 },
688 query: HashMap::new(),
689 },
690 );
691
692 user_action_fetch(
693 &path,
694 crate::utils::fetch::FetchOptions {
695 method: crate::utils::fetch::HttpMethod::PUT,
696 headers: None,
697 body: Some(serde_json::json!({})),
698 api_options: self.api_options.clone(),
699 },
700 )
701 .await
702 }
703
704 pub async fn deactivate_credential(
705 &self,
706 request: DeactivateCredentialRequest,
707 ) -> Result<DeactivateCredentialResponse, DfnsError> {
708 let path = build_path_and_query(
709 "/auth/credentials/deactivate",
710 &crate::utils::url::PathAndQueryParams {
711 path: HashMap::new(),
712 query: HashMap::new(),
713 },
714 );
715
716 user_action_fetch(
717 &path,
718 crate::utils::fetch::FetchOptions {
719 method: crate::utils::fetch::HttpMethod::PUT,
720 headers: None,
721 body: Some(serde_json::to_value(&request.body)?),
722 api_options: self.api_options.clone(),
723 },
724 )
725 .await
726 }
727
728 pub async fn deactivate_personal_access_token(
729 &self,
730 request: DeactivatePersonalAccessTokenRequest,
731 ) -> Result<DeactivatePersonalAccessTokenResponse, DfnsError> {
732 let path = build_path_and_query(
733 "/auth/pats/:token_id/deactivate",
734 &crate::utils::url::PathAndQueryParams {
735 path: {
736 let mut map = HashMap::new();
737 map.insert("token_id".to_string(), request.token_id);
738 map
739 },
740 query: HashMap::new(),
741 },
742 );
743
744 user_action_fetch(
745 &path,
746 crate::utils::fetch::FetchOptions {
747 method: crate::utils::fetch::HttpMethod::PUT,
748 headers: None,
749 body: Some(serde_json::json!({})),
750 api_options: self.api_options.clone(),
751 },
752 )
753 .await
754 }
755
756 pub async fn deactivate_service_account(
757 &self,
758 request: DeactivateServiceAccountRequest,
759 ) -> Result<DeactivateServiceAccountResponse, DfnsError> {
760 let path = build_path_and_query(
761 "/auth/service-accounts/:service_account_id/deactivate",
762 &crate::utils::url::PathAndQueryParams {
763 path: {
764 let mut map = HashMap::new();
765 map.insert("service_account_id".to_string(), request.service_account_id);
766 map
767 },
768 query: HashMap::new(),
769 },
770 );
771
772 user_action_fetch(
773 &path,
774 crate::utils::fetch::FetchOptions {
775 method: crate::utils::fetch::HttpMethod::PUT,
776 headers: None,
777 body: Some(serde_json::json!({})),
778 api_options: self.api_options.clone(),
779 },
780 )
781 .await
782 }
783
784 pub async fn deactivate_user(
785 &self,
786 request: DeactivateUserRequest,
787 ) -> Result<DeactivateUserResponse, DfnsError> {
788 let path = build_path_and_query(
789 "/auth/users/:user_id/deactivate",
790 &crate::utils::url::PathAndQueryParams {
791 path: {
792 let mut map = HashMap::new();
793 map.insert("user_id".to_string(), request.user_id);
794 map
795 },
796 query: HashMap::new(),
797 },
798 );
799
800 user_action_fetch(
801 &path,
802 crate::utils::fetch::FetchOptions {
803 method: crate::utils::fetch::HttpMethod::PUT,
804 headers: None,
805 body: Some(serde_json::json!({})),
806 api_options: self.api_options.clone(),
807 },
808 )
809 .await
810 }
811
812 pub async fn delegated_login(
813 &self,
814 request: DelegatedLoginRequest,
815 ) -> Result<DelegatedLoginResponse, DfnsError> {
816 let path = build_path_and_query(
817 "/auth/login/delegated",
818 &crate::utils::url::PathAndQueryParams {
819 path: HashMap::new(),
820 query: HashMap::new(),
821 },
822 );
823
824 user_action_fetch(
825 &path,
826 crate::utils::fetch::FetchOptions {
827 method: crate::utils::fetch::HttpMethod::POST,
828 headers: None,
829 body: Some(serde_json::to_value(&request.body)?),
830 api_options: self.api_options.clone(),
831 },
832 )
833 .await
834 }
835
836 pub async fn get_application(
837 &self,
838 request: GetApplicationRequest,
839 ) -> Result<GetApplicationResponse, DfnsError> {
840 let path = build_path_and_query(
841 "/auth/apps/:app_id",
842 &crate::utils::url::PathAndQueryParams {
843 path: {
844 let mut map = HashMap::new();
845 map.insert("app_id".to_string(), request.app_id);
846 map
847 },
848 query: HashMap::new(),
849 },
850 );
851
852 simple_fetch(
853 &path,
854 crate::utils::fetch::FetchOptions {
855 method: crate::utils::fetch::HttpMethod::GET,
856 headers: None,
857 body: None,
858 api_options: self.api_options.base.clone(),
859 },
860 )
861 .await
862 }
863
864 pub async fn get_personal_access_token(
865 &self,
866 request: GetPersonalAccessTokenRequest,
867 ) -> Result<GetPersonalAccessTokenResponse, DfnsError> {
868 let path = build_path_and_query(
869 "/auth/pats/:token_id",
870 &crate::utils::url::PathAndQueryParams {
871 path: {
872 let mut map = HashMap::new();
873 map.insert("token_id".to_string(), request.token_id);
874 map
875 },
876 query: HashMap::new(),
877 },
878 );
879
880 simple_fetch(
881 &path,
882 crate::utils::fetch::FetchOptions {
883 method: crate::utils::fetch::HttpMethod::GET,
884 headers: None,
885 body: None,
886 api_options: self.api_options.base.clone(),
887 },
888 )
889 .await
890 }
891
892 pub async fn get_service_account(
893 &self,
894 request: GetServiceAccountRequest,
895 ) -> Result<GetServiceAccountResponse, DfnsError> {
896 let path = build_path_and_query(
897 "/auth/service-accounts/:service_account_id",
898 &crate::utils::url::PathAndQueryParams {
899 path: {
900 let mut map = HashMap::new();
901 map.insert("service_account_id".to_string(), request.service_account_id);
902 map
903 },
904 query: HashMap::new(),
905 },
906 );
907
908 simple_fetch(
909 &path,
910 crate::utils::fetch::FetchOptions {
911 method: crate::utils::fetch::HttpMethod::GET,
912 headers: None,
913 body: None,
914 api_options: self.api_options.base.clone(),
915 },
916 )
917 .await
918 }
919
920 pub async fn get_user(&self, request: GetUserRequest) -> Result<GetUserResponse, DfnsError> {
921 let path = build_path_and_query(
922 "/auth/users/:user_id",
923 &crate::utils::url::PathAndQueryParams {
924 path: {
925 let mut map = HashMap::new();
926 map.insert("user_id".to_string(), request.user_id);
927 map
928 },
929 query: HashMap::new(),
930 },
931 );
932
933 simple_fetch(
934 &path,
935 crate::utils::fetch::FetchOptions {
936 method: crate::utils::fetch::HttpMethod::GET,
937 headers: None,
938 body: None,
939 api_options: self.api_options.base.clone(),
940 },
941 )
942 .await
943 }
944
945 pub async fn list_applications(&self) -> Result<ListApplicationsResponse, DfnsError> {
946 let path = build_path_and_query(
947 "/auth/apps",
948 &crate::utils::url::PathAndQueryParams {
949 path: HashMap::new(),
950 query: HashMap::new(),
951 },
952 );
953
954 simple_fetch(
955 &path,
956 crate::utils::fetch::FetchOptions {
957 method: crate::utils::fetch::HttpMethod::GET,
958 headers: None,
959 body: None,
960 api_options: self.api_options.base.clone(),
961 },
962 )
963 .await
964 }
965
966 pub async fn list_credentials(&self) -> Result<ListCredentialsResponse, DfnsError> {
967 let path = build_path_and_query(
968 "/auth/credentials",
969 &crate::utils::url::PathAndQueryParams {
970 path: HashMap::new(),
971 query: HashMap::new(),
972 },
973 );
974
975 simple_fetch(
976 &path,
977 crate::utils::fetch::FetchOptions {
978 method: crate::utils::fetch::HttpMethod::GET,
979 headers: None,
980 body: None,
981 api_options: self.api_options.base.clone(),
982 },
983 )
984 .await
985 }
986
987 pub async fn list_personal_access_tokens(
988 &self,
989 ) -> Result<ListPersonalAccessTokensResponse, DfnsError> {
990 let path = build_path_and_query(
991 "/auth/pats",
992 &crate::utils::url::PathAndQueryParams {
993 path: HashMap::new(),
994 query: HashMap::new(),
995 },
996 );
997
998 simple_fetch(
999 &path,
1000 crate::utils::fetch::FetchOptions {
1001 method: crate::utils::fetch::HttpMethod::GET,
1002 headers: None,
1003 body: None,
1004 api_options: self.api_options.base.clone(),
1005 },
1006 )
1007 .await
1008 }
1009
1010 pub async fn list_service_accounts(&self) -> Result<ListServiceAccountsResponse, DfnsError> {
1011 let path = build_path_and_query(
1012 "/auth/service-accounts",
1013 &crate::utils::url::PathAndQueryParams {
1014 path: HashMap::new(),
1015 query: HashMap::new(),
1016 },
1017 );
1018
1019 simple_fetch(
1020 &path,
1021 crate::utils::fetch::FetchOptions {
1022 method: crate::utils::fetch::HttpMethod::GET,
1023 headers: None,
1024 body: None,
1025 api_options: self.api_options.base.clone(),
1026 },
1027 )
1028 .await
1029 }
1030
1031 pub async fn list_users(
1032 &self,
1033 request: Option<ListUsersRequest>,
1034 ) -> Result<ListUsersResponse, DfnsError> {
1035 let path = build_path_and_query(
1036 "/auth/users",
1037 &crate::utils::url::PathAndQueryParams {
1038 path: HashMap::new(),
1039 query: request
1040 .and_then(|r| r.query)
1041 .map(|q| {
1042 let mut map = HashMap::new();
1043 if let Some(kind) = q.kind {
1044 map.insert("kind".to_string(), format!("{:?}", kind));
1045 }
1046 if let Some(limit) = q.limit {
1047 map.insert("limit".to_string(), limit.to_string());
1048 }
1049 if let Some(pagination_token) = q.pagination_token {
1050 map.insert("pagination_token".to_string(), pagination_token);
1051 }
1052 map
1053 })
1054 .unwrap_or_default(),
1055 },
1056 );
1057
1058 simple_fetch(
1059 &path,
1060 crate::utils::fetch::FetchOptions {
1061 method: crate::utils::fetch::HttpMethod::GET,
1062 headers: None,
1063 body: None,
1064 api_options: self.api_options.base.clone(),
1065 },
1066 )
1067 .await
1068 }
1069
1070 pub async fn login(&self, request: LoginRequest) -> Result<LoginResponse, DfnsError> {
1071 let path = build_path_and_query(
1072 "/auth/login",
1073 &crate::utils::url::PathAndQueryParams {
1074 path: HashMap::new(),
1075 query: HashMap::new(),
1076 },
1077 );
1078
1079 simple_fetch(
1080 &path,
1081 crate::utils::fetch::FetchOptions {
1082 method: crate::utils::fetch::HttpMethod::POST,
1083 headers: None,
1084 body: Some(serde_json::to_value(&request.body)?),
1085 api_options: self.api_options.base.clone(),
1086 },
1087 )
1088 .await
1089 }
1090
1091 pub async fn logout(
1092 &self,
1093 request: Option<LogoutRequest>,
1094 ) -> Result<LogoutResponse, DfnsError> {
1095 let path = build_path_and_query(
1096 "/auth/logout",
1097 &crate::utils::url::PathAndQueryParams {
1098 path: HashMap::new(),
1099 query: HashMap::new(),
1100 },
1101 );
1102
1103 simple_fetch(
1104 &path,
1105 crate::utils::fetch::FetchOptions {
1106 method: crate::utils::fetch::HttpMethod::PUT,
1107 headers: None,
1108 body: request.map(|r| serde_json::to_value(&r.body).unwrap()),
1109 api_options: self.api_options.base.clone(),
1110 },
1111 )
1112 .await
1113 }
1114
1115 pub async fn recover(&self, request: RecoverRequest) -> Result<RecoverResponse, DfnsError> {
1116 let path = build_path_and_query(
1117 "/auth/recover/user",
1118 &crate::utils::url::PathAndQueryParams {
1119 path: HashMap::new(),
1120 query: HashMap::new(),
1121 },
1122 );
1123
1124 simple_fetch(
1125 &path,
1126 crate::utils::fetch::FetchOptions {
1127 method: crate::utils::fetch::HttpMethod::POST,
1128 headers: None,
1129 body: Some(serde_json::to_value(&request.body)?),
1130 api_options: self.api_options.base.clone(),
1131 },
1132 )
1133 .await
1134 }
1135
1136 pub async fn recreate_delegated_registration_challenge(
1137 &self,
1138 request: RecreateDelegatedRegistrationChallengeRequest,
1139 ) -> Result<RecreateDelegatedRegistrationChallengeResponse, DfnsError> {
1140 let path = build_path_and_query(
1141 "/auth/registration/delegated/restart",
1142 &crate::utils::url::PathAndQueryParams {
1143 path: HashMap::new(),
1144 query: HashMap::new(),
1145 },
1146 );
1147
1148 user_action_fetch(
1149 &path,
1150 crate::utils::fetch::FetchOptions {
1151 method: crate::utils::fetch::HttpMethod::POST,
1152 headers: None,
1153 body: Some(serde_json::to_value(&request.body)?),
1154 api_options: self.api_options.clone(),
1155 },
1156 )
1157 .await
1158 }
1159
1160 pub async fn register(&self, request: RegisterRequest) -> Result<RegisterResponse, DfnsError> {
1161 let path = build_path_and_query(
1162 "/auth/registration",
1163 &crate::utils::url::PathAndQueryParams {
1164 path: HashMap::new(),
1165 query: HashMap::new(),
1166 },
1167 );
1168
1169 simple_fetch(
1170 &path,
1171 crate::utils::fetch::FetchOptions {
1172 method: crate::utils::fetch::HttpMethod::POST,
1173 headers: None,
1174 body: Some(serde_json::to_value(&request.body)?),
1175 api_options: self.api_options.base.clone(),
1176 },
1177 )
1178 .await
1179 }
1180
1181 pub async fn register_end_user(
1182 &self,
1183 request: RegisterEndUserRequest,
1184 ) -> Result<RegisterEndUserResponse, DfnsError> {
1185 let path = build_path_and_query(
1186 "/auth/registration/enduser",
1187 &crate::utils::url::PathAndQueryParams {
1188 path: HashMap::new(),
1189 query: HashMap::new(),
1190 },
1191 );
1192
1193 simple_fetch(
1194 &path,
1195 crate::utils::fetch::FetchOptions {
1196 method: crate::utils::fetch::HttpMethod::POST,
1197 headers: None,
1198 body: Some(serde_json::to_value(&request.body)?),
1199 api_options: self.api_options.base.clone(),
1200 },
1201 )
1202 .await
1203 }
1204
1205 pub async fn resend_registration_code(
1206 &self,
1207 request: ResendRegistrationCodeRequest,
1208 ) -> Result<ResendRegistrationCodeResponse, DfnsError> {
1209 let path = build_path_and_query(
1210 "/auth/registration/code",
1211 &crate::utils::url::PathAndQueryParams {
1212 path: HashMap::new(),
1213 query: HashMap::new(),
1214 },
1215 );
1216
1217 simple_fetch(
1218 &path,
1219 crate::utils::fetch::FetchOptions {
1220 method: crate::utils::fetch::HttpMethod::PUT,
1221 headers: None,
1222 body: Some(serde_json::to_value(&request.body)?),
1223 api_options: self.api_options.base.clone(),
1224 },
1225 )
1226 .await
1227 }
1228
1229 pub async fn send_login_code(
1230 &self,
1231 request: SendLoginCodeRequest,
1232 ) -> Result<SendLoginCodeResponse, DfnsError> {
1233 let path = build_path_and_query(
1234 "/auth/login/code",
1235 &crate::utils::url::PathAndQueryParams {
1236 path: HashMap::new(),
1237 query: HashMap::new(),
1238 },
1239 );
1240
1241 simple_fetch(
1242 &path,
1243 crate::utils::fetch::FetchOptions {
1244 method: crate::utils::fetch::HttpMethod::POST,
1245 headers: None,
1246 body: Some(serde_json::to_value(&request.body)?),
1247 api_options: self.api_options.base.clone(),
1248 },
1249 )
1250 .await
1251 }
1252
1253 pub async fn send_recovery_code(
1254 &self,
1255 request: SendRecoveryCodeRequest,
1256 ) -> Result<SendRecoveryCodeResponse, DfnsError> {
1257 let path = build_path_and_query(
1258 "/auth/recover/user/code",
1259 &crate::utils::url::PathAndQueryParams {
1260 path: HashMap::new(),
1261 query: HashMap::new(),
1262 },
1263 );
1264
1265 simple_fetch(
1266 &path,
1267 crate::utils::fetch::FetchOptions {
1268 method: crate::utils::fetch::HttpMethod::POST,
1269 headers: None,
1270 body: Some(serde_json::to_value(&request.body)?),
1271 api_options: self.api_options.base.clone(),
1272 },
1273 )
1274 .await
1275 }
1276
1277 pub async fn social_login(
1278 &self,
1279 request: SocialLoginRequest,
1280 ) -> Result<SocialLoginResponse, DfnsError> {
1281 let path = build_path_and_query(
1282 "/auth/login/social",
1283 &crate::utils::url::PathAndQueryParams {
1284 path: HashMap::new(),
1285 query: HashMap::new(),
1286 },
1287 );
1288
1289 simple_fetch(
1290 &path,
1291 crate::utils::fetch::FetchOptions {
1292 method: crate::utils::fetch::HttpMethod::POST,
1293 headers: None,
1294 body: Some(serde_json::to_value(&request.body)?),
1295 api_options: self.api_options.base.clone(),
1296 },
1297 )
1298 .await
1299 }
1300
1301 pub async fn update_application(
1302 &self,
1303 request: UpdateApplicationRequest,
1304 ) -> Result<UpdateApplicationResponse, DfnsError> {
1305 let path = build_path_and_query(
1306 "/auth/apps/:app_id",
1307 &crate::utils::url::PathAndQueryParams {
1308 path: {
1309 let mut map = HashMap::new();
1310 map.insert("app_id".to_string(), request.app_id.clone());
1311 map
1312 },
1313 query: HashMap::new(),
1314 },
1315 );
1316
1317 user_action_fetch(
1318 &path,
1319 crate::utils::fetch::FetchOptions {
1320 method: crate::utils::fetch::HttpMethod::POST,
1321 headers: None,
1322 body: Some(serde_json::to_value(&request.body)?),
1323 api_options: self.api_options.clone(),
1324 },
1325 )
1326 .await
1327 }
1328
1329 pub async fn update_personal_access_token(
1330 &self,
1331 request: UpdatePersonalAccessTokenRequest,
1332 ) -> Result<UpdatePersonalAccessTokenResponse, DfnsError> {
1333 let path = build_path_and_query(
1334 "/auth/pats/:token_id",
1335 &crate::utils::url::PathAndQueryParams {
1336 path: {
1337 let mut map = HashMap::new();
1338 map.insert("token_id".to_string(), request.token_id.clone());
1339 map
1340 },
1341 query: HashMap::new(),
1342 },
1343 );
1344
1345 user_action_fetch(
1346 &path,
1347 crate::utils::fetch::FetchOptions {
1348 method: crate::utils::fetch::HttpMethod::PUT,
1349 headers: None,
1350 body: Some(serde_json::to_value(&request.body)?),
1351 api_options: self.api_options.clone(),
1352 },
1353 )
1354 .await
1355 }
1356
1357 pub async fn update_service_account(
1358 &self,
1359 request: UpdateServiceAccountRequest,
1360 ) -> Result<UpdateServiceAccountResponse, DfnsError> {
1361 let path = build_path_and_query(
1362 "/auth/service-accounts/:service_account_id",
1363 &crate::utils::url::PathAndQueryParams {
1364 path: {
1365 let mut map = HashMap::new();
1366 map.insert(
1367 "service_account_id".to_string(),
1368 request.service_account_id.clone(),
1369 );
1370 map
1371 },
1372 query: HashMap::new(),
1373 },
1374 );
1375
1376 user_action_fetch(
1377 &path,
1378 crate::utils::fetch::FetchOptions {
1379 method: crate::utils::fetch::HttpMethod::PUT,
1380 headers: None,
1381 body: Some(serde_json::to_value(&request.body)?),
1382 api_options: self.api_options.clone(),
1383 },
1384 )
1385 .await
1386 }
1387}