Add process id and reference glob pattern matching

For the API endpoint /v3/process two new query parameter are introduced
in order to list only processes that match a pattern for the id and the
reference: idpattern and refpattern. The pattern is a glob pattern. If
patterns for both are given, the results will be intersected. If you use
other query parameters such as id or reference, they will be applied
after the result of the pattern matching.
This commit is contained in:
Ingo Oppermann
2022-08-17 07:55:44 +03:00
parent 11c3fce812
commit 3e7b1751d5
47 changed files with 3057 additions and 29 deletions

View File

@@ -10,7 +10,7 @@ import (
)
func (r *queryResolver) Processes(ctx context.Context) ([]*models.Process, error) {
ids := r.Restream.GetProcessIDs()
ids := r.Restream.GetProcessIDs("", "")
procs := []*models.Process{}

View File

@@ -70,9 +70,11 @@ func (h *RestreamHandler) Add(c echo.Context) error {
// @Description List all known processes. Use the query parameter to filter the listed processes.
// @ID process-3-get-all
// @Produce json
// @Param filter query string false "Comma separated list of fields (config, state, report, metadata) that will be part of the output. If empty, all fields will be part of the output"
// @Param reference query string false "Return only these process that have this reference value. Overrides a list of IDs. If empty, the reference will be ignored"
// @Param id query string false "Comma separated list of process ids to list"
// @Param filter query string false "Comma separated list of fields (config, state, report, metadata) that will be part of the output. If empty, all fields will be part of the output."
// @Param reference query string false "Return only these process that have this reference value. If empty, the reference will be ignored."
// @Param id query string false "Comma separated list of process ids to list. Overrides the reference. If empty all IDs will be returned."
// @Param idpattern query string false "Glob pattern for process IDs. If empty all IDs will be returned. Intersected with results from refpattern."
// @Param refpattern query string false "Glob pattern for process references. If empty all IDs will be returned. Intersected with results from idpattern."
// @Success 200 {array} api.Process
// @Security ApiKeyAuth
// @Router /api/v3/process [get]
@@ -82,8 +84,10 @@ func (h *RestreamHandler) GetAll(c echo.Context) error {
wantids := strings.FieldsFunc(util.DefaultQuery(c, "id", ""), func(r rune) bool {
return r == rune(',')
})
idpattern := util.DefaultQuery(c, "idpattern", "")
refpattern := util.DefaultQuery(c, "refpattern", "")
ids := h.restream.GetProcessIDs()
ids := h.restream.GetProcessIDs(idpattern, refpattern)
processes := []api.Process{}