diff --git a/pkg/api/aim2/api/request/run.go b/pkg/api/aim2/api/request/run.go index 06da48310..2e488feac 100644 --- a/pkg/api/aim2/api/request/run.go +++ b/pkg/api/aim2/api/request/run.go @@ -51,18 +51,18 @@ type SearchRunsRequest struct { // MetricTuple represents a metric with key and context. type MetricTuple struct { - Key string `query:"metric"` - Context string `query:"context"` + Key string `json:"key"` + Context string `json:"context"` } // SearchMetricsRequest is a request struct for `GET /runs/search/metric` endpoint. type SearchMetricsRequest struct { BaseSearchRequest - Metrics []MetricTuple `query:"m"` - Query string `query:"q"` - Steps int `query:"p"` - XAxis string `query:"x_axis"` - SkipSystem bool `query:"skip_system"` + Metrics []MetricTuple `json:"metrics"` + Query string `json:"query"` + Steps int `json:"steps"` + XAxis string `json:"x_axis"` + SkipSystem bool `json:"skip_system"` } // SearchAlignedMetricsRequest is a request struct for `GET /runs/search/metric/align` endpoint. diff --git a/pkg/api/aim2/controller/runs.go b/pkg/api/aim2/controller/runs.go index f3126a1df..9bfa8d283 100644 --- a/pkg/api/aim2/controller/runs.go +++ b/pkg/api/aim2/controller/runs.go @@ -127,7 +127,7 @@ func (c Controller) SearchRuns(ctx *fiber.Ctx) error { return nil } -// SearchMetrics handles `GET /runs/search/metric` endpoint. +// SearchMetrics handles `POST /runs/search/metric` endpoint. func (c Controller) SearchMetrics(ctx *fiber.Ctx) error { ns, err := middleware.GetNamespaceFromContext(ctx.Context()) if err != nil { @@ -136,10 +136,9 @@ func (c Controller) SearchMetrics(ctx *fiber.Ctx) error { log.Debugf("searchMetrics namespace: %s", ns.Code) req := request.SearchMetricsRequest{} - if err = ctx.QueryParser(&req); err != nil { + if err = ctx.BodyParser(&req); err != nil { return fiber.NewError(fiber.StatusUnprocessableEntity, err.Error()) } - if ctx.Query("report_progress") == "" { req.ReportProgress = true } @@ -163,7 +162,7 @@ func (c Controller) SearchMetrics(ctx *fiber.Ctx) error { return nil } -// SearchAlignedMetrics handles `GET /runs/search/metric/align` endpoint. +// SearchAlignedMetrics handles `POST /runs/search/metric/align` endpoint. func (c Controller) SearchAlignedMetrics(ctx *fiber.Ctx) error { ns, err := middleware.GetNamespaceFromContext(ctx.Context()) if err != nil { diff --git a/pkg/api/aim2/routes.go b/pkg/api/aim2/routes.go index d68e30e87..85aae06d5 100644 --- a/pkg/api/aim2/routes.go +++ b/pkg/api/aim2/routes.go @@ -65,7 +65,7 @@ func (r Router) Init(server fiber.Router) { runs := mainGroup.Group("/runs") runs.Get("/active/", r.controller.GetRunsActive) runs.Get("/search/run/", r.controller.SearchRuns) - runs.Get("/search/metric/", r.controller.SearchMetrics) + runs.Post("/search/metric/", r.controller.SearchMetrics) runs.Post("/search/metric/align/", r.controller.SearchAlignedMetrics) runs.Get("/:id/info/", r.controller.GetRunInfo) runs.Post("/:id/metric/get-batch/", r.controller.GetRunMetrics) diff --git a/tests/integration/golang/aim/metric/search_test.go b/tests/integration/golang/aim/metric/search_test.go index 35b7ee18e..c7b21cc55 100644 --- a/tests/integration/golang/aim/metric/search_test.go +++ b/tests/integration/golang/aim/metric/search_test.go @@ -5,6 +5,7 @@ import ( "context" "database/sql" "fmt" + "net/http" "testing" "github.com/google/uuid" @@ -2016,7 +2017,9 @@ func (s *SearchMetricsTestSuite) Test_Ok() { s.Run(tt.name, func() { resp := new(bytes.Buffer) s.Require().Nil( - s.AIMClient().WithQuery( + s.AIMClient().WithMethod( + http.MethodPost, + ).WithRequest( tt.request, ).WithResponseType( helpers.ResponseTypeBuffer, diff --git a/tests/integration/golang/aim/namespace/flows/metric_test.go b/tests/integration/golang/aim/namespace/flows/metric_test.go index 6cfded3a3..76a9ec23c 100644 --- a/tests/integration/golang/aim/namespace/flows/metric_test.go +++ b/tests/integration/golang/aim/namespace/flows/metric_test.go @@ -307,9 +307,11 @@ func (s *MetricFlowTestSuite) searchMetricsAndCompare( ) { resp := new(bytes.Buffer) s.Require().Nil( - s.AIMClient().WithNamespace( + s.AIMClient().WithMethod( + http.MethodPost, + ).WithNamespace( namespace, - ).WithQuery( + ).WithRequest( request, ).WithResponseType( helpers.ResponseTypeBuffer,