Compare commits

...

110 Commits

Author SHA1 Message Date
Danny
4f25447b3e
Merge branch 'main' into sanitize-page 2023-02-13 15:31:37 -05:00
Danny Adams
c1b1d4bc2d Update to /sharepoint/api/pages.go
Introduction of sanitize function for pages. Troubleshooting still required.
2023-02-13 13:14:03 -05:00
Danny Adams
3b2e1ecdc2 Updates to /cli/restore/sharepoint.go
Change to usage for folder names.
2023-02-10 13:24:19 -05:00
Danny Adams
72ff596d2a Updates to /cli/backup/sharepoint.go
Usage updated for folder names.
2023-02-10 13:23:47 -05:00
Danny Adams
4b001a20a1 Updates to /graph/betasdk/beta_client.go
Removal of conflicts.
2023-02-10 12:43:29 -05:00
Danny
8d5ee37c53
Merge branch 'main' into sharepoint-restore-selectors 2023-02-10 11:57:00 -05:00
Danny
aafc9c73f9
Merge branch 'main' into sharepoint-restore-selectors 2023-02-04 16:49:28 -05:00
Danny Adams
341878b6e3 Merge branch 'main' into sharepoint-restore-selectors 2023-01-31 16:59:29 -05:00
Danny
aca2fd2bfb
Merge branch 'beta-library-switch' into sharepoint-restore-selectors 2023-01-26 17:17:31 -05:00
Danny
57ce0be82a
Merge branch 'main' into beta-library-switch 2023-01-26 17:17:00 -05:00
Danny Adams
b3aec1b40f Updates /graph/beasdk/beta_service_test.go
File renamed to beta_client_test.go.
Comments updated.
2023-01-26 16:16:43 -05:00
Danny Adams
f8d65d66de Updates to /graph/betasdk/beta_client.go
Registers serializers for connector.
Adds explicit comments on connector usage and patterns.
Removes Sites() call from supported commands.
2023-01-26 16:08:25 -05:00
Danny Adams
817a7a2bc6 UPdates to /graph/betasdk/sites package
Final sweep to bring src files down to bare minimum for Site Page management.
2023-01-26 15:51:39 -05:00
Danny Adams
2839d8d6e3 ci.yml --> remove swap space. 2023-01-26 14:09:00 -05:00
Danny Adams
05c3216f08 Removal of beta library package from system. 2023-01-26 14:03:49 -05:00
Danny Adams
8a474af189 Revert back to msgraph-sdk-go library for /support/errors.go 2023-01-26 14:02:55 -05:00
Danny Adams
b7b2de096b Revert back to msgraph-sdk-go package for /connector/graph/errors.go 2023-01-26 14:02:15 -05:00
Danny Adams
03ec1dd2e9 Updates to remove beta library from operations/backup_integration_test.go 2023-01-26 14:01:24 -05:00
Danny Adams
7bc080305d Update to exclude betasdk from linting. 2023-01-26 13:56:31 -05:00
Danny Adams
28ddbca41e Merge branch 'beta-library-switch' of github.com:alcionai/corso into beta-library-switch 2023-01-26 11:53:16 -05:00
Danny Adams
263197bbab Updates to /betasdk/sites/ for GOFMT:
Fixes for linter failures --> ignore statements.
2023-01-26 11:39:37 -05:00
Danny
4e3f15f357
Update ci.yml
Update to 12
2023-01-26 10:01:32 -05:00
Danny Adams
68f7ac9cff Updates to the .yml for additional space. 2023-01-26 09:55:41 -05:00
Danny Adams
bcd379f596 Updates to betasdk/sites package
Dependencies updated and minimal files supplied.
2023-01-26 08:24:09 -05:00
Danny Adams
aca2eb5d65 Updates to betasdk/sites package
Package only to support SitePageable objects. Process begun to removal
of queries that do not support these operations.
2023-01-25 21:34:36 -05:00
Danny Adams
2f02efe489 Reduction to /graph/betasdk/models/package
Referenced models from v1.0 and retained minimial for Page retrieval.
2023-01-25 20:52:07 -05:00
Danny Adams
3e4fae6a56 Removal of odataerrors withing betasdk.
Files are present in main package.
2023-01-25 20:16:49 -05:00
Danny Adams
775f5ce4e3 Updates to /connector/graph/betasdk/sites
Removal of Async calls and file permissions for adapter compatibility.
2023-01-25 17:57:11 -05:00
Danny Adams
a31fe596af Update go.mod
mod tidy removes incorrectly applied test suite.
2023-01-25 17:27:35 -05:00
Danny Adams
f33167d765 Updates to .github/workflows/ci.yml
Removal of swap space from ci workflow.
2023-01-25 17:21:47 -05:00
Danny Adams
8f22c4f776 Non-Page files removed. 2023-01-25 17:18:46 -05:00
Danny Adams
9dc487b39f Test file created. 2023-01-25 16:39:28 -05:00
Danny Adams
9bbb479fa3 Changes to /connector/discovery/api/users_test.go
Reverts library back to msgraph-sdk-go.
2023-01-25 15:30:50 -05:00
Danny Adams
dc09508821 Updates to /pkg/services/m365 package
Reverts the package back to msgraph-sdk-go.
2023-01-25 14:45:36 -05:00
Danny Adams
918fd835ad Updates library to use betasdk package. 2023-01-25 14:33:11 -05:00
Danny Adams
42a9499b71 Add file to /graph/betasdk/kiota-lock.json
File shows how app.kiota generator created the minimal SDK.
2023-01-25 14:31:16 -05:00
Danny Adams
740c8dc3e2 Updates to /graph/betasdk/beta_client.go
Removes the admin and groups properties for minimal beta connector.
2023-01-25 14:12:34 -05:00
Danny Adams
d2fb427146 Hydrate sites command directory. 2023-01-25 14:07:06 -05:00
Danny Adams
4fdd165afd Hydrate model directory. 2023-01-25 14:06:41 -05:00
Danny Adams
76cc59348a Go.mod: Update to libraries. 2023-01-25 14:04:51 -05:00
Danny Adams
9a0dd673c6 Kiota library mismatch from preview. 2023-01-25 13:13:10 -05:00
Danny Adams
b4118627a6 Kiota library mismatch from preview. 2023-01-25 13:12:37 -05:00
Danny Adams
a51b6e8444 Kiota library mismatch from preview. 2023-01-25 13:11:03 -05:00
Danny Adams
1acc6b9e18 Hydrate sites package. 2023-01-25 09:51:12 -05:00
Danny Adams
9a6d58b18c Inflate admin package. 2023-01-25 09:50:15 -05:00
Danny Adams
b27ce3d0e2 Inflate Models package. 2023-01-25 09:46:34 -05:00
Danny Adams
f5d514470d Inflate admin package. 2023-01-25 09:44:25 -05:00
Danny Adams
0a1e0d249f Package configuration. 2023-01-25 09:34:15 -05:00
Danny Adams
b1f7ab51e9 beta_client beta client formatting. 2023-01-25 09:23:13 -05:00
Danny Adams
b13f5b6fb6 Update shuffle. 2023-01-25 09:21:18 -05:00
Danny Adams
e51f654e46 Delete /betaSDK/sites package. 2023-01-25 09:02:25 -05:00
Danny Adams
50da437421 Updates package name for betasdk package. 2023-01-25 08:47:45 -05:00
Danny Adams
1d13f7d2df Updates betaSDK/groups package
Removes backing store from model.
2023-01-25 08:36:04 -05:00
Danny Adams
e9371379a6 Updates beta_client..go
Removal of backing store from model.
2023-01-25 08:34:27 -05:00
Danny Adams
ae69293fa6 Updates kiota-lock.json: Removal of backing store. 2023-01-25 08:31:40 -05:00
Danny Adams
66e560987e Adds Kiota-lock.json to betaSDK package. 2023-01-25 08:18:53 -05:00
Danny Adams
c3fd313a82 Adds betaSDK/sites package. Temp 2023-01-25 08:17:44 -05:00
Danny Adams
2d73ed3a6b Adds group package temporarily. 2023-01-25 08:17:11 -05:00
Danny Adams
988962c06e Adds admin file. Temp. 2023-01-25 08:16:35 -05:00
Danny Adams
5368cd38cf Issue #2174: Adds Beta Client to package from generator. 2023-01-25 08:16:09 -05:00
Danny Adams
2a93dc9caf Updates to graph_connector component and helper_test files.
Reverts back to msgraph-sdk-go.
2023-01-25 07:59:09 -05:00
Danny Adams
ea70fa6eee Updates to /connector/sharepoint package
Reverts sharepoint package to msgraph-sdk-go
2023-01-25 07:57:42 -05:00
Danny Adams
c7828db7d6 Merge branch 'main' into sharepoint-restore-selectors 2023-01-25 07:50:47 -05:00
Danny Adams
a090bed081 Update to /mockconnector/mock_data_collection_test.go
Package reverted back to msgraph-sdk-go
2023-01-25 07:45:10 -05:00
Danny Adams
702ec7f234 Updates to /connector/exchange package
Package reverted back to msgraph-sdk-go
2023-01-25 07:43:44 -05:00
Danny Adams
c221d388b1 Update to /connector/mockconnector/mock_data_list.go
Package reverted back to msgraph-sdk-go
2023-01-25 07:40:58 -05:00
Danny Adams
4853d6c0ce Updates to /connector/support package.
Package reverted back to msgraph-sdk-go
2023-01-25 06:47:32 -05:00
Danny Adams
2f9f61b4a6 Updates to /connector/graph/cache_container.go
Package reverted back to msgraph-sdk-go
2023-01-25 06:46:24 -05:00
Danny Adams
a22803e077 Updates ../connector/exchange/api package update
Package reverted back to msgraph-sdk-go
2023-01-25 06:44:59 -05:00
Danny Adams
10c605d02b Updates to /connector/onedrive package
Package reverted back to msgraph-sdk-go.
2023-01-25 06:33:44 -05:00
Danny Adams
63d2d7f4d8 /connector/graph package reverted back from beta packages. 2023-01-25 06:31:47 -05:00
Danny Adams
2fc8b36070 Update to go.mod & go.sum 2023-01-25 06:26:25 -05:00
Danny Adams
ec87d58078 Merge branch 'main' into beta-library-switch 2023-01-25 06:22:01 -05:00
Danny Adams
5414c71581 Updates to cli package per PR Request.
Flags changed to page-folders and pages respectively.
2023-01-25 05:49:29 -05:00
Danny Adams
156e01b8dd Updates to /cli/restore/sharepoint.go
Issue #2218: Connects CLI for SharePoint restore.
2023-01-22 02:12:21 -05:00
Danny Adams
0b7d22581b Update to pkg/selectors/sharepoint_test.go
Use of constant for literal.
2023-01-21 18:30:15 -05:00
Danny Adams
d22d943bef Updates to pkg/selectors/sharepoint_test.go
Adds tests to ensure  function is checked for details command.
2023-01-21 18:07:06 -05:00
Danny Adams
8f556c59a4 Update to /pkg/selectors/sharepoint.go
Bug fix: SharePoint selector misalignmet that causes panic on details command.
2023-01-21 17:41:21 -05:00
Danny Adams
f44607ca73 Additonal swap space required for CI compilation. 2023-01-20 11:40:39 -05:00
Danny Adams
898191f9a9 Removal of whitespace. 2023-01-20 11:23:08 -05:00
Danny Adams
c0112d917e Revert back to original ci.yml. 2023-01-20 11:21:35 -05:00
Danny Adams
f425d24364 Update support library to beta. 2023-01-20 11:11:11 -05:00
Danny Adams
2f125d44a6 Merge branch 'main' into beta-library-switch 2023-01-20 09:40:57 -05:00
Danny Adams
2cd64c4775 Updates to internal/connector/graph_connector_helper_test.go
git status
2023-01-20 09:31:14 -05:00
Danny Adams
b4eae746c4 Update to /pkg/services/m365/m365.go
Change to msgraph beta library.
2023-01-20 09:27:43 -05:00
Danny Adams
9b30a03c31 File added in error. 2023-01-20 09:26:48 -05:00
Danny Adams
77c3b3b7d7 Update /internal/operations package
Beta Library replaces msgraph v1.0
2023-01-20 09:25:44 -05:00
Danny Adams
4009a5c2d4 Update /connector/ package
Beta Library replaces msgraph v1.0
2023-01-20 09:25:03 -05:00
Danny Adams
4687b134ef Update /connector/support package
Beta Library replaces msgraph v1.0
2023-01-20 09:24:11 -05:00
Danny Adams
2929c9f25e Update /connector/sharepoint package
Beta Library replaces msgraph v1.0
2023-01-20 09:23:41 -05:00
Danny Adams
7404c4c8b0 Update /connector/onedrive package
Beta Library replaces msgraph v1.0
2023-01-20 09:22:40 -05:00
Danny Adams
135c07a41a Update /connector/exchange package
Beta Library replaces msgraph v1.0
2023-01-20 09:22:15 -05:00
Danny Adams
3ccdda8ef0 Update /connector/mockconnector package
Change to Beta library.
2023-01-20 09:21:08 -05:00
Danny Adams
4952b81333 Update /connector/graph package
Change to Beta library.
2023-01-20 09:20:31 -05:00
Danny Adams
b82a6349f4 Update /connector/exchange/api package
Change to Beta library.
2023-01-20 09:19:38 -05:00
Danny Adams
519a449b2f Update /connector/discovery package
Change to Beta library.
2023-01-20 09:18:49 -05:00
Danny Adams
97ca692168 Change to msgraph-sdk-beta. 2023-01-20 09:14:51 -05:00
Danny Adams
7ef73b866a Update for Beta Connector. 2023-01-19 16:41:32 -05:00
Danny Adams
613de30664 Updates to error response. Test to verify time for cache. 2023-01-19 16:23:39 -05:00
Danny
0802e97d56
Update ci.yml
Troubleshooting passed 8 GB.
2023-01-19 10:53:49 -05:00
Danny
d661d45671
Update ci.yml
Troubleshooting
2023-01-19 10:17:52 -05:00
Danny Adams
0cf21f6b2c Incremental increase of swap space. 2023-01-19 09:48:06 -05:00
Danny Adams
4c000c816d Adjust to swap space. 2023-01-19 09:42:30 -05:00
Danny Adams
29bb06e779 Updates to ci.yml
Increases swap space for build.
2023-01-19 09:37:49 -05:00
Danny Adams
6b1e84732e Merge branch 'main' into beta-page-connector 2023-01-19 01:34:33 -05:00
Danny Adams
39155c68fa Updates to msgraph-sdk-go to comply with abstraction changes brought in
via Beta.
2023-01-18 23:49:06 -05:00
Danny Adams
287dcd6930 Testing for new struct added. 2023-01-18 23:35:20 -05:00
Danny Adams
a9421d7195 Beta Servicer created. 2023-01-18 23:34:58 -05:00
Danny Adams
0a111cd9df Updates to the change log to address build times. 2023-01-18 23:33:18 -05:00
Danny Adams
58ad917d4c Beta packages updated. 2023-01-18 22:55:33 -05:00

