Class: Melaya::PipelinesAPI
- Inherits:
-
Object
- Object
- Melaya::PipelinesAPI
- Defined in:
- lib/melaya/pipelines.rb
Overview
Pipelines API — overview dashboard, pipeline run listing, traces, and cron-based scheduling.
Maps to:
/api/v1/private/overview/* — dashboard + run listing
/api/v1/private/runs/:id/traces/* — distributed traces
/api/v1/private/pipeline-schedule — cron scheduling
/api/v1/version — server version (public)
Instance Method Summary collapse
-
#build_with_ai(brief) ⇒ Hash
POST /api/v1/private/ai/build-pipeline/sync Generate a pipeline config from a natural-language brief using AI.
-
#cancel_run(name, run_id) ⇒ Hash
DELETE /api/v1/private/pipelines/:name/runs/:run_id Cancel an in-progress pipeline run.
-
#chart_data(params = {}) ⇒ Object
GET /api/v1/private/overview/chart Get chart data for overview dashboard (cost/usage over time).
-
#cost_breakdown(params = {}) ⇒ Object
GET /api/v1/private/overview/cost-breakdown Get cost breakdown by model/provider.
-
#count ⇒ Object
GET /api/v1/private/overview/pipeline-count Count of pipeline runs grouped by status.
-
#create(name:, project:, description: nil, **config) ⇒ Hash
POST /api/v1/private/pipelines Create a new pipeline config.
-
#delete_pipeline(name, project: nil) ⇒ Hash
DELETE /api/v1/private/pipelines/:name Delete a pipeline config.
-
#delete_traces(run_id) ⇒ Hash
DELETE /api/v1/private/runs/:runId/traces Delete all traces (and their spans) for a run by runId.
-
#get(name, project: nil) ⇒ Hash
GET /api/v1/private/pipelines/:name Fetch a single pipeline config by name.
-
#get_schedule(project, pipeline_name) ⇒ Object
GET /api/v1/private/pipeline-schedule/:project/:pipelineName Get schedule status for a pipeline.
-
#initialize(http) ⇒ PipelinesAPI
constructor
A new instance of PipelinesAPI.
-
#instantiate_template(template_id, name:, project:, overrides: nil) ⇒ Hash
POST /api/v1/private/templates/:template_id/instantiate Instantiate a platform template into a new pipeline config.
-
#list(project: nil, pipeline_name: nil, status: nil, limit: nil, offset: nil) ⇒ Object
GET /api/v1/private/overview/pipelines Paginated list of pipeline runs.
-
#list_pipelines ⇒ Object
GET /api/v1/private/pipelines List all pipeline configs accessible to the caller.
-
#list_schedules ⇒ Object
GET /api/v1/private/pipeline-schedule List all pipeline schedules accessible to the caller.
-
#model_prices ⇒ Object
GET /api/v1/private/overview/model-prices Get pricing data for available AI models.
-
#output(name, path, download: false) ⇒ Object
GET /api/v1/private/pipelines/:name/outputs/:path Fetch a specific output artifact.
-
#outputs(name) ⇒ Object
GET /api/v1/private/pipelines/:name/outputs List all output artifacts produced by a pipeline.
-
#overview ⇒ Object
GET /api/v1/private/overview Dashboard overview: usage stats, active strategies, recent runs.
-
#pause_schedule(project, pipeline_name) ⇒ Object
POST /api/v1/private/pipeline-schedule/:project/:pipelineName/pause Pause a pipeline schedule.
-
#preview_code(config) ⇒ Object
POST /api/v1/private/pipelines/preview-code Generate a code preview for a pipeline config without saving it.
-
#recent ⇒ Object
GET /api/v1/private/overview/pipelines/recent Most recent pipeline runs for a dashboard widget.
-
#resume_schedule(project, pipeline_name) ⇒ Object
POST /api/v1/private/pipeline-schedule/:project/:pipelineName/resume Resume a paused pipeline schedule.
-
#run(name, project: nil, execution_target: nil, studio_url: nil, env_overrides: nil) ⇒ Hash
POST /api/v1/private/pipelines/:name/run Enqueue a pipeline run.
-
#run_ids(name) ⇒ Hash
GET /api/v1/private/pipelines/:name/runs List all run IDs for a pipeline.
-
#run_status(name, run_id) ⇒ Hash
GET /api/v1/private/pipelines/:name/runs/:run_id Get the status of a specific pipeline run.
-
#server_version ⇒ Object
GET /api/v1/version (public) Get current server version string.
-
#subagents ⇒ Hash
GET /api/v1/private/pipelines/subagents Fetch the registry of sub-agent definitions available to pipelines.
-
#tools ⇒ Hash
GET /api/v1/private/pipelines/tools Fetch the registry of tools available to pipeline steps.
-
#trace(run_id, trace_id) ⇒ Object
GET /api/v1/private/runs/:runId/traces/:traceId Get a single trace by ID.
-
#trace_stats(run_id, trace_id) ⇒ Object
GET /api/v1/private/runs/:runId/traces/:traceId/stats Get statistics for a specific trace.
-
#traces(run_id, params = {}) ⇒ Hash
GET /api/v1/private/runs/:runId/traces List traces for a run (paginated).
-
#update(name, config:, project: nil) ⇒ Hash
PUT /api/v1/private/pipelines/:name Replace a pipeline's config.
-
#upsert_schedule(project, pipeline_name, cron:, config: nil) ⇒ Object
PUT /api/v1/private/pipeline-schedule/:project/:pipelineName Create or update a pipeline schedule (cron expression + optional config).
Constructor Details
#initialize(http) ⇒ PipelinesAPI
Returns a new instance of PipelinesAPI.
18 19 20 |
# File 'lib/melaya/pipelines.rb', line 18 def initialize(http) @http = http end |
Instance Method Details
#build_with_ai(brief) ⇒ Hash
POST /api/v1/private/ai/build-pipeline/sync Generate a pipeline config from a natural-language brief using AI.
316 317 318 |
# File 'lib/melaya/pipelines.rb', line 316 def build_with_ai(brief) @http.post("/api/v1/private/ai/build-pipeline/sync", brief) end |
#cancel_run(name, run_id) ⇒ Hash
DELETE /api/v1/private/pipelines/:name/runs/:run_id Cancel an in-progress pipeline run.
253 254 255 |
# File 'lib/melaya/pipelines.rb', line 253 def cancel_run(name, run_id) @http.delete("/api/v1/private/pipelines/#{enc(name)}/runs/#{enc(run_id)}") end |
#chart_data(params = {}) ⇒ Object
GET /api/v1/private/overview/chart Get chart data for overview dashboard (cost/usage over time).
38 39 40 |
# File 'lib/melaya/pipelines.rb', line 38 def chart_data(params = {}) @http.get("/api/v1/private/overview/chart", params) end |
#cost_breakdown(params = {}) ⇒ Object
GET /api/v1/private/overview/cost-breakdown Get cost breakdown by model/provider.
44 45 46 |
# File 'lib/melaya/pipelines.rb', line 44 def cost_breakdown(params = {}) @http.get("/api/v1/private/overview/cost-breakdown", params) end |
#count ⇒ Object
GET /api/v1/private/overview/pipeline-count Count of pipeline runs grouped by status.
50 51 52 |
# File 'lib/melaya/pipelines.rb', line 50 def count @http.get("/api/v1/private/overview/pipeline-count") end |
#create(name:, project:, description: nil, **config) ⇒ Hash
POST /api/v1/private/pipelines Create a new pipeline config.
173 174 175 176 177 178 179 180 |
# File 'lib/melaya/pipelines.rb', line 173 def create(name:, project:, description: nil, **config) body = compact( "name" => name, "project" => project, "description" => description ).merge(stringify_keys(config)) @http.post("/api/v1/private/pipelines", body) end |
#delete_pipeline(name, project: nil) ⇒ Hash
DELETE /api/v1/private/pipelines/:name Delete a pipeline config.
208 209 210 211 |
# File 'lib/melaya/pipelines.rb', line 208 def delete_pipeline(name, project: nil) params = compact("project" => project) @http.delete("/api/v1/private/pipelines/#{enc(name)}", params) end |
#delete_traces(run_id) ⇒ Hash
DELETE /api/v1/private/runs/:runId/traces Delete all traces (and their spans) for a run by runId. No request body required — the runId in the path identifies the target.
114 115 116 |
# File 'lib/melaya/pipelines.rb', line 114 def delete_traces(run_id) @http.delete("/api/v1/private/runs/#{enc(run_id)}/traces") end |
#get(name, project: nil) ⇒ Hash
GET /api/v1/private/pipelines/:name Fetch a single pipeline config by name.
187 188 189 190 |
# File 'lib/melaya/pipelines.rb', line 187 def get(name, project: nil) params = compact("project" => project) @http.get("/api/v1/private/pipelines/#{enc(name)}", params) end |
#get_schedule(project, pipeline_name) ⇒ Object
GET /api/v1/private/pipeline-schedule/:project/:pipelineName Get schedule status for a pipeline.
130 131 132 |
# File 'lib/melaya/pipelines.rb', line 130 def get_schedule(project, pipeline_name) @http.get("/api/v1/private/pipeline-schedule/#{enc(project)}/#{enc(pipeline_name)}") end |
#instantiate_template(template_id, name:, project:, overrides: nil) ⇒ Hash
POST /api/v1/private/templates/:template_id/instantiate Instantiate a platform template into a new pipeline config.
307 308 309 310 |
# File 'lib/melaya/pipelines.rb', line 307 def instantiate_template(template_id, name:, project:, overrides: nil) body = compact("name" => name, "project" => project, "overrides" => overrides) @http.post("/api/v1/private/templates/#{enc(template_id)}/instantiate", body) end |
#list(project: nil, pipeline_name: nil, status: nil, limit: nil, offset: nil) ⇒ Object
GET /api/v1/private/overview/pipelines Paginated list of pipeline runs.
61 62 63 64 65 66 |
# File 'lib/melaya/pipelines.rb', line 61 def list(project: nil, pipeline_name: nil, status: nil, limit: nil, offset: nil) @http.get("/api/v1/private/overview/pipelines", compact("project" => project, "pipelineName" => pipeline_name, "status" => status, "limit" => limit, "offset" => offset)) end |
#list_pipelines ⇒ Object
GET /api/v1/private/pipelines List all pipeline configs accessible to the caller. Returns { "pipelines" => [...] }.
162 163 164 |
# File 'lib/melaya/pipelines.rb', line 162 def list_pipelines @http.get("/api/v1/private/pipelines") end |
#list_schedules ⇒ Object
GET /api/v1/private/pipeline-schedule List all pipeline schedules accessible to the caller.
122 123 124 |
# File 'lib/melaya/pipelines.rb', line 122 def list_schedules @http.get("/api/v1/private/pipeline-schedule") end |
#model_prices ⇒ Object
GET /api/v1/private/overview/model-prices Get pricing data for available AI models.
32 33 34 |
# File 'lib/melaya/pipelines.rb', line 32 def model_prices @http.get("/api/v1/private/overview/model-prices") end |
#output(name, path, download: false) ⇒ Object
GET /api/v1/private/pipelines/:name/outputs/:path
Fetch a specific output artifact. Each segment of path is individually
URL-encoded so slashes in segment values are preserved as separators.
272 273 274 275 276 |
# File 'lib/melaya/pipelines.rb', line 272 def output(name, path, download: false) encoded_path = path.to_s.split("/").map { |seg| enc(seg) }.join("/") params = download ? { "download" => 1 } : {} @http.get("/api/v1/private/pipelines/#{enc(name)}/outputs/#{encoded_path}", params) end |
#outputs(name) ⇒ Object
GET /api/v1/private/pipelines/:name/outputs List all output artifacts produced by a pipeline.
261 262 263 |
# File 'lib/melaya/pipelines.rb', line 261 def outputs(name) @http.get("/api/v1/private/pipelines/#{enc(name)}/outputs") end |
#overview ⇒ Object
GET /api/v1/private/overview Dashboard overview: usage stats, active strategies, recent runs.
26 27 28 |
# File 'lib/melaya/pipelines.rb', line 26 def overview @http.get("/api/v1/private/overview") end |
#pause_schedule(project, pipeline_name) ⇒ Object
POST /api/v1/private/pipeline-schedule/:project/:pipelineName/pause Pause a pipeline schedule.
147 148 149 |
# File 'lib/melaya/pipelines.rb', line 147 def pause_schedule(project, pipeline_name) @http.post("/api/v1/private/pipeline-schedule/#{enc(project)}/#{enc(pipeline_name)}/pause") end |
#preview_code(config) ⇒ Object
POST /api/v1/private/pipelines/preview-code Generate a code preview for a pipeline config without saving it.
282 283 284 |
# File 'lib/melaya/pipelines.rb', line 282 def preview_code(config) @http.post("/api/v1/private/pipelines/preview-code", config) end |
#recent ⇒ Object
GET /api/v1/private/overview/pipelines/recent Most recent pipeline runs for a dashboard widget.
70 71 72 |
# File 'lib/melaya/pipelines.rb', line 70 def recent @http.get("/api/v1/private/overview/pipelines/recent") end |
#resume_schedule(project, pipeline_name) ⇒ Object
POST /api/v1/private/pipeline-schedule/:project/:pipelineName/resume Resume a paused pipeline schedule.
153 154 155 |
# File 'lib/melaya/pipelines.rb', line 153 def resume_schedule(project, pipeline_name) @http.post("/api/v1/private/pipeline-schedule/#{enc(project)}/#{enc(pipeline_name)}/resume") end |
#run(name, project: nil, execution_target: nil, studio_url: nil, env_overrides: nil) ⇒ Hash
POST /api/v1/private/pipelines/:name/run Enqueue a pipeline run.
221 222 223 224 225 226 227 228 229 |
# File 'lib/melaya/pipelines.rb', line 221 def run(name, project: nil, execution_target: nil, studio_url: nil, env_overrides: nil) body = compact( "project" => project, "executionTarget" => execution_target, "studio_url" => studio_url, "env_overrides" => env_overrides ) @http.post("/api/v1/private/pipelines/#{enc(name)}/run", body.empty? ? nil : body) end |
#run_ids(name) ⇒ Hash
GET /api/v1/private/pipelines/:name/runs List all run IDs for a pipeline.
235 236 237 |
# File 'lib/melaya/pipelines.rb', line 235 def run_ids(name) @http.get("/api/v1/private/pipelines/#{enc(name)}/runs") end |
#run_status(name, run_id) ⇒ Hash
GET /api/v1/private/pipelines/:name/runs/:run_id Get the status of a specific pipeline run.
244 245 246 |
# File 'lib/melaya/pipelines.rb', line 244 def run_status(name, run_id) @http.get("/api/v1/private/pipelines/#{enc(name)}/runs/#{enc(run_id)}") end |
#server_version ⇒ Object
GET /api/v1/version (public) Get current server version string.
324 325 326 |
# File 'lib/melaya/pipelines.rb', line 324 def server_version @http.get("/api/v1/version") end |
#subagents ⇒ Hash
GET /api/v1/private/pipelines/subagents Fetch the registry of sub-agent definitions available to pipelines.
296 297 298 |
# File 'lib/melaya/pipelines.rb', line 296 def subagents @http.get("/api/v1/private/pipelines/subagents") end |
#tools ⇒ Hash
GET /api/v1/private/pipelines/tools Fetch the registry of tools available to pipeline steps.
289 290 291 |
# File 'lib/melaya/pipelines.rb', line 289 def tools @http.get("/api/v1/private/pipelines/tools") end |
#trace(run_id, trace_id) ⇒ Object
GET /api/v1/private/runs/:runId/traces/:traceId Get a single trace by ID.
98 99 100 |
# File 'lib/melaya/pipelines.rb', line 98 def trace(run_id, trace_id) @http.get("/api/v1/private/runs/#{enc(run_id)}/traces/#{enc(trace_id)}") end |
#trace_stats(run_id, trace_id) ⇒ Object
GET /api/v1/private/runs/:runId/traces/:traceId/stats Get statistics for a specific trace.
104 105 106 |
# File 'lib/melaya/pipelines.rb', line 104 def trace_stats(run_id, trace_id) @http.get("/api/v1/private/runs/#{enc(run_id)}/traces/#{enc(trace_id)}/stats") end |
#traces(run_id, params = {}) ⇒ Hash
GET /api/v1/private/runs/:runId/traces List traces for a run (paginated).
Returns a paginated envelope, NOT a flat array:
{
"data" => {
"list" => Array<Hash>, # trace summaries
"total" => Integer, # total matching traces
"page" => Integer,
"pageSize" => Integer
}
}
92 93 94 |
# File 'lib/melaya/pipelines.rb', line 92 def traces(run_id, params = {}) @http.get("/api/v1/private/runs/#{enc(run_id)}/traces", params) end |
#update(name, config:, project: nil) ⇒ Hash
PUT /api/v1/private/pipelines/:name Replace a pipeline's config.
198 199 200 201 |
# File 'lib/melaya/pipelines.rb', line 198 def update(name, config:, project: nil) body = compact("config" => config, "project" => project) @http.put("/api/v1/private/pipelines/#{enc(name)}", body) end |
#upsert_schedule(project, pipeline_name, cron:, config: nil) ⇒ Object
PUT /api/v1/private/pipeline-schedule/:project/:pipelineName Create or update a pipeline schedule (cron expression + optional config).
140 141 142 143 |
# File 'lib/melaya/pipelines.rb', line 140 def upsert_schedule(project, pipeline_name, cron:, config: nil) body = compact("cron" => cron, "config" => config) @http.put("/api/v1/private/pipeline-schedule/#{enc(project)}/#{enc(pipeline_name)}", body) end |