Updates to /sharepoint/site_page.go
Adds logic for fetching Page M365 IDs.
This commit is contained in:
parent
764909e6e9
commit
ec613b636d
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
bmodel "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
bmodel "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
|
||||||
|
"github.com/microsoftgraph/msgraph-beta-sdk-go/sites"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
@ -37,3 +38,51 @@ func GetSitePage(
|
|||||||
|
|
||||||
return col, nil
|
return col, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fetchPages utility function to return the tuple of item
|
||||||
|
func fetchPages(ctx context.Context, bs graph.BetaService, siteID string) ([]listTuple, error) {
|
||||||
|
var (
|
||||||
|
builder = bs.Client().SitesById(siteID).Pages()
|
||||||
|
opts = fetchPageOptions()
|
||||||
|
pageTuples = make([]listTuple, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
for {
|
||||||
|
resp, err := builder.Get(ctx, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, support.ConnectorStackErrorTraceWrap(err, "failed fetching site page")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, entry := range resp.GetValue() {
|
||||||
|
pid := *entry.GetId()
|
||||||
|
temp := listTuple{id: pid, name: pid}
|
||||||
|
|
||||||
|
if entry.GetName() != nil {
|
||||||
|
temp.name = *entry.GetName()
|
||||||
|
}
|
||||||
|
|
||||||
|
pageTuples = append(pageTuples, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.GetOdataNextLink() == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = sites.NewItemPagesRequestBuilder(*resp.GetOdataNextLink(), bs.Adapter())
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageTuples, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetchPageOptions is used to return minimal information reltating to Site Pages
|
||||||
|
// Pages API: https://learn.microsoft.com/en-us/graph/api/resources/sitepage?view=graph-rest-beta
|
||||||
|
func fetchPageOptions() *sites.ItemPagesRequestBuilderGetRequestConfiguration {
|
||||||
|
fields := []string{"id", "name"}
|
||||||
|
options := &sites.ItemPagesRequestBuilderGetRequestConfiguration{
|
||||||
|
QueryParameters: &sites.ItemPagesRequestBuilderGetQueryParameters{
|
||||||
|
Select: fields,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return options
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user