mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 21:40:31 +00:00
misc: partial project kms switch
This commit is contained in:
@@ -1,2 +1,7 @@
|
||||
export { useAddAwsExternalKms, useRemoveExternalKms, useUpdateAwsExternalKms } from "./mutations";
|
||||
export { useGetExternalKmsById, useGetExternalKmsList } from "./queries";
|
||||
export {
|
||||
useAddAwsExternalKms,
|
||||
useRemoveExternalKms,
|
||||
useUpdateAwsExternalKms,
|
||||
useUpdateProjectKms
|
||||
} from "./mutations";
|
||||
export { useGetActiveProjectKms, useGetExternalKmsById, useGetExternalKmsList } from "./queries";
|
||||
|
||||
@@ -126,3 +126,17 @@ export const useRemoveExternalKms = (orgId: string) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateProjectKms = (projectId: string) => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (updatedData: { secretManagerKmsKeyId: string }) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/workspace/${projectId}/kms`, updatedData);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(kmsKeys.getActiveProjectKms(projectId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,7 +6,8 @@ import { Kms, KmsListEntry } from "./types";
|
||||
|
||||
export const kmsKeys = {
|
||||
getExternalKmsList: (orgId: string) => ["get-all-external-kms", { orgId }],
|
||||
getExternalKmsById: (id: string) => ["get-external-kms", { id }]
|
||||
getExternalKmsById: (id: string) => ["get-external-kms", { id }],
|
||||
getActiveProjectKms: (projectId: string) => ["get-active-project-kms", { projectId }]
|
||||
};
|
||||
|
||||
export const useGetExternalKmsList = (orgId: string) => {
|
||||
@@ -33,3 +34,22 @@ export const useGetExternalKmsById = (kmsId: string) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetActiveProjectKms = (projectId: string) => {
|
||||
return useQuery({
|
||||
queryKey: kmsKeys.getActiveProjectKms(projectId),
|
||||
enabled: Boolean(projectId),
|
||||
queryFn: async () => {
|
||||
const {
|
||||
data: { secretManagerKmsKey }
|
||||
} = await apiRequest.get<{
|
||||
secretManagerKmsKey: {
|
||||
id: string;
|
||||
slug: string;
|
||||
isExternal: string;
|
||||
};
|
||||
}>(`/api/v1/workspace/${projectId}/kms`);
|
||||
return secretManagerKmsKey;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user