49fc908fb4
- data_http: parsea last_runs[] del /api/dags y guarda d.last_runs_status (max 5, mas reciente primero). - tabs.cpp DAG List: 5 columnas R1..R5 con CellRenderer::Badge + BadgeRule por status (success=verde, failed=rojo, running=amarillo, pending/cancelled=gris, "-"=tenue). - main.cpp: g_refresh_pending. WS auto-trigger refresh /api/dags cuando ve un run con status terminal -> last_runs se actualiza sin pulsar nada. - main + tabs: extern "C" dag_list_request_refresh() para el boton Refresh manual. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
90 lines
2.8 KiB
C++
90 lines
2.8 KiB
C++
#pragma once
|
|
|
|
// Cliente HTTP REST contra apps/dag_engine (Go backend).
|
|
// Endpoints: /api/dags, /api/runs, /api/dags/{name}/run (issue 0095).
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace dag_ui {
|
|
|
|
// --- Modelo de datos (mirror JSON shape de apps/dag_engine) ---
|
|
|
|
struct DagRunRow; // fwd
|
|
|
|
struct DagInfo {
|
|
std::string name;
|
|
std::string description;
|
|
std::vector<std::string> schedule; // cron expressions
|
|
std::vector<std::string> tags;
|
|
std::string type;
|
|
std::string file_path;
|
|
bool valid = false;
|
|
// last_run inlined fields (extracted from nested object on load)
|
|
bool has_last_run = false;
|
|
std::string last_run_id;
|
|
std::string last_run_status;
|
|
std::string last_run_started_at;
|
|
std::string last_run_finished_at;
|
|
// last_runs[] (max 5, most recent first). Empty if no runs yet.
|
|
// Populated from /api/dags `last_runs` array.
|
|
std::vector<std::string> last_runs_status; // parallel: status of each (size <= 5)
|
|
};
|
|
|
|
struct DagRunRow {
|
|
std::string id;
|
|
std::string dag_name;
|
|
std::string dag_path;
|
|
std::string status; // pending|running|success|failed|cancelled
|
|
std::string trigger; // manual|cron|api
|
|
std::string started_at;
|
|
std::string finished_at;
|
|
std::string error;
|
|
};
|
|
|
|
struct DagStepRow {
|
|
std::string id;
|
|
std::string run_id;
|
|
std::string step_name;
|
|
std::string status;
|
|
int exit_code = 0;
|
|
std::string stdout_text;
|
|
std::string stderr_text;
|
|
std::string started_at;
|
|
std::string finished_at;
|
|
long long duration_ms = 0;
|
|
std::string error;
|
|
};
|
|
|
|
struct DagRunDetail {
|
|
DagRunRow run;
|
|
std::vector<DagStepRow> steps;
|
|
};
|
|
|
|
struct DagDetail {
|
|
DagInfo info;
|
|
std::vector<DagRunRow> recent_runs;
|
|
std::string validation_error; // empty if valid
|
|
};
|
|
|
|
// --- API ---
|
|
// api_url: "http://127.0.0.1:8090". Todas las funciones blocking, devuelven
|
|
// false si la red falla o el status no es 2xx. Errores van a stderr.
|
|
|
|
bool list_dags_http(const std::string& api_url, std::vector<DagInfo>& out);
|
|
|
|
bool get_dag_http(const std::string& api_url, const std::string& name,
|
|
DagDetail& out);
|
|
|
|
bool list_runs_http(const std::string& api_url, const std::string& dag_name,
|
|
int limit, std::vector<DagRunRow>& out);
|
|
|
|
bool get_run_http(const std::string& api_url, const std::string& run_id,
|
|
DagRunDetail& out);
|
|
|
|
// Devuelve el run_id en out_run_id si HTTP 202.
|
|
bool trigger_dag_http(const std::string& api_url, const std::string& name,
|
|
std::string& out_run_id, std::string& out_error);
|
|
|
|
} // namespace dag_ui
|