Skip to content

Commit

Permalink
list all pages of app profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
shphadnis committed Oct 27, 2023
1 parent 4777a42 commit 9f9ea64
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions client/application_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -122,22 +121,36 @@ 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 {
client, err := h.GetClusterClient()
if err != nil {
return err
}

var params *clusterC.V1AppProfilesUIDMetadataUpdateParams
switch ProfileContext {
case "project":
Expand Down

0 comments on commit 9f9ea64

Please sign in to comment.