1- use crate :: apis:: api_key_service_api:: { ApiKeyError , ApiKeyQueryParams , ApiKeyValidationErrorResponse , CreateApiKeyParams , UpdateApiKeyParams , ValidateApiKeyParams } ;
1+ use crate :: apis:: api_key_service_api:: {
2+ ApiKeyError , ApiKeyQueryParams , ApiKeyValidationErrorResponse , CreateApiKeyParams ,
3+ UpdateApiKeyParams , ValidateApiKeyParams ,
4+ } ;
25use crate :: apis:: configuration:: Configuration ;
3- use crate :: models:: { CreateApiKeyResponse , FetchApiKeyResponse , FetchApiKeysPagedResponse , ValidateApiKeyResponse } ;
4- use crate :: models:: validate_api_key_response:: { ValidateOrgApiKeyResponse , ValidatePersonalApiKeyResponse } ;
6+ use crate :: models:: validate_api_key_response:: {
7+ ValidateOrgApiKeyResponse , ValidatePersonalApiKeyResponse ,
8+ } ;
9+ use crate :: models:: {
10+ CreateApiKeyResponse , FetchApiKeyResponse , FetchApiKeysPagedResponse , ValidateApiKeyResponse ,
11+ } ;
512use crate :: propelauth:: helpers:: map_autogenerated_error;
613
714pub struct ApiKeyService < ' a > {
815 pub ( crate ) config : & ' a Configuration ,
916}
1017
1118impl ApiKeyService < ' _ > {
12- pub async fn fetch_current_api_keys ( & self , params : ApiKeyQueryParams ) -> Result < FetchApiKeysPagedResponse , ApiKeyError > {
19+ pub async fn fetch_current_api_keys (
20+ & self ,
21+ params : ApiKeyQueryParams ,
22+ ) -> Result < FetchApiKeysPagedResponse , ApiKeyError > {
1323 crate :: apis:: api_key_service_api:: fetch_current_api_keys ( & self . config , params)
1424 . await
1525 . map_err ( |err| {
@@ -20,18 +30,22 @@ impl ApiKeyService<'_> {
2030 (
2131 _,
2232 Some ( crate :: apis:: api_key_service_api:: ApiKeyError :: BadRequest (
23- bad_request,
24- ) ) ,
33+ bad_request,
34+ ) ) ,
2535 ) => ApiKeyError :: BadRequest ( bad_request) ,
2636 ( 401 , _) => ApiKeyError :: InvalidIntegrationAPIKey ,
37+ ( 429 , _) => ApiKeyError :: PropelAuthRateLimit ,
2738 ( 404 , _) => ApiKeyError :: NotFound ,
2839 _ => ApiKeyError :: UnexpectedExceptionWithSDK ,
2940 } ,
3041 )
3142 } )
3243 }
3344
34- pub async fn fetch_archived_api_keys ( & self , params : ApiKeyQueryParams ) -> Result < FetchApiKeysPagedResponse , ApiKeyError > {
45+ pub async fn fetch_archived_api_keys (
46+ & self ,
47+ params : ApiKeyQueryParams ,
48+ ) -> Result < FetchApiKeysPagedResponse , ApiKeyError > {
3549 crate :: apis:: api_key_service_api:: fetch_archived_api_keys ( & self . config , params)
3650 . await
3751 . map_err ( |err| {
@@ -42,18 +56,22 @@ impl ApiKeyService<'_> {
4256 (
4357 _,
4458 Some ( crate :: apis:: api_key_service_api:: ApiKeyError :: BadRequest (
45- bad_request,
46- ) ) ,
59+ bad_request,
60+ ) ) ,
4761 ) => ApiKeyError :: BadRequest ( bad_request) ,
4862 ( 401 , _) => ApiKeyError :: InvalidIntegrationAPIKey ,
63+ ( 429 , _) => ApiKeyError :: PropelAuthRateLimit ,
4964 ( 404 , _) => ApiKeyError :: NotFound ,
5065 _ => ApiKeyError :: UnknownError ,
5166 } ,
5267 )
5368 } )
5469 }
5570
56- pub async fn fetch_api_key ( & self , api_key_id : String ) -> Result < FetchApiKeyResponse , ApiKeyError > {
71+ pub async fn fetch_api_key (
72+ & self ,
73+ api_key_id : String ,
74+ ) -> Result < FetchApiKeyResponse , ApiKeyError > {
5775 crate :: apis:: api_key_service_api:: fetch_api_key ( & self . config , api_key_id)
5876 . await
5977 . map_err ( |err| {
@@ -62,14 +80,18 @@ impl ApiKeyService<'_> {
6280 ApiKeyError :: UnexpectedExceptionWithSDK ,
6381 |status_code, _| match status_code. as_u16 ( ) {
6482 401 => ApiKeyError :: InvalidIntegrationAPIKey ,
83+ 429 => ApiKeyError :: PropelAuthRateLimit ,
6584 404 => ApiKeyError :: NotFound ,
6685 _ => ApiKeyError :: UnknownError ,
6786 } ,
6887 )
6988 } )
7089 }
7190
72- pub async fn create_api_key ( & self , params : CreateApiKeyParams ) -> Result < CreateApiKeyResponse , ApiKeyError > {
91+ pub async fn create_api_key (
92+ & self ,
93+ params : CreateApiKeyParams ,
94+ ) -> Result < CreateApiKeyResponse , ApiKeyError > {
7395 crate :: apis:: api_key_service_api:: create_api_key ( & self . config , params)
7496 . await
7597 . map_err ( |err| {
@@ -78,14 +100,19 @@ impl ApiKeyService<'_> {
78100 ApiKeyError :: UnexpectedExceptionWithSDK ,
79101 |status_code, _| match status_code. as_u16 ( ) {
80102 401 => ApiKeyError :: InvalidIntegrationAPIKey ,
103+ 429 => ApiKeyError :: PropelAuthRateLimit ,
81104 404 => ApiKeyError :: NotFound ,
82105 _ => ApiKeyError :: UnknownError ,
83106 } ,
84107 )
85108 } )
86109 }
87110
88- pub async fn update_api_key ( & self , api_key_id : String , params : UpdateApiKeyParams ) -> Result < ( ) , ApiKeyError > {
111+ pub async fn update_api_key (
112+ & self ,
113+ api_key_id : String ,
114+ params : UpdateApiKeyParams ,
115+ ) -> Result < ( ) , ApiKeyError > {
89116 crate :: apis:: api_key_service_api:: update_api_key ( & self . config , api_key_id, params)
90117 . await
91118 . map_err ( |err| {
@@ -94,6 +121,7 @@ impl ApiKeyService<'_> {
94121 ApiKeyError :: UnexpectedExceptionWithSDK ,
95122 |status_code, _| match status_code. as_u16 ( ) {
96123 401 => ApiKeyError :: InvalidIntegrationAPIKey ,
124+ 429 => ApiKeyError :: PropelAuthRateLimit ,
97125 404 => ApiKeyError :: NotFound ,
98126 _ => ApiKeyError :: UnknownError ,
99127 } ,
@@ -112,6 +140,7 @@ impl ApiKeyService<'_> {
112140 ApiKeyError :: UnexpectedExceptionWithSDK ,
113141 |status_code, _| match status_code. as_u16 ( ) {
114142 401 => ApiKeyError :: InvalidIntegrationAPIKey ,
143+ 429 => ApiKeyError :: PropelAuthRateLimit ,
115144 404 => ApiKeyError :: NotFound ,
116145 _ => ApiKeyError :: UnknownError ,
117146 } ,
@@ -127,10 +156,10 @@ impl ApiKeyService<'_> {
127156 ) -> Result < ValidateApiKeyResponse , ApiKeyError > {
128157 if hex:: decode ( & params. api_key_token ) . is_err ( ) {
129158 return Err ( ApiKeyError :: InvalidAPIKey {
130- message : "Invalid API key format." . to_string ( )
131- } ) ;
159+ message : "Invalid API key format." . to_string ( ) ,
160+ } ) ;
132161 }
133-
162+
134163 crate :: apis:: api_key_service_api:: validate_api_key ( & self . config , params)
135164 . await
136165 . map_err ( |err| {
@@ -153,6 +182,7 @@ impl ApiKeyService<'_> {
153182 } ,
154183 None => match status_code. as_u16 ( ) {
155184 401 => ApiKeyError :: InvalidIntegrationAPIKey ,
185+ 429 => ApiKeyError :: PropelAuthRateLimit ,
156186 404 => ApiKeyError :: NotFound ,
157187 _ => ApiKeyError :: UnknownError ,
158188 } ,
@@ -161,7 +191,10 @@ impl ApiKeyService<'_> {
161191 } )
162192 }
163193
164- pub async fn validate_personal_api_key ( & self , params : ValidateApiKeyParams ) -> Result < ValidatePersonalApiKeyResponse , ApiKeyError > {
194+ pub async fn validate_personal_api_key (
195+ & self ,
196+ params : ValidateApiKeyParams ,
197+ ) -> Result < ValidatePersonalApiKeyResponse , ApiKeyError > {
165198 let resp = self . validate_api_key ( params) . await ?;
166199 if resp. user . is_none ( ) || resp. org . is_some ( ) {
167200 return Err ( ApiKeyError :: InvalidPersonalAPIKey ) ;
@@ -173,7 +206,10 @@ impl ApiKeyService<'_> {
173206 } )
174207 }
175208
176- pub async fn validate_org_api_key ( & self , params : ValidateApiKeyParams ) -> Result < ValidateOrgApiKeyResponse , ApiKeyError > {
209+ pub async fn validate_org_api_key (
210+ & self ,
211+ params : ValidateApiKeyParams ,
212+ ) -> Result < ValidateOrgApiKeyResponse , ApiKeyError > {
177213 let resp = self . validate_api_key ( params) . await ?;
178214 if resp. org . is_none ( ) {
179215 return Err ( ApiKeyError :: InvalidOrgAPIKey ) ;
0 commit comments