Skip to content

Commit

Permalink
🧹 fetch all ms365 applications (add pagination when fetching resources)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeffrey committed Dec 23, 2024
1 parent 1784c48 commit b253639
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions providers/ms365/resources/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func (a *mqlMicrosoft) applications() ([]interface{}, error) {
return nil, err
}
ctx := context.Background()
top := int32(999)
top := int32(500)
var allApps []models.Applicationable
resp, err := graphClient.Applications().Get(ctx, &applications.ApplicationsRequestBuilderGetRequestConfiguration{
QueryParameters: &applications.ApplicationsRequestBuilderGetQueryParameters{
Top: &top,
Expand All @@ -39,10 +40,22 @@ func (a *mqlMicrosoft) applications() ([]interface{}, error) {
if err != nil {
return nil, transformError(err)
}
allApps = append(allApps, resp.GetValue()...)

if resp.GetOdataNextLink() != nil {
resp, err := graphClient.Applications().WithUrl(*resp.GetOdataNextLink()).Get(ctx, &applications.ApplicationsRequestBuilderGetRequestConfiguration{
QueryParameters: &applications.ApplicationsRequestBuilderGetQueryParameters{
Top: &top,
},
})
if err != nil {
return nil, err
}
allApps = append(allApps, resp.GetValue()...)
}

res := []interface{}{}
apps := resp.GetValue()
for _, app := range apps {
for _, app := range allApps {
mqlResource, err := newMqlMicrosoftApplication(a.MqlRuntime, app)
if err != nil {
return nil, err
Expand Down

0 comments on commit b253639

Please sign in to comment.