Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 212 additions & 1 deletion src/apis/org_service_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use reqwest;

use super::{configuration, Error};
use crate::apis::ResponseContent;
use crate::models::FetchOrgOrderBy;
use crate::models::{FetchOrgOrderBy, SuccessfulResponse};

/// struct for passing parameters to the method [`add_user_to_org`]
#[derive(Clone, Debug, Default)]
Expand Down Expand Up @@ -174,6 +174,42 @@ pub enum CreateSamlConnectionLinkError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`fetch_saml_sp_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FetchSamlSpMetadataError {
Status401(serde_json::Value),
Status404(serde_json::Value),
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`set_saml_idp_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetSamlIdpMetadataError {
Status401(serde_json::Value),
Status404(serde_json::Value),
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`saml_go_live`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SamlGoLiveError {
Status401(serde_json::Value),
Status404(serde_json::Value),
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`delete_saml_connection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteSamlConnectionError {
Status401(serde_json::Value),
Status404(serde_json::Value),
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`fetch_org`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -550,6 +586,181 @@ pub async fn create_saml_connection_link(
Err(Error::ResponseError(local_var_error))
}
}

pub async fn fetch_saml_sp_metadata(
configuration: &configuration::Configuration,
org_id: String,
) -> Result<crate::models::FetchSamlSpMetadataResponse, Error<FetchSamlSpMetadataError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/api/backend/v1/saml_sp_metadata/{org_id}",
local_var_configuration.base_path,
org_id = crate::apis::urlencode(org_id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent);
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token);
};

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<FetchSamlSpMetadataError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn set_saml_idp_metadata(
configuration: &configuration::Configuration,
set_idp_request: crate::models::SetSamlIdpMetadataRequest,
) -> Result<crate::models::SuccessfulResponse, Error<SetSamlIdpMetadataError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/api/backend/v1/saml_idp_metadata",
local_var_configuration.base_path,
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent);
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token);
};
local_var_req_builder = local_var_req_builder.json(&set_idp_request);

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(SuccessfulResponse::new())
} else {
let local_var_entity: Option<SetSamlIdpMetadataError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn saml_go_live(
configuration: &configuration::Configuration,
org_id: String,
) -> Result<crate::models::SuccessfulResponse, Error<SamlGoLiveError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/api/backend/v1/saml_idp_metadata/go_live/{}",
local_var_configuration.base_path, org_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent);
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token);
};

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(SuccessfulResponse::new())
} else {
let local_var_entity: Option<SamlGoLiveError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn delete_saml_connection(
configuration: &configuration::Configuration,
org_id: String,
) -> Result<crate::models::SuccessfulResponse, Error<DeleteSamlConnectionError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/api/backend/v1/saml_idp_metadata/{}",
local_var_configuration.base_path, org_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent);
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token);
};

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(SuccessfulResponse::new())
} else {
let local_var_entity: Option<DeleteSamlConnectionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn fetch_org(
configuration: &configuration::Configuration,
params: FetchOrgParams,
Expand Down
9 changes: 9 additions & 0 deletions src/models/fetch_saml_sp_metadata_response.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[derive(Clone, Debug, PartialEq, Default, Deserialize)]
pub struct FetchSamlSpMetadataResponse {
#[serde(rename = "entity_id")]
pub entity_id: String,
#[serde(rename = "acs_url")]
pub acs_url: String,
#[serde(rename = "logout_url")]
pub logout_url: String,
}
4 changes: 4 additions & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ pub mod fetch_pending_invites;
pub use self::fetch_pending_invites::FetchPendingInvitesResponse;
pub mod revoke_pending_org_invite_request;
pub use self::revoke_pending_org_invite_request::RevokePendingOrgInviteRequest;
pub mod fetch_saml_sp_metadata_response;
pub use self::fetch_saml_sp_metadata_response::FetchSamlSpMetadataResponse;
pub mod set_saml_idp_metadata_request;
pub use self::set_saml_idp_metadata_request::SetSamlIdpMetadataRequest;
25 changes: 25 additions & 0 deletions src/models/set_saml_idp_metadata_request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct SetSamlIdpMetadataRequest {
#[serde(rename = "org_id")]
pub org_id: String,
#[serde(rename = "idp_entity_id")]
pub idp_entity_id: String,
#[serde(rename = "idp_sso_url")]
pub idp_sso_url: String,
#[serde(rename = "idp_certificate")]
pub idp_certificate: String,
#[serde(rename = "provider")]
pub provider: SamlIdpProvider,
}

#[derive(Clone, Debug, PartialEq, Serialize)]
pub enum SamlIdpProvider {
Google,
Rippling,
OneLogin,
JumpCloud,
Okta,
Azure,
Duo,
Generic,
}
96 changes: 93 additions & 3 deletions src/propelauth/org.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use crate::apis::org_service_api::{
};
use crate::models::{
AddUserToOrgRequest, ChangeUserRoleInOrgRequest, CreateOrgRequest, CreateOrgResponse,
CreateSamlConnectionLinkResponse, FetchOrgResponse, FetchOrgsResponse, InviteUserToOrgRequest,
RemoveUserFromOrgRequest, RevokePendingOrgInviteRequest, SubscribeOrgToRoleMappingRequest,
UpdateOrgRequest, UserPagedResponse,
CreateSamlConnectionLinkResponse, FetchOrgResponse, FetchOrgsResponse,
FetchSamlSpMetadataResponse, InviteUserToOrgRequest, RemoveUserFromOrgRequest,
RevokePendingOrgInviteRequest, SubscribeOrgToRoleMappingRequest, UpdateOrgRequest,
UserPagedResponse,
};
use crate::propelauth::errors::{
CreateOrgError, ErrorsWithNotFound, FetchOrgsByQueryError, FetchUsersInOrgError,
Expand Down Expand Up @@ -379,6 +380,95 @@ impl OrgService<'_> {
})
}

pub async fn fetch_saml_sp_metadata(
&self,
org_id: String,
) -> Result<FetchSamlSpMetadataResponse, ErrorsWithNotFound> {
if !is_valid_id(&org_id) {
return Err(ErrorsWithNotFound::NotFound);
}

crate::apis::org_service_api::fetch_saml_sp_metadata(&self.config, org_id)
.await
.map_err(|err| {
map_autogenerated_error(
err,
ErrorsWithNotFound::UnexpectedException,
|status_code, _| match status_code.as_u16() {
401 => ErrorsWithNotFound::InvalidApiKey,
404 => ErrorsWithNotFound::NotFound,
_ => ErrorsWithNotFound::UnexpectedException,
},
)
})
}

pub async fn set_saml_idp_metadata(
&self,
request: crate::models::SetSamlIdpMetadataRequest,
) -> Result<(), ErrorsWithNotFound> {
if !is_valid_id(&request.org_id) {
return Err(ErrorsWithNotFound::NotFound);
}

crate::apis::org_service_api::set_saml_idp_metadata(&self.config, request)
.await
.map_err(|err| {
map_autogenerated_error(
err,
ErrorsWithNotFound::UnexpectedException,
|status_code, _| match status_code.as_u16() {
401 => ErrorsWithNotFound::InvalidApiKey,
404 => ErrorsWithNotFound::NotFound,
_ => ErrorsWithNotFound::UnexpectedException,
},
)
})?;
Ok(())
}

pub async fn saml_go_live(&self, org_id: String) -> Result<(), ErrorsWithNotFound> {
if !is_valid_id(&org_id) {
return Err(ErrorsWithNotFound::NotFound);
}

crate::apis::org_service_api::saml_go_live(&self.config, org_id)
.await
.map_err(|err| {
map_autogenerated_error(
err,
ErrorsWithNotFound::UnexpectedException,
|status_code, _| match status_code.as_u16() {
401 => ErrorsWithNotFound::InvalidApiKey,
404 => ErrorsWithNotFound::NotFound,
_ => ErrorsWithNotFound::UnexpectedException,
},
)
})?;
Ok(())
}

pub async fn delete_saml_connection(&self, org_id: String) -> Result<(), ErrorsWithNotFound> {
if !is_valid_id(&org_id) {
return Err(ErrorsWithNotFound::NotFound);
}

crate::apis::org_service_api::delete_saml_connection(&self.config, org_id)
.await
.map_err(|err| {
map_autogenerated_error(
err,
ErrorsWithNotFound::UnexpectedException,
|status_code, _| match status_code.as_u16() {
401 => ErrorsWithNotFound::InvalidApiKey,
404 => ErrorsWithNotFound::NotFound,
_ => ErrorsWithNotFound::UnexpectedException,
},
)
})?;
Ok(())
}

pub async fn delete_org(&self, org_id: String) -> Result<(), ErrorsWithNotFound> {
if !is_valid_id(&org_id) {
return Err(ErrorsWithNotFound::NotFound);
Expand Down