Skip to content

Commit

Permalink
PLT-1217:Added pagination support in edge_hosts/appliances data source (
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM authored May 22, 2024
1 parent 0cf07aa commit dbae34a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions client/appliance.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"github.com/spectrocloud/gomi/pkg/ptr"
hashboardC "github.com/spectrocloud/hapi/hashboard/client/v1"
"github.com/spectrocloud/hapi/models"
clusterC "github.com/spectrocloud/hapi/spectrocluster/client/v1"
Expand All @@ -20,13 +21,21 @@ func (h *V1Client) SearchApplianceSummaries(applianceContext string, filter *mod
Filter: filter,
Sort: sort,
}

resp, err := h.GetHashboardClient().V1DashboardEdgehostsSearch(params)
if err != nil {
return nil, err
isContinue := true
var hosts []*models.V1EdgeHostsMetadata
for isContinue {
resp, err := h.GetHashboardClient().V1DashboardEdgehostsSearch(params)
if err != nil {
return nil, err
}
hosts = append(hosts, resp.Payload.Items...)
if resp.Payload.Listmeta.Continue == "" {
isContinue = false
}
params.WithContinue(ptr.StringPtr(resp.Payload.Listmeta.Continue))
}

return resp.Payload.Items, nil
return hosts, nil
}

func (h *V1Client) GetAppliances(applianceContext string, tags map[string]string, status, health, architecture string) ([]*models.V1EdgeHostsMetadata, error) {
Expand Down

0 comments on commit dbae34a

Please sign in to comment.