8c5152fca4
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
107 lines
3.2 KiB
C++
107 lines
3.2 KiB
C++
#pragma once
|
|
|
|
// HTTP REST client for sqlite_api /api/datafactory/* endpoints.
|
|
// All calls are blocking; return false on net failure or non-2xx.
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace data_factory {
|
|
|
|
struct Node {
|
|
std::string id;
|
|
std::string kind; // extractor|transformer|database|sink|validator
|
|
std::string name;
|
|
std::string function_id;
|
|
std::string description;
|
|
std::string schedule_cron;
|
|
bool enabled = true;
|
|
std::vector<std::string> tags;
|
|
std::string created_at;
|
|
std::string updated_at;
|
|
};
|
|
|
|
struct Run {
|
|
std::string id;
|
|
std::string node_id;
|
|
std::string started_at;
|
|
std::string finished_at;
|
|
std::string status; // running|success|failed|cancelled
|
|
long long rows_in = 0;
|
|
long long rows_out = 0;
|
|
long long kb_in = 0;
|
|
long long kb_out = 0;
|
|
long long duration_ms = 0;
|
|
std::string trigger;
|
|
std::string error;
|
|
std::string storage_db_id;
|
|
std::string storage_table;
|
|
};
|
|
|
|
struct DatabaseInfo {
|
|
std::string id;
|
|
std::string kind;
|
|
std::string label;
|
|
std::string uri;
|
|
std::string description;
|
|
long long table_count = 0;
|
|
long long size_bytes = 0;
|
|
std::string last_seen_at;
|
|
};
|
|
|
|
struct TableEntry {
|
|
std::string database_id;
|
|
std::string database_label;
|
|
std::string database_kind;
|
|
std::string table_name;
|
|
long long row_count = 0;
|
|
std::string error;
|
|
};
|
|
|
|
struct TablePreview {
|
|
std::string database_id;
|
|
std::string table_name;
|
|
std::vector<std::pair<std::string, std::string>> columns; // (name, type)
|
|
std::vector<std::vector<std::string>> rows;
|
|
long long total_rows = 0;
|
|
long long limit = 100;
|
|
long long offset = 0;
|
|
};
|
|
|
|
// Mirrors dag_engine_ui FnInfo (response shape of GET /api/functions/{id}).
|
|
struct FnInfo {
|
|
std::string id;
|
|
std::string name;
|
|
std::string description;
|
|
std::string signature;
|
|
std::string purity;
|
|
std::string domain;
|
|
std::string lang;
|
|
std::vector<std::string> uses_functions;
|
|
std::vector<std::string> uses_types;
|
|
};
|
|
|
|
bool list_nodes_http(const std::string& api_url, const std::string& kind,
|
|
std::vector<Node>& out);
|
|
|
|
bool list_runs_http(const std::string& api_url, const std::string& node_id,
|
|
int limit, std::vector<Run>& out);
|
|
|
|
bool list_databases_http(const std::string& api_url,
|
|
std::vector<DatabaseInfo>& out);
|
|
|
|
bool list_tables_http(const std::string& api_url,
|
|
std::vector<TableEntry>& out);
|
|
|
|
bool get_function_http(const std::string& api_url,
|
|
const std::string& function_id,
|
|
FnInfo& out);
|
|
|
|
bool get_table_preview_http(const std::string& api_url,
|
|
const std::string& database_id,
|
|
const std::string& table,
|
|
int limit, int offset,
|
|
TablePreview& out);
|
|
|
|
} // namespace data_factory
|