CmdRemove handles the "remove" command.
(fn Function)
| 562 | |
| 563 | // CmdRemove handles the "remove" command. |
| 564 | func (h *Handler[C]) CmdRemove(fn Function) { |
| 565 | key, _, ok := h.cb.ExtractKey(fn) |
| 566 | if !ok { |
| 567 | h.api.SendCodef(fn, 400, "invalid job ID format.") |
| 568 | return |
| 569 | } |
| 570 | |
| 571 | entry, ok := h.exposed.LookupByKey(key) |
| 572 | if !ok { |
| 573 | h.api.SendCodef(fn, 404, "job not found.") |
| 574 | return |
| 575 | } |
| 576 | |
| 577 | if entry.Cfg.SourceType() != "dyncfg" { |
| 578 | h.api.SendCodef(fn, 405, "removing jobs of type '%s' is not supported, only 'dyncfg' jobs can be removed.", entry.Cfg.SourceType()) |
| 579 | return |
| 580 | } |
| 581 | |
| 582 | h.seen.Remove(entry.Cfg) |
| 583 | h.exposed.Remove(entry.Cfg) |
| 584 | h.cb.Stop(entry.Cfg) |
| 585 | |
| 586 | h.api.SendCodef(fn, 200, "%s", takeCommandMessage(h.cb)) |
| 587 | h.NotifyJobRemove(entry.Cfg) |
| 588 | } |
| 589 | |
| 590 | // CmdUpdate handles the "update" command. |
| 591 | func (h *Handler[C]) CmdUpdate(fn Function) { |