(ctx context.Context, raw json.RawMessage)
| 1474 | } |
| 1475 | |
| 1476 | func (h *HostAPIHandler) handleAutomationJobsUpdate(ctx context.Context, raw json.RawMessage) (any, error) { |
| 1477 | automation, err := h.automationManager() |
| 1478 | if err != nil { |
| 1479 | return nil, err |
| 1480 | } |
| 1481 | |
| 1482 | var params hostAPIAutomationJobUpdateParams |
| 1483 | if err := decodeHostAPIParams(raw, ¶ms); err != nil { |
| 1484 | return nil, err |
| 1485 | } |
| 1486 | if strings.TrimSpace(params.ID) == "" { |
| 1487 | return nil, invalidParamsRPCError(errors.New("id is required")) |
| 1488 | } |
| 1489 | if !params.HasChanges() { |
| 1490 | return nil, invalidParamsRPCError(errors.New("automation job update must include at least one field")) |
| 1491 | } |
| 1492 | |
| 1493 | current, err := automation.GetJob(ctx, params.ID) |
| 1494 | if err != nil { |
| 1495 | return nil, err |
| 1496 | } |
| 1497 | |
| 1498 | if current.Source == automationpkg.JobSourceConfig { |
| 1499 | if err := validateHostAPIConfigJobUpdate(params.UpdateJobRequest); err != nil { |
| 1500 | return nil, invalidParamsRPCError(err) |
| 1501 | } |
| 1502 | return automation.SetJobEnabled(ctx, current.ID, *params.Enabled) |
| 1503 | } |
| 1504 | |
| 1505 | next, err := h.applyJobUpdateParams(ctx, current, params.UpdateJobRequest) |
| 1506 | if err != nil { |
| 1507 | return nil, err |
| 1508 | } |
| 1509 | if err := next.Validate("job"); err != nil { |
| 1510 | return nil, invalidParamsRPCError(err) |
| 1511 | } |
| 1512 | |
| 1513 | return automation.UpdateJob(ctx, next) |
| 1514 | } |
| 1515 | |
| 1516 | func (h *HostAPIHandler) handleAutomationJobsDelete(ctx context.Context, raw json.RawMessage) (any, error) { |
| 1517 | automation, err := h.automationManager() |
nothing calls this directly
no test coverage detected