mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 19:16:22 +00:00
Merge pull request #2589 from scott-ray-wilson/entra-group-role-mapping
Feature: SCIM Group to Organization Role Mapping
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export * from "./mutations";
|
||||
export * from "./queries";
|
||||
export * from "./types";
|
||||
@@ -0,0 +1,19 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { externalGroupOrgRoleMappingKeys } from "@app/hooks/api/externalGroupOrgRoleMappings/queries";
|
||||
import { TSyncExternalGroupOrgRoleMappingsDTO } from "@app/hooks/api/externalGroupOrgRoleMappings/types";
|
||||
|
||||
export const useUpdateExternalGroupOrgRoleMappings = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (payload: TSyncExternalGroupOrgRoleMappingsDTO) => {
|
||||
const { data } = await apiRequest.put("/api/v1/external-group-mappings", payload);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(externalGroupOrgRoleMappingKeys.list());
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TExternalGroupOrgRoleMappingList } from "@app/hooks/api/externalGroupOrgRoleMappings/types";
|
||||
|
||||
export const externalGroupOrgRoleMappingKeys = {
|
||||
all: ["external-group-org-role-mapping"] as const,
|
||||
list: () => [...externalGroupOrgRoleMappingKeys.all, "list"] as const
|
||||
};
|
||||
|
||||
export const useGetExternalGroupOrgRoleMappings = (
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TExternalGroupOrgRoleMappingList,
|
||||
unknown,
|
||||
TExternalGroupOrgRoleMappingList,
|
||||
ReturnType<typeof externalGroupOrgRoleMappingKeys.list>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: externalGroupOrgRoleMappingKeys.list(),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<TExternalGroupOrgRoleMappingList>(
|
||||
"/api/v1/external-group-mappings"
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
export type TSyncExternalGroupOrgRoleMappingsDTO = {
|
||||
mappings: {
|
||||
groupName: string;
|
||||
roleSlug: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type TExternalGroupOrgRoleMapping = {
|
||||
id: string;
|
||||
groupName: string;
|
||||
role: string;
|
||||
roleId: string;
|
||||
orgId: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type TExternalGroupOrgRoleMappingList = TExternalGroupOrgRoleMapping[];
|
||||
Reference in New Issue
Block a user