mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 19:28:35 +00:00
Make progress on ca cert versioning
This commit is contained in:
@@ -3,6 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { workspaceKeys } from "../workspace/queries";
|
||||
import { caKeys } from "./queries";
|
||||
import {
|
||||
TCertificateAuthority,
|
||||
TCreateCaDTO,
|
||||
@@ -11,10 +12,11 @@ import {
|
||||
TDeleteCaDTO,
|
||||
TImportCaCertificateDTO,
|
||||
TImportCaCertificateResponse,
|
||||
TRenewCaDTO,
|
||||
TRenewCaResponse,
|
||||
TSignIntermediateDTO,
|
||||
TSignIntermediateResponse,
|
||||
TUpdateCaDTO
|
||||
} from "./types";
|
||||
TUpdateCaDTO} from "./types";
|
||||
|
||||
export const useCreateCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
@@ -84,8 +86,10 @@ export const useImportCaCertificate = () => {
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
onSuccess: (_, { caId, projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries(caKeys.getCaCerts(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCert(caId));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -106,3 +110,23 @@ export const useCreateCertificate = () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useRenewCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TRenewCaResponse, {}, TRenewCaDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TRenewCaResponse>(
|
||||
`/api/v1/pki/ca/${body.caId}/renew`,
|
||||
body
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { caId, projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries(caKeys.getCaCert(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCerts(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCsr(caId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCrl(caId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user