View File

@ -7,8 +7,12 @@ import (
"sync"
"time"
msmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
kioser "github.com/microsoft/kiota-serialization-json-go"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/common/ptr"
discover "github.com/alcionai/corso/src/internal/connector/discovery/api"
"github.com/alcionai/corso/src/internal/connector/graph"
"github.com/alcionai/corso/src/internal/connector/graph/betasdk/models"
@ -19,6 +23,11 @@ import (
"github.com/alcionai/corso/src/pkg/backup/details"
)
const (
textWebPartType = "#microsoft.graph.textWebPart"
standardWebPartType = "#microsoft.graph.standardWebPart"
)
// GetSitePages retrieves a collection of Pages related to the give Site.
// Returns error if error experienced during the call
func GetSitePages(
@ -171,9 +180,8 @@ func RestoreSitePage(
defer end()
var (
dii = details.ItemInfo{}
pageID = itemData.UUID()
pageName = pageID
dii = details.ItemInfo{}
pageID = itemData.UUID()
)
byteArray, err := io.ReadAll(itemData.ToReader())
@ -187,23 +195,35 @@ func RestoreSitePage(
return dii, errors.Wrapf(err, "creating Page object %s", pageID)
}
pageNamePtr := page.GetName()
if pageNamePtr != nil {
pageName = *pageNamePtr
pageName := ptr.Val(page.GetName())
if len(pageName) == 0 {
pageName = pageID
}
newName := fmt.Sprintf("%s_%s", destName, pageName)
page.SetName(&newName)
pg := sanitize(page, newName)
wtr := kioser.NewJsonSerializationWriter()
err = wtr.WriteObjectValue("", pg)
byteArray, err = wtr.GetSerializedContent()
if err != nil {
fmt.Println("What happened")
}
fmt.Printf("Page\n %+v\n", string(byteArray))
fmt.Printf("Layout: %+v\n", pg.GetCanvasLayout())
// Restore is a 2-Step Process in Graph API
// 1. Create the Page on the site
// 2. Publish the site
// See: https://learn.microsoft.com/en-us/graph/api/sitepage-create?view=graph-rest-beta
restoredPage, err := service.Client().SitesById(siteID).Pages().Post(ctx, page, nil)
restoredPage, err := service.Client().SitesById(siteID).Pages().Post(ctx, pg, nil)
if err != nil {
sendErr := support.ConnectorStackErrorTraceWrap(
err,
"creating page from ID: %s"+pageName+" API Error Details",
"creating page: "+pageName+" API Error Details",
)
return dii, sendErr
@ -235,6 +255,182 @@ func RestoreSitePage(
return dii, nil
}
// sanitize removes all unique M365IDs from the SitePage data type.
func sanitize(orig models.SitePageable, newName string) *models.SitePage {
newPage := models.NewSitePage()
layout := sanitizeCanvasLayout(orig.GetCanvasLayout())
newPage.SetCanvasLayout(layout)
ct := sanitizeContentType(orig.GetContentType())
newPage.SetContentType(ct)
newPage.SetContentType(ct)
// Skip CreatedBy.., ..ByUser, ..DateTime
newPage.SetDescription(orig.GetDescription())
// skip Etag, ID, lastModified
// skip ID
// skip lastModified -> it will be the app
newPage.SetName(orig.GetName())
newPage.SetPageLayout(orig.GetPageLayout())
// Parent skipped
newPage.SetPromotionKind(nil)
// Skip publishing state. Page will attempt to be published during restore
newPage.SetReactions(orig.GetReactions())
newPage.SetShowComments(nil)
newPage.SetShowRecommendedPages(nil)
newPage.SetThumbnailWebUrl(nil)
newPage.SetTitle(orig.GetTitle())
// Skip TitleArea due to Upstream Failure
// https://github.com/microsoftgraph/msgraph-metadata/issues/258
newPage.SetTitleArea(nil)
wp := make([]models.WebPartable, 0)
for _, entry := range orig.GetWebParts() {
temp := sanitizeWebPart(entry)
wp = append(wp, temp)
}
newPage.SetWebParts(wp)
// webURL intentionally left
return newPage
}
func sanitizeContentType(orig msmodels.ContentTypeInfoable) msmodels.ContentTypeInfoable {
if orig == nil {
return nil
}
ct := msmodels.NewContentTypeInfo()
ct.SetName(orig.GetName())
ct.SetOdataType(orig.GetOdataType())
return ct
}
func sanitizeCanvasLayout(orig models.CanvasLayoutable) models.CanvasLayoutable {
canvas := models.NewCanvasLayout()
vert := sanitizeVertical(orig.GetVerticalSection())
canvas.SetVerticalSection(vert)
hzLayouts := make([]models.HorizontalSectionable, 0)
sections := orig.GetHorizontalSections()
for _, entry := range sections {
temp := sanitizeHorizontal(entry)
hzLayouts = append(hzLayouts, temp)
}
canvas.SetHorizontalSections(hzLayouts)
canvas.SetHorizontalSections(nil)
return canvas
}
func sanitizeVertical(orig models.VerticalSectionable) models.VerticalSectionable {
if orig == nil {
return nil
}
section := models.NewVerticalSection()
wps := make([]models.WebPartable, 0)
for _, item := range orig.GetWebparts() {
temp := sanitizeWebPart(item)
wps = append(wps, temp)
}
section.SetWebparts(wps)
section.SetEmphasis(orig.GetEmphasis())
section.SetOdataType(orig.GetOdataType())
return section
}
func sanitizeHorizontal(orig models.HorizontalSectionable) models.HorizontalSectionable {
newColumns := make([]models.HorizontalSectionColumnable, 0)
temp := models.NewHorizontalSection()
temp.SetEmphasis(orig.GetEmphasis())
temp.SetLayout(orig.GetLayout())
for _, entry := range orig.GetColumns() {
column := sanitizeColumn(entry)
newColumns = append(newColumns, column)
}
temp.SetColumns(newColumns)
return temp
}
func sanitizeColumn(orig models.HorizontalSectionColumnable) models.HorizontalSectionColumnable {
webparts := make([]models.WebPartable, 0)
temp := models.NewHorizontalSectionColumn()
temp.SetWidth(orig.GetWidth())
parts := orig.GetWebparts()
for _, entry := range parts {
wp := sanitizeWebPart(entry)
webparts = append(webparts, wp)
}
temp.SetWebparts(webparts)
return temp
}
func sanitizeWebPart(orig models.WebPartable) models.WebPartable {
fmt.Println(ptr.Val(orig.GetOdataType()))
category := ptr.Val(orig.GetOdataType())
switch category {
case textWebPartType:
temp := models.NewTextWebPart()
cast := orig.(models.TextWebPartable)
temp.SetInnerHtml(cast.GetInnerHtml())
temp.SetOdataType(cast.GetOdataType())
fmt.Println("Print Text Additional")
printAdditional(cast.GetAdditionalData())
fmt.Printf("WP: %+v\n", cast)
return temp
case standardWebPartType:
temp := models.NewStandardWebPart()
cast := orig.(models.StandardWebPartable)
adtl := cast.GetAdditionalData()
fmt.Println("Print Standard Additional")
printAdditional(adtl)
temp.SetData(cast.GetData())
temp.SetOdataType(cast.GetOdataType())
temp.SetWebPartType(cast.GetWebPartType())
fmt.Printf("TP: %+v\n", cast)
return temp
default:
return nil
}
}
func printAdditional(mapped map[string]any) {
if mapped == nil {
return
}
fmt.Printf("Length: %d\n", len(mapped))
for key, value := range mapped {
switch category := value.(type) {
case int, string, bool:
fmt.Printf("Key: %s Value: %+v", key, value)
default:
fmt.Printf("Key: %s Value Type: %v\n", key, category)
}
}
}
// ==============================
// Helpers
// ==============================