func (l *Listener) ModifyRepo(ctx *fasthttp.RequestCtx) {
	id := ctx.UserValue("left").(string)
	if len(id) == 0 {
		writeErrorString(ctx, "ID required when modifying repo", http.StatusBadRequest)
		return
	}
	action := string(ctx.QueryArgs().Peek("action"))
	if len(action) == 0 {
		writeErrorString(ctx, "Action required when modifying repo", http.StatusBadRequest)
		return
	}
	var err error
	var jobID int
	switch action {
	case "check":
		jobID, err = l.manager.Check(id)
	case "delta":
		jobID, err = l.manager.Delta(id)
	case "index":
		jobID, err = l.manager.Index(id)
	case "rescan":
		jobID, err = l.manager.Rescan(id)
	case "trim-obsoletes":
		jobID, err = l.manager.TrimObsoletes(id)
	case "trim-packages":
		max := string(ctx.QueryArgs().Peek("max"))
		if len(max) == 0 {
			writeErrorString(ctx, "Max required when trimming packages", http.StatusBadRequest)
			return
		}
		m, err := strconv.Atoi(max)
		if err != nil {
			writeErrorString(ctx, "Max must be an integer", http.StatusBadRequest)
			return
		}
		jobID, err = l.manager.TrimPackages(id, m)
	default:
		writeErrorString(ctx, fmt.Sprintf("Invalid action '%s' when modifying repo", action), http.StatusBadRequest)
		return
	}
	if err != nil {
		writeError(ctx, err, http.StatusInternalServerError)
		return
	}
	writeID(ctx, jobID)
}
ModifyRepo performs a modification to an existing repo
package v1
import (
	"fmt"
	"github.com/getsolus/ferryd/jobs"
	"github.com/getsolus/ferryd/repo"
	"github.com/valyala/fasthttp"
	"net/http"
	"strconv"
)
func (c *Client) modifyRepo(id, action string) (j *jobs.Job, err error) {
	req, err := http.NewRequest("PATCH", formURI("api/v1/repos/"+id), nil)
	if err != nil {
		return
	}
	q := req.URL.Query()
	q.Add("action", action)
	req.URL.RawQuery = q.Encode()
	j, err = c.runJob(req)
	return
}
func (c *Client) modifyDiff(id, action string) (d *repo.Diff, j *jobs.Job, err error) {
	if j, err = c.modifyRepo(id, action); err != nil {
		return
	}
	if err = d.UnmarshalBinary(j.Results); err != nil {
		err = fmt.Errorf("error while decoding diff: %v", err)
	}
	return
}