mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 10:18:16 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
|
|
import { apiRequest } from "@app/config/request";
|
|
|
|
import { TSshCertificateTemplate } from "../sshCertificateTemplates/types";
|
|
import { TSshCertificateAuthority } from "./types";
|
|
|
|
export const sshCaKeys = {
|
|
getSshCaById: (caId: string) => [{ caId }, "ssh-ca"],
|
|
getSshCaCertTemplates: (caId: string) => [{ caId }, "ssh-ca-cert-templates"]
|
|
};
|
|
|
|
export const useGetSshCaById = (caId: string) => {
|
|
return useQuery({
|
|
queryKey: sshCaKeys.getSshCaById(caId),
|
|
queryFn: async () => {
|
|
const {
|
|
data: { ca }
|
|
} = await apiRequest.get<{ ca: TSshCertificateAuthority }>(`/api/v1/ssh/ca/${caId}`);
|
|
return ca;
|
|
},
|
|
enabled: Boolean(caId)
|
|
});
|
|
};
|
|
|
|
export const useGetSshCaCertTemplates = (caId: string) => {
|
|
return useQuery({
|
|
queryKey: sshCaKeys.getSshCaCertTemplates(caId),
|
|
queryFn: async () => {
|
|
const { data } = await apiRequest.get<{
|
|
certificateTemplates: TSshCertificateTemplate[];
|
|
}>(`/api/v1/ssh/ca/${caId}/certificate-templates`);
|
|
return data;
|
|
},
|
|
enabled: Boolean(caId)
|
|
});
|
|
};
|