4ccb980593
Initial Job Collector (changes pending) * movearroundtocleancollector * internalgetfunctions * completecollectorquery * simplify * fixtests * addvendor * noplaceholder
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package queryservice
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func (s *Controllers) GetJobCollectorByJobId(ctx echo.Context, jobId string) error {
|
|
uid, err := uuid.Parse(jobId)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, "Invalid ID")
|
|
}
|
|
|
|
coll, err := s.svc.JobCollector.GetByJobID(ctx.Request().Context(), uid)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Unable to get collector: %s", err))
|
|
}
|
|
|
|
fields := make([]JobCollectorField, len(coll.Fields))
|
|
index := 0
|
|
for name, id := range coll.Fields {
|
|
fields[index] = JobCollectorField{
|
|
Name: name,
|
|
QueryId: id.String(),
|
|
}
|
|
index++
|
|
}
|
|
|
|
return ctx.JSON(http.StatusOK, JobCollector{
|
|
JobId: coll.JobID.String(),
|
|
MinimumCleanerVersion: coll.MinCleanVersion,
|
|
MinimumTextVersion: coll.MinTextVersion,
|
|
ActiveVersion: coll.ActiveVersion,
|
|
LatestVersion: coll.LatestVersion,
|
|
Fields: fields,
|
|
})
|
|
}
|
|
|
|
func (s *Controllers) UpdateJobCollectorByJobId(ctx echo.Context, jobId string) error {
|
|
return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"})
|
|
}
|