diff --git a/client/application_profile.go b/client/application_profile.go index 50eb403e..07ab8971 100644 --- a/client/application_profile.go +++ b/client/application_profile.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/pkg/errors" - "github.com/spectrocloud/hapi/apiutil/transport" hashboardC "github.com/spectrocloud/hapi/hashboard/client/v1" "github.com/spectrocloud/hapi/models" @@ -105,7 +104,7 @@ func (h *V1Client) GetApplicationProfileTierManifestContent(applicationProfileUI return success.Payload.Spec.Published.Content, nil } -func (h *V1Client) SearchAppProfileSummaries(scope string, filter *models.V1AppProfileFilterSpec, sortBy []*models.V1AppProfileSortSpec) ([]*models.V1AppProfileSummary, error) { +func (h *V1Client) SearchAppProfileSummaries(scope string, filter *models.V1AppProfileFilterSpec, sortBy []*models.V1AppProfileSortSpec, getAllPages bool) ([]*models.V1AppProfileSummary, error) { client, err := h.GetHashboardClient() if err != nil { return nil, err @@ -122,14 +121,29 @@ func (h *V1Client) SearchAppProfileSummaries(scope string, filter *models.V1AppP Filter: filter, Sort: sortBy, } - + var appProfile []*models.V1AppProfileSummary resp, err := client.V1DashboardAppProfiles(params) if e, ok := err.(*transport.TransportError); ok && e.HttpCode == 404 { return nil, nil } else if err != nil { return nil, err } - return resp.Payload.AppProfiles, nil + appProfile = append(appProfile, resp.Payload.AppProfiles...) + for len(resp.Payload.Listmeta.Continue) != 0 && getAllPages { + params.Offset = &resp.Payload.Listmeta.Offset + resp, err := client.V1DashboardAppProfiles(params) + if e, ok := err.(*transport.TransportError); ok && e.HttpCode == 404 { + return nil, nil + } else if err != nil { + return nil, err + } + appProfile = append(appProfile, resp.Payload.AppProfiles...) + if len(resp.Payload.Listmeta.Continue) == 0 { + break + } + getAllPages = true + } + return appProfile, nil } func (h *V1Client) PatchApplicationProfile(appProfileUID string, metadata *models.V1AppProfileMetaEntity, ProfileContext string) error { @@ -137,7 +151,6 @@ func (h *V1Client) PatchApplicationProfile(appProfileUID string, metadata *model if err != nil { return err } - var params *clusterC.V1AppProfilesUIDMetadataUpdateParams switch ProfileContext { case "project":