Skip to content

Commit e83ad7a

Browse files
authored
New apis (#82)
* new-apis * update mfa errors * version bump
1 parent 65dbaf5 commit e83ad7a

24 files changed

+1229
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "propelauth"
3-
version = "0.23.3"
3+
version = "0.23.4"
44
authors = ["support@propelauth.com"]
55
description = "A Rust crate for managing authentication and authorization with support for multi-tenant / B2B products, powered by PropelAuth"
66
keywords = ["authentication", "auth", "authorization", "b2b", "tenant"]

src/apis/api_key_service_api.rs

Lines changed: 169 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)]
3545
pub 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)]
4353
pub 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+
82116
pub 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+
}

src/apis/employee_service_api.rs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* propelauth
3+
*
4+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5+
*
6+
* The version of the OpenAPI document: 0.1.0
7+
*
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use reqwest;
12+
13+
use super::{configuration, Error};
14+
use crate::propelauth::auth::AUTH_HOSTNAME_HEADER;
15+
use crate::apis::ResponseContent;
16+
17+
/// struct for passing parameters to the method [`fetch_employee_by_id`]
18+
#[derive(Clone, Debug, Default)]
19+
pub struct FetchEmployeeByIdParams {
20+
pub employee_id: String,
21+
}
22+
23+
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
24+
pub struct Employee {
25+
#[serde(rename = "email")]
26+
pub email: String,
27+
}
28+
29+
/// struct for typed errors of method [`fetch_employee_by_id`]
30+
#[derive(Debug, Clone, Serialize, Deserialize)]
31+
#[serde(untagged)]
32+
pub enum FetchEmployeeByIdError {
33+
Status401(serde_json::Value),
34+
Status404(serde_json::Value),
35+
UnknownValue(serde_json::Value),
36+
}
37+
38+
39+
pub async fn fetch_employee_by_id(
40+
configuration: &configuration::Configuration,
41+
params: FetchEmployeeByIdParams,
42+
) -> Result<Employee, Error<FetchEmployeeByIdError>> {
43+
let local_var_configuration = configuration;
44+
45+
// unbox the parameters
46+
let employee_id = params.employee_id;
47+
48+
let local_var_client = &local_var_configuration.client;
49+
50+
let local_var_uri_str = format!(
51+
"{}/api/backend/v1/employee/{employee_id}",
52+
local_var_configuration.base_path,
53+
employee_id = crate::apis::urlencode(employee_id)
54+
);
55+
let mut local_var_req_builder =
56+
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
57+
58+
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
59+
local_var_req_builder =
60+
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
61+
}
62+
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
63+
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
64+
};
65+
local_var_req_builder = local_var_req_builder.header(
66+
AUTH_HOSTNAME_HEADER,
67+
local_var_configuration.auth_hostname.to_owned(),
68+
);
69+
70+
let local_var_req = local_var_req_builder.build()?;
71+
let local_var_resp = local_var_client.execute(local_var_req).await?;
72+
73+
let local_var_status = local_var_resp.status();
74+
let local_var_content = local_var_resp.text().await?;
75+
76+
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
77+
serde_json::from_str(&local_var_content).map_err(Error::from)
78+
} else {
79+
let local_var_entity: Option<FetchEmployeeByIdError> =
80+
serde_json::from_str(&local_var_content).ok();
81+
let local_var_error: crate::apis::ResponseContent<FetchEmployeeByIdError> = ResponseContent {
82+
status: local_var_status,
83+
content: local_var_content,
84+
entity: local_var_entity,
85+
};
86+
Err(Error::ResponseError(local_var_error))
87+
}
88+
}
89+

0 commit comments

Comments
 (0)