@@ -30,6 +30,16 @@ pub struct CreateApiKeyParams {
3030 pub org_id : Option < String > ,
3131}
3232
33+ /// struct for passing parameters to the method [`import_api_key`]
34+ #[ derive( Clone , Debug , Default , Serialize ) ]
35+ pub struct ImportApiKeyParams {
36+ pub imported_api_key : String ,
37+ pub expires_at_seconds : Option < i64 > ,
38+ pub metadata : Option < serde_json:: Value > ,
39+ pub user_id : Option < String > ,
40+ pub org_id : Option < String > ,
41+ }
42+
3343/// struct for passing parameters to the method [`update_api_key`]
3444#[ derive( Clone , Debug , Default , Serialize ) ]
3545pub struct UpdateApiKeyParams {
@@ -38,12 +48,21 @@ pub struct UpdateApiKeyParams {
3848 pub set_to_never_expire : Option < bool > ,
3949}
4050
41- /// struct for passing parameters to the method [`validate_api_key`]
51+ /// struct for passing parameters to the method [`validate_api_key`] and [`validate_imported_api_key`]
4252#[ derive( Clone , Debug , Default , Serialize ) ]
4353pub struct ValidateApiKeyParams {
4454 pub api_key_token : String ,
4555}
4656
57+ /// struct for passing parameters to the method [`fetch_api_key_usage`]
58+ #[ derive( Clone , Debug , Default , Serialize ) ]
59+ pub struct FetchApiKeyUsageParams {
60+ pub date : String ,
61+ pub user_id : Option < String > ,
62+ pub org_id : Option < String > ,
63+ pub api_key_id : Option < String > ,
64+ }
65+
4766// struct for typed errors on the api keys service
4867#[ derive( Debug , Clone , Deserialize ) ]
4968#[ serde( untagged) ]
@@ -79,6 +98,21 @@ pub enum ApiKeyValidationErrorResponse {
7998 } ,
8099}
81100
101+ #[ derive( Debug , Clone , Deserialize ) ]
102+ #[ serde( untagged) ]
103+ pub enum FetchApiKeyUsageError {
104+ InvalidIntegrationAPIKey ,
105+ RateLimited {
106+ wait_seconds : f64 ,
107+ user_facing_error : String ,
108+ } ,
109+ PropelAuthRateLimit ,
110+ NotFound ,
111+ UnknownValue ( serde_json:: Value ) ,
112+ UnknownError ,
113+ UnexpectedExceptionWithSDK ,
114+ }
115+
82116pub async fn fetch_current_api_keys (
83117 configuration : & configuration:: Configuration ,
84118 params : ApiKeyQueryParams ,
@@ -404,3 +438,137 @@ pub async fn validate_api_key(
404438 Err ( Error :: ResponseError ( error) )
405439 }
406440}
441+
442+ pub async fn fetch_api_key_usage (
443+ configuration : & configuration:: Configuration ,
444+ params : FetchApiKeyUsageParams ,
445+ ) -> Result < crate :: models:: FetchApiKeyUsageResponse , Error < FetchApiKeyUsageError > > {
446+ let client = & configuration. client ;
447+
448+ let date = params. date ;
449+ let uri = format ! (
450+ "{}/api/backend/v1/end_user_api_keys/usage" ,
451+ configuration. base_path
452+ ) ;
453+ let mut req_builder = client. request ( reqwest:: Method :: GET , uri. as_str ( ) ) ;
454+
455+ // assemble the query parameters
456+ req_builder = req_builder. query ( & [ ( "date" , & date. to_string ( ) ) ] ) ;
457+ if let Some ( ref user_id) = params. user_id {
458+ req_builder = req_builder. query ( & [ ( "user_id" , user_id) ] ) ;
459+ }
460+ if let Some ( ref org_id) = params. org_id {
461+ req_builder = req_builder. query ( & [ ( "org_id" , org_id) ] ) ;
462+ }
463+ if let Some ( ref api_key_id) = params. api_key_id {
464+ req_builder = req_builder. query ( & [ ( "api_key_id" , api_key_id) ] ) ;
465+ }
466+
467+ if let Some ( ref user_agent) = configuration. user_agent {
468+ req_builder = req_builder. header ( reqwest:: header:: USER_AGENT , user_agent. clone ( ) ) ;
469+ }
470+ if let Some ( ref bearer_token) = configuration. bearer_access_token {
471+ req_builder = req_builder. bearer_auth ( bearer_token. to_owned ( ) ) ;
472+ }
473+ req_builder = req_builder. header ( AUTH_HOSTNAME_HEADER , configuration. auth_hostname . to_owned ( ) ) ;
474+
475+ let req = req_builder. build ( ) ?;
476+ let resp = client. execute ( req) . await ?;
477+
478+ let status = resp. status ( ) ;
479+ let content = resp. text ( ) . await ?;
480+
481+ if !status. is_client_error ( ) && !status. is_server_error ( ) {
482+ serde_json:: from_str ( & content) . map_err ( Error :: from)
483+ } else {
484+ let entity: Option < FetchApiKeyUsageError > = serde_json:: from_str ( & content) . ok ( ) ;
485+ let error: ResponseContent < FetchApiKeyUsageError > = ResponseContent {
486+ status,
487+ content,
488+ entity,
489+ } ;
490+ Err ( Error :: ResponseError ( error) )
491+ }
492+ }
493+
494+ pub async fn import_api_key (
495+ configuration : & configuration:: Configuration ,
496+ params : ImportApiKeyParams ,
497+ ) -> Result < crate :: models:: ImportApiKeyResponse , Error < ApiKeyError > > {
498+ let client = & configuration. client ;
499+
500+ let uri = format ! (
501+ "{}/api/backend/v1/end_user_api_keys/import" ,
502+ configuration. base_path
503+ ) ;
504+ let mut req_builder = client. request ( reqwest:: Method :: POST , uri. as_str ( ) ) ;
505+
506+ if let Some ( ref user_agent) = configuration. user_agent {
507+ req_builder = req_builder. header ( reqwest:: header:: USER_AGENT , user_agent. clone ( ) ) ;
508+ }
509+ if let Some ( ref bearer_token) = configuration. bearer_access_token {
510+ req_builder = req_builder. bearer_auth ( bearer_token. to_owned ( ) ) ;
511+ }
512+ req_builder = req_builder. header ( AUTH_HOSTNAME_HEADER , configuration. auth_hostname . to_owned ( ) ) ;
513+
514+ req_builder = req_builder. json ( & params) ;
515+
516+ let req = req_builder. build ( ) ?;
517+ let resp = client. execute ( req) . await ?;
518+
519+ let status = resp. status ( ) ;
520+ let content = resp. text ( ) . await ?;
521+
522+ if !status. is_client_error ( ) && !status. is_server_error ( ) {
523+ serde_json:: from_str ( & content) . map_err ( Error :: from)
524+ } else {
525+ let entity: Option < ApiKeyError > = serde_json:: from_str ( & content) . ok ( ) ;
526+ let error = ResponseContent {
527+ status,
528+ content,
529+ entity,
530+ } ;
531+ Err ( Error :: ResponseError ( error) )
532+ }
533+ }
534+
535+ pub async fn validate_imported_api_key (
536+ configuration : & configuration:: Configuration ,
537+ params : ValidateApiKeyParams ,
538+ ) -> Result < crate :: models:: ValidateApiKeyResponse , Error < ApiKeyValidationErrorResponse > > {
539+ let client = & configuration. client ;
540+
541+ let uri = format ! (
542+ "{}/api/backend/v1/end_user_api_keys/validate_imported" ,
543+ configuration. base_path
544+ ) ;
545+ let mut req_builder = client. request ( reqwest:: Method :: POST , uri. as_str ( ) ) ;
546+
547+ if let Some ( ref user_agent) = configuration. user_agent {
548+ req_builder = req_builder. header ( reqwest:: header:: USER_AGENT , user_agent. clone ( ) ) ;
549+ }
550+ if let Some ( ref bearer_token) = configuration. bearer_access_token {
551+ req_builder = req_builder. bearer_auth ( bearer_token. to_owned ( ) ) ;
552+ }
553+ req_builder = req_builder. header ( AUTH_HOSTNAME_HEADER , configuration. auth_hostname . to_owned ( ) ) ;
554+
555+ req_builder = req_builder. json ( & params) ;
556+
557+ let req = req_builder. build ( ) ?;
558+ let resp = client. execute ( req) . await ?;
559+
560+ let status = resp. status ( ) ;
561+ let content = resp. text ( ) . await ?;
562+
563+ if !status. is_client_error ( ) && !status. is_server_error ( ) {
564+ serde_json:: from_str ( & content) . map_err ( Error :: from)
565+ } else {
566+ let entity: Option < ApiKeyValidationErrorResponse > = serde_json:: from_str ( & content) . ok ( ) ;
567+ let error = ResponseContent {
568+ status,
569+ content,
570+ entity,
571+ } ;
572+ Err ( Error :: ResponseError ( error) )
573+ }
574+ }
0 commit comments