Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix listQueriesV2 client func inventory #2333

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/describe/schedulers/query-validator/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *JobScheduler) runScheduler() error {
}
}

namedQueries, err := s.inventoryClient.ListQueriesV2(clientCtx)
namedQueries, err := s.inventoryClient.ListQueriesV2(clientCtx, nil)
if err != nil {
s.logger.Error("error while listing benchmarks", zap.Error(err))
return fmt.Errorf("error while listing benchmarks: %v", err)
Expand Down
11 changes: 8 additions & 3 deletions services/inventory/client/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
type InventoryServiceClient interface {
RunQuery(ctx *httpclient.Context, req api.RunQueryRequest) (*api.RunQueryResponse, error)
GetQuery(ctx *httpclient.Context, id string) (*api.NamedQueryItemV2, error)
ListQueriesV2(ctx *httpclient.Context) (*api.ListQueriesV2Response, error)
ListQueriesV2(ctx *httpclient.Context, req *api.ListQueryV2Request) (*api.ListQueriesV2Response, error)
CountResources(ctx *httpclient.Context) (int64, error)
ListIntegrationsData(ctx *httpclient.Context, integrationIds []string, resourceCollections []string, startTime, endTime *time.Time, metricIDs []string, needCost, needResourceCount bool) (map[string]api.ConnectionData, error)
ListResourceTypesMetadata(ctx *httpclient.Context, integrationTypes []integration.Type, services []string, resourceTypes []string, summarized bool, tags map[string]string, pageSize, pageNumber int) (*api.ListResourceTypeMetadataResponse, error)
Expand Down Expand Up @@ -81,11 +81,16 @@ func (s *inventoryClient) GetQuery(ctx *httpclient.Context, id string) (*api.Nam
return &namedQuery, nil
}

func (s *inventoryClient) ListQueriesV2(ctx *httpclient.Context) (*api.ListQueriesV2Response, error) {
func (s *inventoryClient) ListQueriesV2(ctx *httpclient.Context, req *api.ListQueryV2Request) (*api.ListQueriesV2Response, error) {
url := fmt.Sprintf("%s/api/v3/queries", s.baseURL)

reqBytes, err := json.Marshal(req)
if err != nil {
return nil, err
}

var namedQuery api.ListQueriesV2Response
if statusCode, err := httpclient.DoRequest(ctx.Ctx, http.MethodGet, url, ctx.ToHeaders(), nil, &namedQuery); err != nil {
if statusCode, err := httpclient.DoRequest(ctx.Ctx, http.MethodPost, url, ctx.ToHeaders(), reqBytes, &namedQuery); err != nil {
if statusCode == http.StatusNotFound {
return nil, nil
}
Expand Down
2 changes: 1 addition & 1 deletion services/metadata/http_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (h HttpHandler) ListQueryParameters(ctx echo.Context) error {
h.logger.Error("error listing controls", zap.Error(err))
return echo.NewHTTPError(http.StatusInternalServerError, "error listing controls")
}
namedQueries, err := inventoryClient.ListQueriesV2(clientCtx)
namedQueries, err := inventoryClient.ListQueriesV2(clientCtx, nil)
if err != nil {
h.logger.Error("error listing queries", zap.Error(err))
return echo.NewHTTPError(http.StatusInternalServerError, "error listing queries")
Expand Down
Loading