import { schema } from '@kbn/config-schema' ; import { RouteDependencies } from '../../plugin' ; const roleMappingBaseSchema = { rules : schema . recordOf ( schema . string ( ) , schema . string ( ) ) , roleType : schema . string ( ) , groups : schema . arrayOf ( schema . string ( ) ) , allGroups : schema . boolean ( ) , } ; export function registerOrgEnableRoleMappingsRoute ( { router , enterpriseSearchRequestHandler , } ) { router . post ( { path : '/internal/workplace_search/org/role_mappings/enable_role_based_access' , validate : false , } , enterpriseSearchRequestHandler . createRequest ( { path : '/ws/org/role_mappings/enable_role_based_access' , } ) ) ; } export function registerOrgRoleMappingsRoute ( { router , enterpriseSearchRequestHandler , } ) { router . get ( { path : '/internal/workplace_search/org/role_mappings' , validate : false , } , enterpriseSearchRequestHandler . createRequest ( { path : '/ws/org/role_mappings/collection' , } ) ) ; router . post ( { path : '/internal/workplace_search/org/role_mappings' , validate : { body : schema . object ( roleMappingBaseSchema ) , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/ws/org/role_mappings/collection' , } ) ) ; } export function registerOrgRoleMappingRoute ( { router , enterpriseSearchRequestHandler , } ) { router . put ( { path : '/internal/workplace_search/org/role_mappings/{id}' , validate : { body : schema . object ( roleMappingBaseSchema ) , params : schema . object ( { id : schema . string ( ) , } ) , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/ws/org/role_mappings/:id' , } ) ) ; router . delete ( { path : '/internal/workplace_search/org/role_mappings/{id}' , validate : { params : schema . object ( { id : schema . string ( ) , } ) , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/ws/org/role_mappings/:id' , } ) ) ; } export function registerOrgUserRoute ( { router , enterpriseSearchRequestHandler , } ) { router . post ( { path : '/internal/workplace_search/org/single_user_role_mapping' , validate : { body : schema . object ( { roleMapping : schema . object ( { groups : schema . arrayOf ( schema . string ( ) ) , roleType : schema . string ( ) , allGroups : schema . boolean ( ) , id : schema . maybe ( schema . string ( ) ) , } ) , elasticsearchUser : schema . object ( { username : schema . string ( ) , email : schema . string ( ) , } ) , } ) , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/ws/org/role_mappings/upsert_single_user_role_mapping' , } ) ) ; } export const registerRoleMappingsRoutes = ( dependencies ) => { registerOrgEnableRoleMappingsRoute ( dependencies ) ; registerOrgRoleMappingsRoute ( dependencies ) ; registerOrgRoleMappingRoute ( dependencies ) ; registerOrgUserRoute ( dependencies ) ; } ;