Newer
Older
cortex-hub / frontend / src / services / api / agentService.js
import { fetchWithAuth } from './apiClient';

export const getAgents = async () => {
    return await fetchWithAuth(`/agents`);
};

export const getAgentTelemetry = async (id) => {
    return await fetchWithAuth(`/agents/${id}/telemetry`);
};

export const getAgentDependencies = async (id) => {
    return await fetchWithAuth(`/agents/${id}/dependencies`);
};

export const updateAgentStatus = async (id, status) => {
    return await fetchWithAuth(`/agents/${id}/status`, {
        method: 'PATCH',
        body: { status }
    });
};

export const updateAgentConfig = async (id, config) => {
    return await fetchWithAuth(`/agents/${id}/config`, {
        method: 'PATCH',
        body: config
    });
};

export const deployAgent = async (payload) => {
    return await fetchWithAuth(`/agents/deploy`, {
        method: 'POST',
        body: payload
    });
};

export const deleteAgent = async (id) => {
    return await fetchWithAuth(`/agents/${id}`, {
        method: 'DELETE'
    });
};

export const getAgentTriggers = async (id) => {
    return await fetchWithAuth(`/agents/${id}/triggers`);
};

export const createAgentTrigger = async (id, triggerPayload) => {
    return await fetchWithAuth(`/agents/${id}/triggers`, {
        method: 'POST',
        body: triggerPayload
    });
};

export const deleteAgentTrigger = async (triggerId) => {
    return await fetchWithAuth(`/agents/triggers/${triggerId}`, {
        method: 'DELETE'
    });
};