(ctx context.Context, raw json.RawMessage)
| 1398 | } |
| 1399 | |
| 1400 | func (h *HostAPIHandler) handleAutomationJobs(ctx context.Context, raw json.RawMessage) (any, error) { |
| 1401 | automation, err := h.automationManager() |
| 1402 | if err != nil { |
| 1403 | return nil, err |
| 1404 | } |
| 1405 | |
| 1406 | var params hostAPIAutomationJobsParams |
| 1407 | if err := decodeHostAPIParams(raw, ¶ms); err != nil { |
| 1408 | return nil, err |
| 1409 | } |
| 1410 | |
| 1411 | workspaceID, err := h.resolveAutomationWorkspaceID(ctx, params.WorkspaceID) |
| 1412 | if err != nil { |
| 1413 | return nil, err |
| 1414 | } |
| 1415 | |
| 1416 | jobs, err := automation.ListJobs(ctx, automationpkg.JobListQuery{ |
| 1417 | Scope: params.Scope, |
| 1418 | WorkspaceID: workspaceID, |
| 1419 | }) |
| 1420 | if err != nil { |
| 1421 | return nil, err |
| 1422 | } |
| 1423 | |
| 1424 | if params.Enabled == nil { |
| 1425 | return jobs, nil |
| 1426 | } |
| 1427 | |
| 1428 | filtered := make([]automationpkg.Job, 0, len(jobs)) |
| 1429 | for _, job := range jobs { |
| 1430 | if job.Enabled == *params.Enabled { |
| 1431 | filtered = append(filtered, job) |
| 1432 | } |
| 1433 | } |
| 1434 | return filtered, nil |
| 1435 | } |
| 1436 | |
| 1437 | func (h *HostAPIHandler) handleAutomationJobsGet(ctx context.Context, raw json.RawMessage) (any, error) { |
| 1438 | automation, err := h.automationManager() |
nothing calls this directly
no test coverage detected