Newer
Older
EnvoyControlPlane / static / js / api / clustersService.js
// static/js/api/clustersService.js
import { request } from './baseApi.js';

export async function fetchClusters() {
    return await request('/list-clusters');
}

export async function toggleClusterStatus(name, action) {
    let endpoint = (action === 'remove') ? '/remove-cluster' : `/${action}-cluster`;
    return await request(endpoint, {
        method: 'POST',
        body: JSON.stringify({ name })
    });
}

export async function addCluster(yaml, upsert = false) {
    const payload = { yaml };
    if (upsert) {
        payload.upsert = true;
    }
    return await request('/add-cluster', {
        method: 'POST',
        body: JSON.stringify(payload)
    });
}

export async function fetchClusterYaml(name) {
    return await request(`/get-cluster?name=${name}&format=yaml`);
}