// static/js/api/secretsService.js
import { request } from './baseApi.js';
export async function fetchSecrets() {
return await request('/list-secrets');
}
export async function toggleSecretStatus(name, action) {
return await request(`/${action}-secret`, {
method: 'POST',
body: JSON.stringify({ name })
});
}
export async function addSecret(yaml, upsert = false) {
const payload = { yaml };
if (upsert) {
payload.upsert = true;
}
return await request('/add-secret', {
method: 'POST',
body: JSON.stringify(payload)
});
}
export async function removeSecret(name) {
return await request('/remove-secret', {
method: 'POST',
body: JSON.stringify({ name })
});
}
export async function manualRenewCertificate(domain) {
return await request('/renew-certificate', {
method: 'POST',
body: JSON.stringify({ domain })
});
}
export async function updateRotationSettings(secretName, domain, enabled, renewBefore) {
const payload = {
secret_name: secretName,
associated_domain: domain,
rotation_enabled: enabled,
renew_before: `${renewBefore * 24}h`
};
return await request('/update-rotation-settings', {
method: 'POST',
body: JSON.stringify(payload)
});
}
export async function fetchSecretYaml(name) {
return await request(`/get-secret?name=${name}&format=yaml`);
}