mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
refactor(user_roles): implement parent group info based role APIs (#8896)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -2,9 +2,10 @@ use common_utils::events::{ApiEventMetric, ApiEventsType};
|
||||
|
||||
use crate::user_role::{
|
||||
role::{
|
||||
CreateRoleRequest, GetRoleRequest, GroupsAndResources, ListRolesAtEntityLevelRequest,
|
||||
ListRolesRequest, RoleInfoResponseNew, RoleInfoWithGroupsResponse, RoleInfoWithParents,
|
||||
UpdateRoleRequest,
|
||||
CreateRoleRequest, CreateRoleV2Request, GetParentGroupsInfoQueryParams, GetRoleRequest,
|
||||
GroupsAndResources, ListRolesAtEntityLevelRequest, ListRolesQueryParams, ListRolesResponse,
|
||||
ParentGroupInfoRequest, RoleInfoResponseNew, RoleInfoResponseWithParentsGroup,
|
||||
RoleInfoWithGroupsResponse, RoleInfoWithParents, UpdateRoleRequest,
|
||||
},
|
||||
AuthorizationInfoResponse, DeleteUserRoleRequest, ListUsersInEntityRequest,
|
||||
UpdateUserRoleRequest,
|
||||
@ -14,17 +15,22 @@ common_utils::impl_api_event_type!(
|
||||
Miscellaneous,
|
||||
(
|
||||
GetRoleRequest,
|
||||
GetParentGroupsInfoQueryParams,
|
||||
AuthorizationInfoResponse,
|
||||
UpdateUserRoleRequest,
|
||||
DeleteUserRoleRequest,
|
||||
CreateRoleRequest,
|
||||
CreateRoleV2Request,
|
||||
UpdateRoleRequest,
|
||||
ListRolesAtEntityLevelRequest,
|
||||
RoleInfoResponseNew,
|
||||
RoleInfoWithGroupsResponse,
|
||||
ListUsersInEntityRequest,
|
||||
ListRolesRequest,
|
||||
ListRolesQueryParams,
|
||||
GroupsAndResources,
|
||||
RoleInfoWithParents
|
||||
RoleInfoWithParents,
|
||||
ParentGroupInfoRequest,
|
||||
RoleInfoResponseWithParentsGroup,
|
||||
ListRolesResponse
|
||||
)
|
||||
);
|
||||
|
||||
@ -10,6 +10,14 @@ pub struct CreateRoleRequest {
|
||||
pub entity_type: Option<EntityType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct CreateRoleV2Request {
|
||||
pub role_name: String,
|
||||
pub role_scope: RoleScope,
|
||||
pub entity_type: Option<EntityType>,
|
||||
pub parent_groups: Vec<ParentGroupInfoRequest>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct UpdateRoleRequest {
|
||||
pub groups: Option<Vec<PermissionGroup>>,
|
||||
@ -41,8 +49,15 @@ pub struct ParentGroupInfo {
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct ListRolesRequest {
|
||||
pub struct ParentGroupInfoRequest {
|
||||
pub name: ParentGroup,
|
||||
pub scopes: Vec<PermissionScope>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct ListRolesQueryParams {
|
||||
pub entity_type: Option<EntityType>,
|
||||
pub groups: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
@ -54,6 +69,15 @@ pub struct RoleInfoResponseNew {
|
||||
pub scope: RoleScope,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
pub struct RoleInfoResponseWithParentsGroup {
|
||||
pub role_id: String,
|
||||
pub role_name: String,
|
||||
pub entity_type: EntityType,
|
||||
pub parent_groups: Vec<ParentGroupInfo>,
|
||||
pub role_scope: RoleScope,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct GetRoleRequest {
|
||||
pub role_id: String,
|
||||
@ -64,6 +88,11 @@ pub struct ListRolesAtEntityLevelRequest {
|
||||
pub entity_type: EntityType,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct GetParentGroupsInfoQueryParams {
|
||||
pub entity_type: Option<EntityType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub enum RoleCheckType {
|
||||
Invite,
|
||||
@ -81,3 +110,10 @@ pub struct GroupsAndResources {
|
||||
pub groups: Vec<PermissionGroup>,
|
||||
pub resources: Vec<Resource>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum ListRolesResponse {
|
||||
WithGroups(Vec<RoleInfoResponseNew>),
|
||||
WithParentGroups(Vec<RoleInfoResponseWithParentsGroup>),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user