From cfbbb092d09e80a3ae4217d24cfc0907c5162ee3 Mon Sep 17 00:00:00 2001 From: Gamya Date: Thu, 6 Jun 2024 19:13:20 +0530 Subject: [PATCH] PQA-1860: get edge hosts using continue token (#110) * get edge hosts using continue token * Update cluster_edge_native.go --- client/cluster_edge_native.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/cluster_edge_native.go b/client/cluster_edge_native.go index cd85e44b..e7af4e12 100644 --- a/client/cluster_edge_native.go +++ b/client/cluster_edge_native.go @@ -53,12 +53,19 @@ func (h *V1Client) GetEdgeHost(edgeHostId string) (*models.V1EdgeHostDevice, err } func (h *V1Client) ListEdgeHosts() ([]*models.V1EdgeHostsMetadata, error) { - params := clientV1.NewV1DashboardEdgehostsSearchParamsWithContext(h.ctx) - resp, err := h.Client.V1DashboardEdgehostsSearch(params) - if err != nil { - return nil, err + continueToken := "" + var items []*models.V1EdgeHostsMetadata + for ok := true; ok; ok = (continueToken != "") { + params := clientV1.NewV1DashboardEdgehostsSearchParamsWithContext(h.ctx) + resp, err := h.Client.V1DashboardEdgehostsSearch(params) + if err != nil { + return nil, err + } + continueToken = resp.Payload.Listmeta.Continue + items = append(items, resp.Payload.Items...) } - return resp.Payload.Items, nil + + return items, nil } func (h *V1Client) CreateClusterEdgeNative(cluster *models.V1SpectroEdgeNativeClusterEntity) (string, error) {