diff --git a/src/.golangci.yml b/src/.golangci.yml index 377c140d8..0949053cc 100644 --- a/src/.golangci.yml +++ b/src/.golangci.yml @@ -118,7 +118,7 @@ issues: linters: - forbidigo text: "context.(Background|TODO)" - - path: internal/connector/graph/betasdk + - path: internal/m365/graph/betasdk linters: - wsl - revive diff --git a/src/cli/backup/backup.go b/src/cli/backup/backup.go index 59809ef97..25a6d22e7 100644 --- a/src/cli/backup/backup.go +++ b/src/cli/backup/backup.go @@ -12,8 +12,8 @@ import ( . "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/connector/graph" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup" "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/cli/backup/exchange_e2e_test.go b/src/cli/backup/exchange_e2e_test.go index 39437de20..9400f0d90 100644 --- a/src/cli/backup/exchange_e2e_test.go +++ b/src/cli/backup/exchange_e2e_test.go @@ -19,7 +19,7 @@ import ( "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/connector/exchange" + "github.com/alcionai/corso/src/internal/m365/exchange" "github.com/alcionai/corso/src/internal/operations" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" diff --git a/src/cli/restore/exchange_e2e_test.go b/src/cli/restore/exchange_e2e_test.go index c35001f29..1f4f93601 100644 --- a/src/cli/restore/exchange_e2e_test.go +++ b/src/cli/restore/exchange_e2e_test.go @@ -14,7 +14,7 @@ import ( "github.com/alcionai/corso/src/cli/config" "github.com/alcionai/corso/src/cli/utils" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/connector/exchange" + "github.com/alcionai/corso/src/internal/m365/exchange" "github.com/alcionai/corso/src/internal/operations" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" diff --git a/src/cmd/factory/impl/common.go b/src/cmd/factory/impl/common.go index d2ccb76f5..f1b863275 100644 --- a/src/cmd/factory/impl/common.go +++ b/src/cmd/factory/impl/common.go @@ -15,9 +15,10 @@ import ( "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/common/str" - "github.com/alcionai/corso/src/internal/connector" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/account" @@ -50,7 +51,7 @@ type dataBuilderFunc func(id, now, subject, body string) []byte func generateAndRestoreItems( ctx context.Context, - gc *connector.GraphConnector, + ctrl *m365.Controller, service path.ServiceType, cat path.CategoryType, sel selectors.Selector, @@ -98,19 +99,19 @@ func generateAndRestoreItems( print.Infof(ctx, "Generating %d %s items in %s\n", howMany, cat, Destination) - return gc.ConsumeRestoreCollections(ctx, version.Backup, sel, dest, opts, dataColls, errs) + return ctrl.ConsumeRestoreCollections(ctx, version.Backup, sel, dest, opts, dataColls, errs) } // ------------------------------------------------------------------------------------------ // Common Helpers // ------------------------------------------------------------------------------------------ -func getGCAndVerifyResourceOwner( +func getControllerAndVerifyResourceOwner( ctx context.Context, - resource connector.Resource, + rc resource.Category, resourceOwner string, ) ( - *connector.GraphConnector, + *m365.Controller, account.Account, idname.Provider, error, @@ -132,17 +133,17 @@ func getGCAndVerifyResourceOwner( return nil, account.Account{}, nil, clues.Wrap(err, "finding m365 account details") } - gc, err := connector.NewGraphConnector(ctx, acct, resource) + ctrl, err := m365.NewController(ctx, acct, rc) if err != nil { return nil, account.Account{}, nil, clues.Wrap(err, "connecting to graph api") } - id, _, err := gc.PopulateOwnerIDAndNamesFrom(ctx, resourceOwner, nil) + id, _, err := ctrl.PopulateOwnerIDAndNamesFrom(ctx, resourceOwner, nil) if err != nil { return nil, account.Account{}, nil, clues.Wrap(err, "verifying user") } - return gc, acct, gc.IDNameLookup.ProviderForID(id), nil + return ctrl, acct, ctrl.IDNameLookup.ProviderForID(id), nil } type item struct { @@ -208,7 +209,7 @@ var ( ) func generateAndRestoreDriveItems( - gc *connector.GraphConnector, + ctrl *m365.Controller, resourceOwner, secondaryUserID, secondaryUserName string, acct account.Account, service path.ServiceType, @@ -232,14 +233,14 @@ func generateAndRestoreDriveItems( switch service { case path.SharePointService: - d, err := gc.AC.Stable.Client().Sites().BySiteId(resourceOwner).Drive().Get(ctx, nil) + d, err := ctrl.AC.Stable.Client().Sites().BySiteId(resourceOwner).Drive().Get(ctx, nil) if err != nil { return nil, clues.Wrap(err, "getting site's default drive") } driveID = ptr.Val(d.GetId()) default: - d, err := gc.AC.Stable.Client().Users().ByUserId(resourceOwner).Drive().Get(ctx, nil) + d, err := ctrl.AC.Stable.Client().Users().ByUserId(resourceOwner).Drive().Get(ctx, nil) if err != nil { return nil, clues.Wrap(err, "getting user's default drive") } @@ -248,7 +249,7 @@ func generateAndRestoreDriveItems( } var ( - cols []connector.OnedriveColInfo + cols []m365.OnedriveColInfo rootPath = []string{"drives", driveID, "root:"} folderAPath = []string{"drives", driveID, "root:", folderAName} @@ -262,15 +263,15 @@ func generateAndRestoreDriveItems( ) for i := 0; i < count; i++ { - col := []connector.OnedriveColInfo{ + col := []m365.OnedriveColInfo{ // basic folder and file creation { PathElements: rootPath, - Files: []connector.ItemData{ + Files: []m365.ItemData{ { Name: fmt.Sprintf("file-1st-count-%d-at-%s", i, currentTime), Data: fileAData, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: writePerm, @@ -281,13 +282,13 @@ func generateAndRestoreDriveItems( Data: fileBData, }, }, - Folders: []connector.ItemData{ + Folders: []m365.ItemData{ { Name: folderBName, }, { Name: folderAName, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: readPerm, @@ -295,7 +296,7 @@ func generateAndRestoreDriveItems( }, { Name: folderCName, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: readPerm, @@ -307,18 +308,18 @@ func generateAndRestoreDriveItems( // a folder that has permissions with an item in the folder with // the different permissions. PathElements: folderAPath, - Files: []connector.ItemData{ + Files: []m365.ItemData{ { Name: fmt.Sprintf("file-count-%d-at-%s", i, currentTime), Data: fileEData, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: writePerm, }, }, }, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: readPerm, @@ -328,13 +329,13 @@ func generateAndRestoreDriveItems( // a folder that has permissions with an item in the folder with // no permissions. PathElements: folderCPath, - Files: []connector.ItemData{ + Files: []m365.ItemData{ { Name: fmt.Sprintf("file-count-%d-at-%s", i, currentTime), Data: fileAData, }, }, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: readPerm, @@ -342,23 +343,23 @@ func generateAndRestoreDriveItems( }, { PathElements: folderBPath, - Files: []connector.ItemData{ + Files: []m365.ItemData{ { // restoring a file in a non-root folder that doesn't inherit // permissions. Name: fmt.Sprintf("file-count-%d-at-%s", i, currentTime), Data: fileBData, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: writePerm, }, }, }, - Folders: []connector.ItemData{ + Folders: []m365.ItemData{ { Name: folderAName, - Perms: connector.PermData{ + Perms: m365.PermData{ User: secondaryUserName, EntityID: secondaryUserID, Roles: readPerm, @@ -371,7 +372,7 @@ func generateAndRestoreDriveItems( cols = append(cols, col...) } - input, err := connector.DataForInfo(service, cols, version.Backup) + input, err := m365.DataForInfo(service, cols, version.Backup) if err != nil { return nil, err } @@ -388,16 +389,16 @@ func generateAndRestoreDriveItems( ToggleFeatures: control.Toggles{}, } - config := connector.ConfigInfo{ + config := m365.ConfigInfo{ Opts: opts, - Resource: connector.Users, + Resource: resource.Users, Service: service, Tenant: tenantID, ResourceOwners: []string{resourceOwner}, RestoreCfg: tester.DefaultTestRestoreConfig(""), } - _, _, collections, _, err := connector.GetCollectionsAndExpected( + _, _, collections, _, err := m365.GetCollectionsAndExpected( config, input, version.Backup) @@ -405,5 +406,5 @@ func generateAndRestoreDriveItems( return nil, err } - return gc.ConsumeRestoreCollections(ctx, version.Backup, sel, dest, opts, collections, errs) + return ctrl.ConsumeRestoreCollections(ctx, version.Backup, sel, dest, opts, collections, errs) } diff --git a/src/cmd/factory/impl/exchange.go b/src/cmd/factory/impl/exchange.go index bc6b666be..dd304e2e9 100644 --- a/src/cmd/factory/impl/exchange.go +++ b/src/cmd/factory/impl/exchange.go @@ -5,8 +5,8 @@ import ( . "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" - "github.com/alcionai/corso/src/internal/connector" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" @@ -52,14 +52,14 @@ func handleExchangeEmailFactory(cmd *cobra.Command, args []string) error { return nil } - gc, _, _, err := getGCAndVerifyResourceOwner(ctx, connector.Users, User) + ctrl, _, _, err := getControllerAndVerifyResourceOwner(ctx, resource.Users, User) if err != nil { return Only(ctx, err) } deets, err := generateAndRestoreItems( ctx, - gc, + ctrl, service, category, selectors.NewExchangeRestore([]string{User}).Selector, @@ -98,14 +98,14 @@ func handleExchangeCalendarEventFactory(cmd *cobra.Command, args []string) error return nil } - gc, _, _, err := getGCAndVerifyResourceOwner(ctx, connector.Users, User) + ctrl, _, _, err := getControllerAndVerifyResourceOwner(ctx, resource.Users, User) if err != nil { return Only(ctx, err) } deets, err := generateAndRestoreItems( ctx, - gc, + ctrl, service, category, selectors.NewExchangeRestore([]string{User}).Selector, @@ -143,14 +143,14 @@ func handleExchangeContactFactory(cmd *cobra.Command, args []string) error { return nil } - gc, _, _, err := getGCAndVerifyResourceOwner(ctx, connector.Users, User) + ctrl, _, _, err := getControllerAndVerifyResourceOwner(ctx, resource.Users, User) if err != nil { return Only(ctx, err) } deets, err := generateAndRestoreItems( ctx, - gc, + ctrl, service, category, selectors.NewExchangeRestore([]string{User}).Selector, diff --git a/src/cmd/factory/impl/onedrive.go b/src/cmd/factory/impl/onedrive.go index 62ebcc71a..750fa64a3 100644 --- a/src/cmd/factory/impl/onedrive.go +++ b/src/cmd/factory/impl/onedrive.go @@ -7,7 +7,7 @@ import ( . "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" - "github.com/alcionai/corso/src/internal/connector" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/path" @@ -36,7 +36,7 @@ func handleOneDriveFileFactory(cmd *cobra.Command, args []string) error { return nil } - gc, acct, inp, err := getGCAndVerifyResourceOwner(ctx, connector.Users, User) + ctrl, acct, inp, err := getControllerAndVerifyResourceOwner(ctx, resource.Users, User) if err != nil { return Only(ctx, err) } @@ -45,7 +45,7 @@ func handleOneDriveFileFactory(cmd *cobra.Command, args []string) error { sel.SetDiscreteOwnerIDName(inp.ID(), inp.Name()) deets, err := generateAndRestoreDriveItems( - gc, + ctrl, inp.ID(), SecondaryUser, strings.ToLower(SecondaryUser), diff --git a/src/cmd/factory/impl/sharepoint.go b/src/cmd/factory/impl/sharepoint.go index 7f50ee97b..bdcc952f5 100644 --- a/src/cmd/factory/impl/sharepoint.go +++ b/src/cmd/factory/impl/sharepoint.go @@ -7,7 +7,7 @@ import ( . "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" - "github.com/alcionai/corso/src/internal/connector" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/path" @@ -36,7 +36,7 @@ func handleSharePointLibraryFileFactory(cmd *cobra.Command, args []string) error return nil } - gc, acct, inp, err := getGCAndVerifyResourceOwner(ctx, connector.Sites, Site) + ctrl, acct, inp, err := getControllerAndVerifyResourceOwner(ctx, resource.Sites, Site) if err != nil { return Only(ctx, err) } @@ -45,7 +45,7 @@ func handleSharePointLibraryFileFactory(cmd *cobra.Command, args []string) error sel.SetDiscreteOwnerIDName(inp.ID(), inp.Name()) deets, err := generateAndRestoreDriveItems( - gc, + ctrl, inp.ID(), SecondaryUser, strings.ToLower(SecondaryUser), diff --git a/src/cmd/getM365/onedrive/get_item.go b/src/cmd/getM365/onedrive/get_item.go index 4729885f5..4e29098fd 100644 --- a/src/cmd/getM365/onedrive/get_item.go +++ b/src/cmd/getM365/onedrive/get_item.go @@ -21,7 +21,7 @@ import ( "github.com/alcionai/corso/src/cli/utils" "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/common/str" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/credentials" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/cmd/sanity_test/sanity_tests.go b/src/cmd/sanity_test/sanity_tests.go index da603d651..9304460fd 100644 --- a/src/cmd/sanity_test/sanity_tests.go +++ b/src/cmd/sanity_test/sanity_tests.go @@ -17,7 +17,7 @@ import ( "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/filters" "github.com/alcionai/corso/src/pkg/logger" diff --git a/src/internal/connector/exchange/data_collections.go b/src/internal/connector/exchange/data_collections.go deleted file mode 100644 index f607488fd..000000000 --- a/src/internal/connector/exchange/data_collections.go +++ /dev/null @@ -1,317 +0,0 @@ -package exchange - -import ( - "context" - "encoding/json" - - "github.com/alcionai/clues" - - "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/common/prefixmatcher" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" - "github.com/alcionai/corso/src/internal/data" - "github.com/alcionai/corso/src/internal/observe" - "github.com/alcionai/corso/src/pkg/control" - "github.com/alcionai/corso/src/pkg/fault" - "github.com/alcionai/corso/src/pkg/logger" - "github.com/alcionai/corso/src/pkg/path" - "github.com/alcionai/corso/src/pkg/selectors" - "github.com/alcionai/corso/src/pkg/services/m365/api" -) - -// MetadataFileNames produces the category-specific set of filenames used to -// store graph metadata such as delta tokens and folderID->path references. -func MetadataFileNames(cat path.CategoryType) []string { - switch cat { - case path.EmailCategory, path.ContactsCategory: - return []string{graph.DeltaURLsFileName, graph.PreviousPathFileName} - default: - return []string{graph.PreviousPathFileName} - } -} - -type CatDeltaPaths map[path.CategoryType]DeltaPaths - -type DeltaPaths map[string]DeltaPath - -func (dps DeltaPaths) AddDelta(k, d string) { - dp, ok := dps[k] - if !ok { - dp = DeltaPath{} - } - - dp.Delta = d - dps[k] = dp -} - -func (dps DeltaPaths) AddPath(k, p string) { - dp, ok := dps[k] - if !ok { - dp = DeltaPath{} - } - - dp.Path = p - dps[k] = dp -} - -type DeltaPath struct { - Delta string - Path string -} - -// ParseMetadataCollections produces a map of structs holding delta -// and path lookup maps. -func parseMetadataCollections( - ctx context.Context, - colls []data.RestoreCollection, -) (CatDeltaPaths, bool, error) { - // cdp stores metadata - cdp := CatDeltaPaths{ - path.ContactsCategory: {}, - path.EmailCategory: {}, - path.EventsCategory: {}, - } - - // found tracks the metadata we've loaded, to make sure we don't - // fetch overlapping copies. - found := map[path.CategoryType]map[string]struct{}{ - path.ContactsCategory: {}, - path.EmailCategory: {}, - path.EventsCategory: {}, - } - - // errors from metadata items should not stop the backup, - // but it should prevent us from using previous backups - errs := fault.New(true) - - for _, coll := range colls { - var ( - breakLoop bool - items = coll.Items(ctx, errs) - category = coll.FullPath().Category() - ) - - for { - select { - case <-ctx.Done(): - return nil, false, clues.Wrap(ctx.Err(), "parsing collection metadata").WithClues(ctx) - - case item, ok := <-items: - if !ok || errs.Failure() != nil { - breakLoop = true - break - } - - var ( - m = map[string]string{} - cdps = cdp[category] - ) - - err := json.NewDecoder(item.ToReader()).Decode(&m) - if err != nil { - return nil, false, clues.New("decoding metadata json").WithClues(ctx) - } - - switch item.UUID() { - case graph.PreviousPathFileName: - if _, ok := found[category]["path"]; ok { - return nil, false, clues.Wrap(clues.New(category.String()), "multiple versions of path metadata").WithClues(ctx) - } - - for k, p := range m { - cdps.AddPath(k, p) - } - - found[category]["path"] = struct{}{} - - case graph.DeltaURLsFileName: - if _, ok := found[category]["delta"]; ok { - return nil, false, clues.Wrap(clues.New(category.String()), "multiple versions of delta metadata").WithClues(ctx) - } - - for k, d := range m { - cdps.AddDelta(k, d) - } - - found[category]["delta"] = struct{}{} - } - - cdp[category] = cdps - } - - if breakLoop { - break - } - } - } - - if errs.Failure() != nil { - logger.CtxErr(ctx, errs.Failure()).Info("reading metadata collection items") - - return CatDeltaPaths{ - path.ContactsCategory: {}, - path.EmailCategory: {}, - path.EventsCategory: {}, - }, false, nil - } - - // Remove any entries that contain a path or a delta, but not both. - // That metadata is considered incomplete, and needs to incur a - // complete backup on the next run. - for _, dps := range cdp { - for k, dp := range dps { - if len(dp.Path) == 0 { - delete(dps, k) - } - } - } - - return cdp, true, nil -} - -// DataCollections returns a DataCollection which the caller can -// use to read mailbox data out for the specified user -func DataCollections( - ctx context.Context, - ac api.Client, - selector selectors.Selector, - tenantID string, - user idname.Provider, - metadata []data.RestoreCollection, - su support.StatusUpdater, - ctrlOpts control.Options, - errs *fault.Bus, -) ([]data.BackupCollection, *prefixmatcher.StringSetMatcher, bool, error) { - eb, err := selector.ToExchangeBackup() - if err != nil { - return nil, nil, false, clues.Wrap(err, "exchange dataCollection selector").WithClues(ctx) - } - - var ( - collections = []data.BackupCollection{} - el = errs.Local() - categories = map[path.CategoryType]struct{}{} - handlers = BackupHandlers(ac) - ) - - // Turn on concurrency limiter middleware for exchange backups - // unless explicitly disabled through DisableConcurrencyLimiterFN cli flag - if !ctrlOpts.ToggleFeatures.DisableConcurrencyLimiter { - graph.InitializeConcurrencyLimiter(ctrlOpts.Parallelism.ItemFetch) - } - - cdps, canUsePreviousBackup, err := parseMetadataCollections(ctx, metadata) - if err != nil { - return nil, nil, false, err - } - - for _, scope := range eb.Scopes() { - if el.Failure() != nil { - break - } - - dcs, err := createCollections( - ctx, - handlers, - tenantID, - user, - scope, - cdps[scope.Category().PathType()], - ctrlOpts, - su, - errs) - if err != nil { - el.AddRecoverable(err) - continue - } - - categories[scope.Category().PathType()] = struct{}{} - - collections = append(collections, dcs...) - } - - if len(collections) > 0 { - baseCols, err := graph.BaseCollections( - ctx, - collections, - tenantID, - user.ID(), - path.ExchangeService, - categories, - su, - errs) - if err != nil { - return nil, nil, false, err - } - - collections = append(collections, baseCols...) - } - - return collections, nil, canUsePreviousBackup, el.Failure() -} - -// createCollections - utility function that retrieves M365 -// IDs through Microsoft Graph API. The selectors.ExchangeScope -// determines the type of collections that are retrieved. -func createCollections( - ctx context.Context, - handlers map[path.CategoryType]backupHandler, - tenantID string, - user idname.Provider, - scope selectors.ExchangeScope, - dps DeltaPaths, - ctrlOpts control.Options, - su support.StatusUpdater, - errs *fault.Bus, -) ([]data.BackupCollection, error) { - ctx = clues.Add(ctx, "category", scope.Category().PathType()) - - var ( - allCollections = make([]data.BackupCollection, 0) - category = scope.Category().PathType() - qp = graph.QueryParams{ - Category: category, - ResourceOwner: user, - TenantID: tenantID, - } - ) - - handler, ok := handlers[category] - if !ok { - return nil, clues.New("unsupported backup category type").WithClues(ctx) - } - - foldersComplete := observe.MessageWithCompletion( - ctx, - observe.Bulletf("%s", qp.Category)) - defer close(foldersComplete) - - rootFolder, cc := handler.NewContainerCache(user.ID()) - - if err := cc.Populate(ctx, errs, rootFolder); err != nil { - return nil, clues.Wrap(err, "populating container cache") - } - - collections, err := filterContainersAndFillCollections( - ctx, - qp, - handler, - su, - cc, - scope, - dps, - ctrlOpts, - errs) - if err != nil { - return nil, clues.Wrap(err, "filling collections") - } - - foldersComplete <- struct{}{} - - for _, coll := range collections { - allCollections = append(allCollections, coll) - } - - return allCollections, nil -} diff --git a/src/internal/connector/exchange/data_collections_test.go b/src/internal/connector/exchange/data_collections_test.go deleted file mode 100644 index 212024fb9..000000000 --- a/src/internal/connector/exchange/data_collections_test.go +++ /dev/null @@ -1,761 +0,0 @@ -package exchange - -import ( - "bytes" - "context" - "sync" - "testing" - - "github.com/alcionai/clues" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - inMock "github.com/alcionai/corso/src/internal/common/idname/mock" - "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" - "github.com/alcionai/corso/src/internal/data" - "github.com/alcionai/corso/src/internal/tester" - "github.com/alcionai/corso/src/pkg/control" - "github.com/alcionai/corso/src/pkg/fault" - "github.com/alcionai/corso/src/pkg/path" - "github.com/alcionai/corso/src/pkg/selectors" - "github.com/alcionai/corso/src/pkg/services/m365/api" -) - -// --------------------------------------------------------------------------- -// Unit tests -// --------------------------------------------------------------------------- - -type DataCollectionsUnitSuite struct { - tester.Suite -} - -func TestDataCollectionsUnitSuite(t *testing.T) { - suite.Run(t, &DataCollectionsUnitSuite{Suite: tester.NewUnitSuite(t)}) -} - -func (suite *DataCollectionsUnitSuite) TestParseMetadataCollections() { - type fileValues struct { - fileName string - value string - } - - table := []struct { - name string - data []fileValues - expect map[string]DeltaPath - canUsePreviousBackup bool - expectError assert.ErrorAssertionFunc - }{ - { - name: "delta urls only", - data: []fileValues{ - {graph.DeltaURLsFileName, "delta-link"}, - }, - expect: map[string]DeltaPath{}, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - { - name: "multiple delta urls", - data: []fileValues{ - {graph.DeltaURLsFileName, "delta-link"}, - {graph.DeltaURLsFileName, "delta-link-2"}, - }, - canUsePreviousBackup: false, - expectError: assert.Error, - }, - { - name: "previous path only", - data: []fileValues{ - {graph.PreviousPathFileName, "prev-path"}, - }, - expect: map[string]DeltaPath{ - "key": { - Delta: "delta-link", - Path: "prev-path", - }, - }, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - { - name: "multiple previous paths", - data: []fileValues{ - {graph.PreviousPathFileName, "prev-path"}, - {graph.PreviousPathFileName, "prev-path-2"}, - }, - canUsePreviousBackup: false, - expectError: assert.Error, - }, - { - name: "delta urls and previous paths", - data: []fileValues{ - {graph.DeltaURLsFileName, "delta-link"}, - {graph.PreviousPathFileName, "prev-path"}, - }, - expect: map[string]DeltaPath{ - "key": { - Delta: "delta-link", - Path: "prev-path", - }, - }, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - { - name: "delta urls and empty previous paths", - data: []fileValues{ - {graph.DeltaURLsFileName, "delta-link"}, - {graph.PreviousPathFileName, ""}, - }, - expect: map[string]DeltaPath{}, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - { - name: "empty delta urls and previous paths", - data: []fileValues{ - {graph.DeltaURLsFileName, ""}, - {graph.PreviousPathFileName, "prev-path"}, - }, - expect: map[string]DeltaPath{ - "key": { - Delta: "delta-link", - Path: "prev-path", - }, - }, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - { - name: "delta urls with special chars", - data: []fileValues{ - {graph.DeltaURLsFileName, "`!@#$%^&*()_[]{}/\"\\"}, - {graph.PreviousPathFileName, "prev-path"}, - }, - expect: map[string]DeltaPath{ - "key": { - Delta: "`!@#$%^&*()_[]{}/\"\\", - Path: "prev-path", - }, - }, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - { - name: "delta urls with escaped chars", - data: []fileValues{ - {graph.DeltaURLsFileName, `\n\r\t\b\f\v\0\\`}, - {graph.PreviousPathFileName, "prev-path"}, - }, - expect: map[string]DeltaPath{ - "key": { - Delta: "\\n\\r\\t\\b\\f\\v\\0\\\\", - Path: "prev-path", - }, - }, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - { - name: "delta urls with newline char runes", - data: []fileValues{ - // rune(92) = \, rune(110) = n. Ensuring it's not possible to - // error in serializing/deserializing and produce a single newline - // character from those two runes. - {graph.DeltaURLsFileName, string([]rune{rune(92), rune(110)})}, - {graph.PreviousPathFileName, "prev-path"}, - }, - expect: map[string]DeltaPath{ - "key": { - Delta: "\\n", - Path: "prev-path", - }, - }, - canUsePreviousBackup: true, - expectError: assert.NoError, - }, - } - for _, test := range table { - suite.Run(test.name, func() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - entries := []graph.MetadataCollectionEntry{} - - for _, d := range test.data { - entries = append( - entries, - graph.NewMetadataEntry(d.fileName, map[string]string{"key": d.value})) - } - - coll, err := graph.MakeMetadataCollection( - "t", "u", - path.ExchangeService, - path.EmailCategory, - entries, - func(cos *support.ConnectorOperationStatus) {}, - ) - require.NoError(t, err, clues.ToCore(err)) - - cdps, canUsePreviousBackup, err := parseMetadataCollections(ctx, []data.RestoreCollection{ - data.NoFetchRestoreCollection{Collection: coll}, - }) - test.expectError(t, err, clues.ToCore(err)) - - assert.Equal(t, test.canUsePreviousBackup, canUsePreviousBackup, "can use previous backup") - - emails := cdps[path.EmailCategory] - - assert.Len(t, emails, len(test.expect)) - - for k, v := range emails { - assert.Equal(t, v.Delta, emails[k].Delta, "delta") - assert.Equal(t, v.Path, emails[k].Path, "path") - } - }) - } -} - -type failingColl struct { - t *testing.T -} - -func (f failingColl) Items(ctx context.Context, errs *fault.Bus) <-chan data.Stream { - ic := make(chan data.Stream) - defer close(ic) - - errs.AddRecoverable(assert.AnError) - - return ic -} - -func (f failingColl) FullPath() path.Path { - tmp, err := path.Build( - "tenant", - "user", - path.ExchangeService, - path.EmailCategory, - false, - "inbox") - require.NoError(f.t, err, clues.ToCore(err)) - - return tmp -} - -func (f failingColl) FetchItemByName(context.Context, string) (data.Stream, error) { - // no fetch calls will be made - return nil, nil -} - -// This check is to ensure that we don't error out, but still return -// canUsePreviousBackup as false on read errors -func (suite *DataCollectionsUnitSuite) TestParseMetadataCollections_ReadFailure() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - fc := failingColl{t} - - _, canUsePreviousBackup, err := parseMetadataCollections(ctx, []data.RestoreCollection{fc}) - require.NoError(t, err) - require.False(t, canUsePreviousBackup) -} - -// --------------------------------------------------------------------------- -// Integration tests -// --------------------------------------------------------------------------- - -func newStatusUpdater(t *testing.T, wg *sync.WaitGroup) func(status *support.ConnectorOperationStatus) { - updater := func(status *support.ConnectorOperationStatus) { - defer wg.Done() - } - - return updater -} - -type DataCollectionsIntegrationSuite struct { - tester.Suite - user string - site string - tenantID string - ac api.Client -} - -func TestDataCollectionsIntegrationSuite(t *testing.T) { - suite.Run(t, &DataCollectionsIntegrationSuite{ - Suite: tester.NewIntegrationSuite( - t, - [][]string{tester.M365AcctCredEnvs}, - ), - }) -} - -func (suite *DataCollectionsIntegrationSuite) SetupSuite() { - suite.user = tester.M365UserID(suite.T()) - suite.site = tester.M365SiteID(suite.T()) - - acct := tester.NewM365Account(suite.T()) - creds, err := acct.M365Config() - require.NoError(suite.T(), err, clues.ToCore(err)) - - suite.ac, err = api.NewClient(creds) - require.NoError(suite.T(), err, clues.ToCore(err)) - - suite.tenantID = creds.AzureTenantID - - tester.LogTimeOfTest(suite.T()) -} - -func (suite *DataCollectionsIntegrationSuite) TestMailFetch() { - var ( - userID = tester.M365UserID(suite.T()) - users = []string{userID} - handlers = BackupHandlers(suite.ac) - ) - - tests := []struct { - name string - scope selectors.ExchangeScope - folderNames map[string]struct{} - canMakeDeltaQueries bool - }{ - { - name: "Folder Iterative Check Mail", - scope: selectors.NewExchangeBackup(users).MailFolders( - []string{DefaultMailFolder}, - selectors.PrefixMatch(), - )[0], - folderNames: map[string]struct{}{ - DefaultMailFolder: {}, - }, - canMakeDeltaQueries: true, - }, - { - name: "Folder Iterative Check Mail Non-Delta", - scope: selectors.NewExchangeBackup(users).MailFolders( - []string{DefaultMailFolder}, - selectors.PrefixMatch(), - )[0], - folderNames: map[string]struct{}{ - DefaultMailFolder: {}, - }, - canMakeDeltaQueries: false, - }, - } - - for _, test := range tests { - suite.Run(test.name, func() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - ctrlOpts := control.Defaults() - ctrlOpts.ToggleFeatures.DisableDelta = !test.canMakeDeltaQueries - - collections, err := createCollections( - ctx, - handlers, - suite.tenantID, - inMock.NewProvider(userID, userID), - test.scope, - DeltaPaths{}, - ctrlOpts, - func(status *support.ConnectorOperationStatus) {}, - fault.New(true)) - require.NoError(t, err, clues.ToCore(err)) - - for _, c := range collections { - if c.FullPath().Service() == path.ExchangeMetadataService { - continue - } - - require.NotEmpty(t, c.FullPath().Folder(false)) - - // TODO(ashmrtn): Remove when LocationPath is made part of BackupCollection - // interface. - if !assert.Implements(t, (*data.LocationPather)(nil), c) { - continue - } - - loc := c.(data.LocationPather).LocationPath().String() - - require.NotEmpty(t, loc) - - delete(test.folderNames, loc) - } - - assert.Empty(t, test.folderNames) - }) - } -} - -func (suite *DataCollectionsIntegrationSuite) TestDelta() { - var ( - userID = tester.M365UserID(suite.T()) - users = []string{userID} - handlers = BackupHandlers(suite.ac) - ) - - tests := []struct { - name string - scope selectors.ExchangeScope - }{ - { - name: "Mail", - scope: selectors.NewExchangeBackup(users).MailFolders( - []string{DefaultMailFolder}, - selectors.PrefixMatch(), - )[0], - }, - { - name: "Contacts", - scope: selectors.NewExchangeBackup(users).ContactFolders( - []string{DefaultContactFolder}, - selectors.PrefixMatch(), - )[0], - }, - { - name: "Events", - scope: selectors.NewExchangeBackup(users).EventCalendars( - []string{DefaultCalendar}, - selectors.PrefixMatch(), - )[0], - }, - } - for _, test := range tests { - suite.Run(test.name, func() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - // get collections without providing any delta history (ie: full backup) - collections, err := createCollections( - ctx, - handlers, - suite.tenantID, - inMock.NewProvider(userID, userID), - test.scope, - DeltaPaths{}, - control.Defaults(), - func(status *support.ConnectorOperationStatus) {}, - fault.New(true)) - require.NoError(t, err, clues.ToCore(err)) - assert.Less(t, 1, len(collections), "retrieved metadata and data collections") - - var metadata data.BackupCollection - - for _, coll := range collections { - if coll.FullPath().Service() == path.ExchangeMetadataService { - metadata = coll - } - } - - require.NotNil(t, metadata, "collections contains a metadata collection") - - cdps, canUsePreviousBackup, err := parseMetadataCollections(ctx, []data.RestoreCollection{ - data.NoFetchRestoreCollection{Collection: metadata}, - }) - require.NoError(t, err, clues.ToCore(err)) - assert.True(t, canUsePreviousBackup, "can use previous backup") - - dps := cdps[test.scope.Category().PathType()] - - // now do another backup with the previous delta tokens, - // which should only contain the difference. - collections, err = createCollections( - ctx, - handlers, - suite.tenantID, - inMock.NewProvider(userID, userID), - test.scope, - dps, - control.Defaults(), - func(status *support.ConnectorOperationStatus) {}, - fault.New(true)) - require.NoError(t, err, clues.ToCore(err)) - - // TODO(keepers): this isn't a very useful test at the moment. It needs to - // investigate the items in the original and delta collections to at least - // assert some minimum assumptions, such as "deltas should retrieve fewer items". - // Delta usage is commented out at the moment, anyway. So this is currently - // a sanity check that the minimum behavior won't break. - for _, coll := range collections { - if coll.FullPath().Service() != path.ExchangeMetadataService { - ec, ok := coll.(*Collection) - require.True(t, ok, "collection is *Collection") - assert.NotNil(t, ec) - } - } - }) - } -} - -// TestMailSerializationRegression verifies that all mail data stored in the -// test account can be successfully downloaded into bytes and restored into -// M365 mail objects -func (suite *DataCollectionsIntegrationSuite) TestMailSerializationRegression() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - var ( - wg sync.WaitGroup - users = []string{suite.user} - handlers = BackupHandlers(suite.ac) - ) - - sel := selectors.NewExchangeBackup(users) - sel.Include(sel.MailFolders([]string{DefaultMailFolder}, selectors.PrefixMatch())) - - collections, err := createCollections( - ctx, - handlers, - suite.tenantID, - inMock.NewProvider(suite.user, suite.user), - sel.Scopes()[0], - DeltaPaths{}, - control.Defaults(), - newStatusUpdater(t, &wg), - fault.New(true)) - require.NoError(t, err, clues.ToCore(err)) - - wg.Add(len(collections)) - - for _, edc := range collections { - suite.Run(edc.FullPath().String(), func() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - isMetadata := edc.FullPath().Service() == path.ExchangeMetadataService - streamChannel := edc.Items(ctx, fault.New(true)) - - // Verify that each message can be restored - for stream := range streamChannel { - buf := &bytes.Buffer{} - - read, err := buf.ReadFrom(stream.ToReader()) - assert.NoError(t, err, clues.ToCore(err)) - assert.NotZero(t, read) - - if isMetadata { - continue - } - - message, err := api.BytesToMessageable(buf.Bytes()) - assert.NotNil(t, message) - assert.NoError(t, err, clues.ToCore(err)) - } - }) - } - - wg.Wait() -} - -// TestContactSerializationRegression verifies ability to query contact items -// and to store contact within Collection. Downloaded contacts are run through -// a regression test to ensure that downloaded items can be uploaded. -func (suite *DataCollectionsIntegrationSuite) TestContactSerializationRegression() { - var ( - users = []string{suite.user} - handlers = BackupHandlers(suite.ac) - ) - - tests := []struct { - name string - scope selectors.ExchangeScope - }{ - { - name: "Default Contact Folder", - scope: selectors.NewExchangeBackup(users).ContactFolders( - []string{DefaultContactFolder}, - selectors.PrefixMatch())[0], - }, - } - - for _, test := range tests { - suite.Run(test.name, func() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - var wg sync.WaitGroup - - edcs, err := createCollections( - ctx, - handlers, - suite.tenantID, - inMock.NewProvider(suite.user, suite.user), - test.scope, - DeltaPaths{}, - control.Defaults(), - newStatusUpdater(t, &wg), - fault.New(true)) - require.NoError(t, err, clues.ToCore(err)) - - wg.Add(len(edcs)) - - require.GreaterOrEqual(t, len(edcs), 1, "expected 1 <= num collections <= 2") - require.GreaterOrEqual(t, 2, len(edcs), "expected 1 <= num collections <= 2") - - for _, edc := range edcs { - isMetadata := edc.FullPath().Service() == path.ExchangeMetadataService - count := 0 - - for stream := range edc.Items(ctx, fault.New(true)) { - buf := &bytes.Buffer{} - read, err := buf.ReadFrom(stream.ToReader()) - assert.NoError(t, err, clues.ToCore(err)) - assert.NotZero(t, read) - - if isMetadata { - continue - } - - contact, err := api.BytesToContactable(buf.Bytes()) - assert.NotNil(t, contact) - assert.NoError(t, err, "converting contact bytes: "+buf.String(), clues.ToCore(err)) - count++ - } - - if isMetadata { - continue - } - - // TODO(ashmrtn): Remove when LocationPath is made part of BackupCollection - // interface. - if !assert.Implements(t, (*data.LocationPather)(nil), edc) { - continue - } - - assert.Equal( - t, - edc.(data.LocationPather).LocationPath().String(), - DefaultContactFolder) - assert.NotZero(t, count) - } - - wg.Wait() - }) - } -} - -// TestEventsSerializationRegression ensures functionality of createCollections -// to be able to successfully query, download and restore event objects -func (suite *DataCollectionsIntegrationSuite) TestEventsSerializationRegression() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - var ( - users = []string{suite.user} - handlers = BackupHandlers(suite.ac) - calID string - bdayID string - ) - - fn := func(gcf graph.CachedContainer) error { - if ptr.Val(gcf.GetDisplayName()) == DefaultCalendar { - calID = ptr.Val(gcf.GetId()) - } - - if ptr.Val(gcf.GetDisplayName()) == "Birthdays" { - bdayID = ptr.Val(gcf.GetId()) - } - - return nil - } - - err := suite.ac.Events().EnumerateContainers(ctx, suite.user, DefaultCalendar, fn, fault.New(true)) - require.NoError(t, err, clues.ToCore(err)) - - tests := []struct { - name, expected string - scope selectors.ExchangeScope - }{ - { - name: "Default Event Calendar", - expected: calID, - scope: selectors.NewExchangeBackup(users).EventCalendars( - []string{DefaultCalendar}, - selectors.PrefixMatch(), - )[0], - }, - { - name: "Birthday Calendar", - expected: bdayID, - scope: selectors.NewExchangeBackup(users).EventCalendars( - []string{"Birthdays"}, - selectors.PrefixMatch(), - )[0], - }, - } - - for _, test := range tests { - suite.Run(test.name, func() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - var wg sync.WaitGroup - - collections, err := createCollections( - ctx, - handlers, - suite.tenantID, - inMock.NewProvider(suite.user, suite.user), - test.scope, - DeltaPaths{}, - control.Defaults(), - newStatusUpdater(t, &wg), - fault.New(true)) - require.NoError(t, err, clues.ToCore(err)) - require.Len(t, collections, 2) - - wg.Add(len(collections)) - - for _, edc := range collections { - var isMetadata bool - - if edc.FullPath().Service() != path.ExchangeMetadataService { - isMetadata = true - assert.Equal(t, test.expected, edc.FullPath().Folder(false)) - } else { - assert.Equal(t, "", edc.FullPath().Folder(false)) - } - - for item := range edc.Items(ctx, fault.New(true)) { - buf := &bytes.Buffer{} - - read, err := buf.ReadFrom(item.ToReader()) - assert.NoError(t, err, clues.ToCore(err)) - assert.NotZero(t, read) - - if isMetadata { - continue - } - - event, err := api.BytesToEventable(buf.Bytes()) - assert.NotNil(t, event) - assert.NoError(t, err, "creating event from bytes: "+buf.String(), clues.ToCore(err)) - } - } - - wg.Wait() - }) - } -} diff --git a/src/internal/connector/exchange/folder_resolver_test.go b/src/internal/connector/exchange/folder_resolver_test.go deleted file mode 100644 index 6ba78f464..000000000 --- a/src/internal/connector/exchange/folder_resolver_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package exchange - -import ( - "testing" - - "github.com/alcionai/clues" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/tester" - "github.com/alcionai/corso/src/pkg/account" - "github.com/alcionai/corso/src/pkg/fault" - "github.com/alcionai/corso/src/pkg/services/m365/api" -) - -type CacheResolverSuite struct { - tester.Suite - credentials account.M365Config -} - -func TestCacheResolverIntegrationSuite(t *testing.T) { - suite.Run(t, &CacheResolverSuite{ - Suite: tester.NewIntegrationSuite( - t, - [][]string{tester.M365AcctCredEnvs}, - ), - }) -} - -func (suite *CacheResolverSuite) SetupSuite() { - t := suite.T() - - a := tester.NewM365Account(t) - m365, err := a.M365Config() - require.NoError(t, err, clues.ToCore(err)) - - suite.credentials = m365 -} - -func (suite *CacheResolverSuite) TestPopulate() { - ac, err := api.NewClient(suite.credentials) - require.NoError(suite.T(), err, clues.ToCore(err)) - - eventFunc := func(t *testing.T) graph.ContainerResolver { - return &eventCalendarCache{ - userID: tester.M365UserID(t), - enumer: ac.Events(), - getter: ac.Events(), - } - } - - contactFunc := func(t *testing.T) graph.ContainerResolver { - return &contactFolderCache{ - userID: tester.M365UserID(t), - enumer: ac.Contacts(), - getter: ac.Contacts(), - } - } - - tests := []struct { - name, folderInCache, root, basePath string - resolverFunc func(t *testing.T) graph.ContainerResolver - canFind assert.BoolAssertionFunc - }{ - { - name: "Default Event Cache", - // Fine as long as this isn't running against a migrated Exchange server. - folderInCache: DefaultCalendar, - root: DefaultCalendar, - basePath: DefaultCalendar, - resolverFunc: eventFunc, - canFind: assert.True, - }, - { - name: "Default Event Folder Hidden", - folderInCache: DefaultContactFolder, - root: DefaultCalendar, - canFind: assert.False, - resolverFunc: eventFunc, - }, - { - name: "Name Not in Cache", - folderInCache: "testFooBarWhoBar", - root: DefaultCalendar, - canFind: assert.False, - resolverFunc: eventFunc, - }, - { - name: "Default Contact Cache", - folderInCache: DefaultContactFolder, - root: DefaultContactFolder, - basePath: DefaultContactFolder, - canFind: assert.True, - resolverFunc: contactFunc, - }, - { - name: "Default Contact Hidden", - folderInCache: DefaultContactFolder, - root: DefaultContactFolder, - canFind: assert.False, - resolverFunc: contactFunc, - }, - { - name: "Name Not in Cache", - folderInCache: "testFooBarWhoBar", - root: DefaultContactFolder, - canFind: assert.False, - resolverFunc: contactFunc, - }, - } - for _, test := range tests { - suite.Run(test.name, func() { - t := suite.T() - - ctx, flush := tester.NewContext(t) - defer flush() - - resolver := test.resolverFunc(t) - - err := resolver.Populate(ctx, fault.New(true), test.root, test.basePath) - require.NoError(t, err, clues.ToCore(err)) - - _, isFound := resolver.LocationInCache(test.folderInCache) - test.canFind(t, isFound, "folder path", test.folderInCache) - }) - } -} diff --git a/src/internal/connector/exchange/iterators_test.go b/src/internal/connector/exchange/iterators_test.go deleted file mode 100644 index 7938dfff8..000000000 --- a/src/internal/connector/exchange/iterators_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package exchange - -import ( - "testing" - - "github.com/alcionai/clues" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/tester" - "github.com/alcionai/corso/src/pkg/services/m365/api" -) - -type ExchangeIteratorSuite struct { - tester.Suite -} - -func TestExchangeIteratorSuite(t *testing.T) { - suite.Run(t, &ExchangeIteratorSuite{Suite: tester.NewUnitSuite(t)}) -} - -func (suite *ExchangeIteratorSuite) TestDisplayable() { - t := suite.T() - bytes := exchMock.ContactBytes("Displayable") - contact, err := api.BytesToContactable(bytes) - require.NoError(t, err, clues.ToCore(err)) - - aDisplayable, ok := contact.(graph.Displayable) - assert.True(t, ok) - assert.NotNil(t, aDisplayable.GetId()) - assert.NotNil(t, aDisplayable.GetDisplayName()) -} - -func (suite *ExchangeIteratorSuite) TestDescendable() { - t := suite.T() - bytes := exchMock.MessageBytes("Descendable") - message, err := api.BytesToMessageable(bytes) - require.NoError(t, err, clues.ToCore(err)) - - aDescendable, ok := message.(graph.Descendable) - assert.True(t, ok) - assert.NotNil(t, aDescendable.GetId()) - assert.NotNil(t, aDescendable.GetParentFolderId()) -} diff --git a/src/internal/kopia/data_collection_test.go b/src/internal/kopia/data_collection_test.go index a6c2a8b97..318af2682 100644 --- a/src/internal/kopia/data_collection_test.go +++ b/src/internal/kopia/data_collection_test.go @@ -13,8 +13,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" "github.com/alcionai/corso/src/internal/data" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/internal/kopia/merge_collection_test.go b/src/internal/kopia/merge_collection_test.go index bd5579e08..4ffd8d394 100644 --- a/src/internal/kopia/merge_collection_test.go +++ b/src/internal/kopia/merge_collection_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/exchange/mock" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/internal/kopia/upload.go b/src/internal/kopia/upload.go index a1cc0bed2..4a610c892 100644 --- a/src/internal/kopia/upload.go +++ b/src/internal/kopia/upload.go @@ -22,10 +22,10 @@ import ( "github.com/kopia/kopia/snapshot/snapshotfs" "github.com/alcionai/corso/src/internal/common/prefixmatcher" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/graph/metadata" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/graph/metadata" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" diff --git a/src/internal/kopia/upload_test.go b/src/internal/kopia/upload_test.go index 32ed10364..fba178fdf 100644 --- a/src/internal/kopia/upload_test.go +++ b/src/internal/kopia/upload_test.go @@ -20,8 +20,8 @@ import ( "github.com/stretchr/testify/suite" pmMock "github.com/alcionai/corso/src/internal/common/prefixmatcher/mock" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" "github.com/alcionai/corso/src/internal/data" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" diff --git a/src/internal/kopia/wrapper_test.go b/src/internal/kopia/wrapper_test.go index 750a08432..19d6e1a4d 100644 --- a/src/internal/kopia/wrapper_test.go +++ b/src/internal/kopia/wrapper_test.go @@ -19,10 +19,10 @@ import ( "golang.org/x/exp/maps" pmMock "github.com/alcionai/corso/src/internal/common/prefixmatcher/mock" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/data/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control/repository" diff --git a/src/internal/connector/data_collections.go b/src/internal/m365/backup.go similarity index 67% rename from src/internal/connector/data_collections.go rename to src/internal/m365/backup.go index 0d836820e..f3af44e62 100644 --- a/src/internal/connector/data_collections.go +++ b/src/internal/m365/backup.go @@ -1,4 +1,4 @@ -package connector +package m365 import ( "context" @@ -8,15 +8,13 @@ import ( "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/prefixmatcher" - "github.com/alcionai/corso/src/internal/connector/discovery" - "github.com/alcionai/corso/src/internal/connector/exchange" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/onedrive" - "github.com/alcionai/corso/src/internal/connector/sharepoint" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" - "github.com/alcionai/corso/src/pkg/backup/details" + "github.com/alcionai/corso/src/internal/m365/discovery" + "github.com/alcionai/corso/src/internal/m365/exchange" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive" + "github.com/alcionai/corso/src/internal/m365/sharepoint" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/filters" @@ -34,7 +32,7 @@ import ( // The metadata field can include things like delta tokens or the previous backup's // folder hierarchy. The absence of metadata causes the collection creation to ignore // prior history (ie, incrementals) and run a full backup. -func (gc *GraphConnector) ProduceBackupCollections( +func (ctrl *Controller) ProduceBackupCollections( ctx context.Context, owner idname.Provider, sels selectors.Selector, @@ -45,7 +43,7 @@ func (gc *GraphConnector) ProduceBackupCollections( ) ([]data.BackupCollection, prefixmatcher.StringSetReader, bool, error) { ctx, end := diagnostics.Span( ctx, - "gc:produceBackupCollections", + "m365:produceBackupCollections", diagnostics.Index("service", sels.Service.String())) defer end() @@ -55,14 +53,14 @@ func (gc *GraphConnector) ProduceBackupCollections( ctrlOpts.Parallelism.ItemFetch = graph.Parallelism(sels.PathService()). ItemOverride(ctx, ctrlOpts.Parallelism.ItemFetch) - err := verifyBackupInputs(sels, gc.IDNameLookup.IDs()) + err := verifyBackupInputs(sels, ctrl.IDNameLookup.IDs()) if err != nil { return nil, nil, false, clues.Stack(err).WithClues(ctx) } serviceEnabled, canMakeDeltaQueries, err := checkServiceEnabled( ctx, - gc.AC.Users(), + ctrl.AC.Users(), path.ServiceType(sels.Service), sels.DiscreteOwner) if err != nil { @@ -87,14 +85,14 @@ func (gc *GraphConnector) ProduceBackupCollections( switch sels.Service { case selectors.ServiceExchange: - colls, ssmb, canUsePreviousBackup, err = exchange.DataCollections( + colls, ssmb, canUsePreviousBackup, err = exchange.ProduceBackupCollections( ctx, - gc.AC, + ctrl.AC, sels, - gc.credentials.AzureTenantID, + ctrl.credentials.AzureTenantID, owner, metadata, - gc.UpdateStatus, + ctrl.UpdateStatus, ctrlOpts, errs) if err != nil { @@ -102,15 +100,15 @@ func (gc *GraphConnector) ProduceBackupCollections( } case selectors.ServiceOneDrive: - colls, ssmb, canUsePreviousBackup, err = onedrive.DataCollections( + colls, ssmb, canUsePreviousBackup, err = onedrive.ProduceBackupCollections( ctx, - gc.AC, + ctrl.AC, sels, owner, metadata, lastBackupVersion, - gc.credentials.AzureTenantID, - gc.UpdateStatus, + ctrl.credentials.AzureTenantID, + ctrl.UpdateStatus, ctrlOpts, errs) if err != nil { @@ -118,14 +116,14 @@ func (gc *GraphConnector) ProduceBackupCollections( } case selectors.ServiceSharePoint: - colls, ssmb, canUsePreviousBackup, err = sharepoint.DataCollections( + colls, ssmb, canUsePreviousBackup, err = sharepoint.ProduceBackupCollections( ctx, - gc.AC, + ctrl.AC, sels, owner, metadata, - gc.credentials, - gc, + ctrl.credentials, + ctrl, ctrlOpts, errs) if err != nil { @@ -144,7 +142,7 @@ func (gc *GraphConnector) ProduceBackupCollections( // break the process state, putting us into deadlock or // panics. if c.State() != data.DeletedState { - gc.incrementAwaitingMessages() + ctrl.incrementAwaitingMessages() } } @@ -154,7 +152,7 @@ func (gc *GraphConnector) ProduceBackupCollections( // IsBackupRunnable verifies that the users provided has the services enabled and // data can be backed up. The canMakeDeltaQueries provides info if the mailbox is // full and delta queries can be made on it. -func (gc *GraphConnector) IsBackupRunnable( +func (ctrl *Controller) IsBackupRunnable( ctx context.Context, service path.ServiceType, resourceOwner string, @@ -164,7 +162,7 @@ func (gc *GraphConnector) IsBackupRunnable( return true, nil } - info, err := gc.AC.Users().GetInfo(ctx, resourceOwner) + info, err := ctrl.AC.Users().GetInfo(ctx, resourceOwner) if err != nil { return false, err } @@ -225,59 +223,3 @@ func checkServiceEnabled( return true, canMakeDeltaQueries, nil } - -// ConsumeRestoreCollections restores data from the specified collections -// into M365 using the GraphAPI. -// SideEffect: gc.status is updated at the completion of operation -func (gc *GraphConnector) ConsumeRestoreCollections( - ctx context.Context, - backupVersion int, - sels selectors.Selector, - restoreCfg control.RestoreConfig, - opts control.Options, - dcs []data.RestoreCollection, - errs *fault.Bus, -) (*details.Details, error) { - ctx, end := diagnostics.Span(ctx, "connector:restore") - defer end() - - ctx = graph.BindRateLimiterConfig(ctx, graph.LimiterCfg{Service: sels.PathService()}) - - var ( - status *support.ConnectorOperationStatus - deets = &details.Builder{} - err error - ) - - switch sels.Service { - case selectors.ServiceExchange: - status, err = exchange.RestoreCollections(ctx, gc.AC, restoreCfg, dcs, deets, errs) - case selectors.ServiceOneDrive: - status, err = onedrive.RestoreCollections( - ctx, - onedrive.NewRestoreHandler(gc.AC), - backupVersion, - restoreCfg, - opts, - dcs, - deets, - errs) - case selectors.ServiceSharePoint: - status, err = sharepoint.RestoreCollections( - ctx, - backupVersion, - gc.AC, - restoreCfg, - opts, - dcs, - deets, - errs) - default: - err = clues.Wrap(clues.New(sels.Service.String()), "service not supported") - } - - gc.incrementAwaitingMessages() - gc.UpdateStatus(status) - - return deets.Details(), err -} diff --git a/src/internal/connector/data_collections_test.go b/src/internal/m365/backup_test.go similarity index 88% rename from src/internal/connector/data_collections_test.go rename to src/internal/m365/backup_test.go index a20b55952..9429be012 100644 --- a/src/internal/connector/data_collections_test.go +++ b/src/internal/m365/backup_test.go @@ -1,4 +1,4 @@ -package connector +package m365 import ( "bytes" @@ -11,8 +11,9 @@ import ( "github.com/stretchr/testify/suite" inMock "github.com/alcionai/corso/src/internal/common/idname/mock" - "github.com/alcionai/corso/src/internal/connector/exchange" - "github.com/alcionai/corso/src/internal/connector/sharepoint" + "github.com/alcionai/corso/src/internal/m365/exchange" + "github.com/alcionai/corso/src/internal/m365/resource" + "github.com/alcionai/corso/src/internal/m365/sharepoint" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/control" @@ -59,19 +60,13 @@ func (suite *DataCollectionIntgSuite) SetupSuite() { require.NoError(t, err, clues.ToCore(err)) } -// TestExchangeDataCollection verifies interface between operation and -// GraphConnector remains stable to receive a non-zero amount of Collections -// for the Exchange Package. Enabled exchange applications: -// - mail -// - contacts -// - events func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() { ctx, flush := tester.NewContext(suite.T()) defer flush() selUsers := []string{suite.user} - connector := loadConnector(ctx, suite.T(), Users) + ctrl := loadController(ctx, suite.T(), resource.Users) tests := []struct { name string getSelector func(t *testing.T) selectors.Selector @@ -127,14 +122,14 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() { ctrlOpts := control.Defaults() ctrlOpts.ToggleFeatures.DisableDelta = !canMakeDeltaQueries - collections, excludes, canUsePreviousBackup, err := exchange.DataCollections( + collections, excludes, canUsePreviousBackup, err := exchange.ProduceBackupCollections( ctx, suite.ac, sel, suite.tenantID, uidn, nil, - connector.UpdateStatus, + ctrl.UpdateStatus, ctrlOpts, fault.New(true)) require.NoError(t, err, clues.ToCore(err)) @@ -142,7 +137,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() { assert.True(t, excludes.Empty()) for range collections { - connector.incrementAwaitingMessages() + ctrl.incrementAwaitingMessages() } // Categories with delta endpoints will produce a collection for metadata @@ -158,7 +153,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() { } } - status := connector.Wait() + status := ctrl.Wait() assert.NotZero(t, status.Successes) t.Log(status.String()) }) @@ -172,8 +167,7 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner() defer flush() owners := []string{"snuffleupagus"} - - connector := loadConnector(ctx, suite.T(), Users) + ctrl := loadController(ctx, suite.T(), resource.Users) tests := []struct { name string getSelector func(t *testing.T) selectors.Selector @@ -238,7 +232,7 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner() ctx, flush := tester.NewContext(t) defer flush() - collections, excludes, canUsePreviousBackup, err := connector.ProduceBackupCollections( + collections, excludes, canUsePreviousBackup, err := ctrl.ProduceBackupCollections( ctx, test.getSelector(t), test.getSelector(t), @@ -254,16 +248,12 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner() } } -// TestSharePointDataCollection verifies interface between operation and -// GraphConnector remains stable to receive a non-zero amount of Collections -// for the SharePoint Package. func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() { ctx, flush := tester.NewContext(suite.T()) defer flush() selSites := []string{suite.site} - - connector := loadConnector(ctx, suite.T(), Sites) + ctrl := loadController(ctx, suite.T(), resource.Sites) tests := []struct { name string expected int @@ -297,14 +287,14 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() { sel := test.getSelector() - collections, excludes, canUsePreviousBackup, err := sharepoint.DataCollections( + collections, excludes, canUsePreviousBackup, err := sharepoint.ProduceBackupCollections( ctx, suite.ac, sel, sel, nil, - connector.credentials, - connector, + ctrl.credentials, + ctrl, control.Defaults(), fault.New(true)) require.NoError(t, err, clues.ToCore(err)) @@ -313,7 +303,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() { assert.True(t, excludes.Empty()) for range collections { - connector.incrementAwaitingMessages() + ctrl.incrementAwaitingMessages() } // we don't know an exact count of drives this will produce, @@ -328,7 +318,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() { } } - status := connector.Wait() + status := ctrl.Wait() assert.NotZero(t, status.Successes) t.Log(status.String()) }) @@ -341,7 +331,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() { type SPCollectionIntgSuite struct { tester.Suite - connector *GraphConnector + connector *Controller user string } @@ -358,7 +348,7 @@ func (suite *SPCollectionIntgSuite) SetupSuite() { ctx, flush := tester.NewContext(suite.T()) defer flush() - suite.connector = loadConnector(ctx, suite.T(), Sites) + suite.connector = loadController(ctx, suite.T(), resource.Sites) suite.user = tester.M365UserID(suite.T()) tester.LogTimeOfTest(suite.T()) @@ -372,11 +362,11 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Libraries() { var ( siteID = tester.M365SiteID(t) - gc = loadConnector(ctx, t, Sites) + ctrl = loadController(ctx, t, resource.Sites) siteIDs = []string{siteID} ) - id, name, err := gc.PopulateOwnerIDAndNamesFrom(ctx, siteID, nil) + id, name, err := ctrl.PopulateOwnerIDAndNamesFrom(ctx, siteID, nil) require.NoError(t, err, clues.ToCore(err)) sel := selectors.NewSharePointBackup(siteIDs) @@ -384,7 +374,7 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Libraries() { sel.SetDiscreteOwnerIDName(id, name) - cols, excludes, canUsePreviousBackup, err := gc.ProduceBackupCollections( + cols, excludes, canUsePreviousBackup, err := ctrl.ProduceBackupCollections( ctx, inMock.NewProvider(id, name), sel.Selector, @@ -419,11 +409,11 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Lists() { var ( siteID = tester.M365SiteID(t) - gc = loadConnector(ctx, t, Sites) + ctrl = loadController(ctx, t, resource.Sites) siteIDs = []string{siteID} ) - id, name, err := gc.PopulateOwnerIDAndNamesFrom(ctx, siteID, nil) + id, name, err := ctrl.PopulateOwnerIDAndNamesFrom(ctx, siteID, nil) require.NoError(t, err, clues.ToCore(err)) sel := selectors.NewSharePointBackup(siteIDs) @@ -431,7 +421,7 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Lists() { sel.SetDiscreteOwnerIDName(id, name) - cols, excludes, canUsePreviousBackup, err := gc.ProduceBackupCollections( + cols, excludes, canUsePreviousBackup, err := ctrl.ProduceBackupCollections( ctx, inMock.NewProvider(id, name), sel.Selector, diff --git a/src/internal/connector/graph_connector.go b/src/internal/m365/controller.go similarity index 62% rename from src/internal/connector/graph_connector.go rename to src/internal/m365/controller.go index b38518e37..910bf52a2 100644 --- a/src/internal/connector/graph_connector.go +++ b/src/internal/m365/controller.go @@ -1,6 +1,4 @@ -// Package connector uploads and retrieves data from M365 through -// the msgraph-go-sdk. -package connector +package m365 import ( "context" @@ -10,28 +8,25 @@ import ( "github.com/alcionai/clues" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/resource" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/operations/inject" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/services/m365/api" ) -// --------------------------------------------------------------------------- -// Graph Connector -// --------------------------------------------------------------------------- - // must comply with BackupProducer and RestoreConsumer var ( - _ inject.BackupProducer = &GraphConnector{} - _ inject.RestoreConsumer = &GraphConnector{} + _ inject.BackupProducer = &Controller{} + _ inject.RestoreConsumer = &Controller{} ) -// GraphConnector is a struct used to wrap the GraphServiceClient and +// Controller is a struct used to wrap the GraphServiceClient and // GraphRequestAdapter from the msgraph-sdk-go. Additional fields are for // bookkeeping and interfacing with other component. -type GraphConnector struct { +type Controller struct { AC api.Client tenant string @@ -43,20 +38,20 @@ type GraphConnector struct { // reference for processes that choose to populate the values. IDNameLookup idname.Cacher - // wg is used to track completion of GC tasks + // wg is used to track completion of tasks wg *sync.WaitGroup region *trace.Region // mutex used to synchronize updates to `status` mu sync.Mutex - status support.ConnectorOperationStatus // contains the status of the last run status + status support.ControllerOperationStatus // contains the status of the last run status } -func NewGraphConnector( +func NewController( ctx context.Context, acct account.Account, - r Resource, -) (*GraphConnector, error) { + rc resource.Category, +) (*Controller, error) { creds, err := acct.M365Config() if err != nil { return nil, clues.Wrap(err, "retrieving m365 account configuration").WithClues(ctx) @@ -67,106 +62,97 @@ func NewGraphConnector( return nil, clues.Wrap(err, "creating api client").WithClues(ctx) } - rc, err := r.resourceClient(ac) + rCli, err := getResourceClient(rc, ac) if err != nil { return nil, clues.Wrap(err, "creating resource client").WithClues(ctx) } - gc := GraphConnector{ + ctrl := Controller{ AC: ac, IDNameLookup: idname.NewCache(nil), credentials: creds, - ownerLookup: rc, + ownerLookup: rCli, tenant: acct.ID(), wg: &sync.WaitGroup{}, } - return &gc, nil + return &ctrl, nil } // --------------------------------------------------------------------------- // Processing Status // --------------------------------------------------------------------------- -// AwaitStatus waits for all gc tasks to complete and then returns status -func (gc *GraphConnector) Wait() *data.CollectionStats { +// AwaitStatus waits for all tasks to complete and then returns status +func (ctrl *Controller) Wait() *data.CollectionStats { defer func() { - if gc.region != nil { - gc.region.End() - gc.region = nil + if ctrl.region != nil { + ctrl.region.End() + ctrl.region = nil } }() - gc.wg.Wait() + ctrl.wg.Wait() // clean up and reset statefulness dcs := data.CollectionStats{ - Folders: gc.status.Folders, - Objects: gc.status.Metrics.Objects, - Successes: gc.status.Metrics.Successes, - Bytes: gc.status.Metrics.Bytes, - Details: gc.status.String(), + Folders: ctrl.status.Folders, + Objects: ctrl.status.Metrics.Objects, + Successes: ctrl.status.Metrics.Successes, + Bytes: ctrl.status.Metrics.Bytes, + Details: ctrl.status.String(), } - gc.wg = &sync.WaitGroup{} - gc.status = support.ConnectorOperationStatus{} + ctrl.wg = &sync.WaitGroup{} + ctrl.status = support.ControllerOperationStatus{} return &dcs } -// UpdateStatus is used by gc initiated tasks to indicate completion -func (gc *GraphConnector) UpdateStatus(status *support.ConnectorOperationStatus) { - defer gc.wg.Done() +// UpdateStatus is used by initiated tasks to indicate completion +func (ctrl *Controller) UpdateStatus(status *support.ControllerOperationStatus) { + defer ctrl.wg.Done() if status == nil { return } - gc.mu.Lock() - defer gc.mu.Unlock() - gc.status = support.MergeStatus(gc.status, *status) + ctrl.mu.Lock() + defer ctrl.mu.Unlock() + ctrl.status = support.MergeStatus(ctrl.status, *status) } -// Status returns the current status of the graphConnector operation. -func (gc *GraphConnector) Status() support.ConnectorOperationStatus { - return gc.status +// Status returns the current status of the controller process. +func (ctrl *Controller) Status() support.ControllerOperationStatus { + return ctrl.status } -// PrintableStatus returns a string formatted version of the GC status. -func (gc *GraphConnector) PrintableStatus() string { - return gc.status.String() +// PrintableStatus returns a string formatted version of the status. +func (ctrl *Controller) PrintableStatus() string { + return ctrl.status.String() } -func (gc *GraphConnector) incrementAwaitingMessages() { - gc.wg.Add(1) +func (ctrl *Controller) incrementAwaitingMessages() { + ctrl.wg.Add(1) } // --------------------------------------------------------------------------- // Resource Lookup Handling // --------------------------------------------------------------------------- -type Resource int - -const ( - UnknownResource Resource = iota - AllResources // unused - Users - Sites -) - -func (r Resource) resourceClient(ac api.Client) (*resourceClient, error) { - switch r { - case Users: - return &resourceClient{enum: r, getter: ac.Users()}, nil - case Sites: - return &resourceClient{enum: r, getter: ac.Sites()}, nil +func getResourceClient(rc resource.Category, ac api.Client) (*resourceClient, error) { + switch rc { + case resource.Users: + return &resourceClient{enum: rc, getter: ac.Users()}, nil + case resource.Sites: + return &resourceClient{enum: rc, getter: ac.Sites()}, nil default: - return nil, clues.New("unrecognized owner resource enum").With("resource_enum", r) + return nil, clues.New("unrecognized owner resource enum").With("resource_enum", rc) } } type resourceClient struct { - enum Resource + enum resource.Category getter getIDAndNamer } @@ -243,18 +229,18 @@ func (r resourceClient) getOwnerIDAndNameFrom( // The id-name swapper is optional. Some processes will look up all owners in // the tenant before reaching this step. In that case, the data gets handed // down for this func to consume instead of performing further queries. The -// data gets stored inside the gc instance for later re-use. -func (gc *GraphConnector) PopulateOwnerIDAndNamesFrom( +// data gets stored inside the controller instance for later re-use. +func (ctrl *Controller) PopulateOwnerIDAndNamesFrom( ctx context.Context, owner string, // input value, can be either id or name ins idname.Cacher, ) (string, string, error) { - id, name, err := gc.ownerLookup.getOwnerIDAndNameFrom(ctx, gc.AC, owner, ins) + id, name, err := ctrl.ownerLookup.getOwnerIDAndNameFrom(ctx, ctrl.AC, owner, ins) if err != nil { return "", "", clues.Wrap(err, "identifying resource owner") } - gc.IDNameLookup = idname.NewCache(map[string]string{id: name}) + ctrl.IDNameLookup = idname.NewCache(map[string]string{id: name}) return id, name, nil } diff --git a/src/internal/connector/graph_connector_test.go b/src/internal/m365/controller_test.go similarity index 87% rename from src/internal/connector/graph_connector_test.go rename to src/internal/m365/controller_test.go index ccc9e25e7..e7be0ae5f 100644 --- a/src/internal/connector/graph_connector_test.go +++ b/src/internal/m365/controller_test.go @@ -1,4 +1,4 @@ -package connector +package m365 import ( "context" @@ -13,10 +13,11 @@ import ( "github.com/stretchr/testify/suite" inMock "github.com/alcionai/corso/src/internal/common/idname/mock" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" - "github.com/alcionai/corso/src/internal/connector/mock" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" + "github.com/alcionai/corso/src/internal/m365/mock" + "github.com/alcionai/corso/src/internal/m365/resource" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/control" @@ -29,15 +30,15 @@ import ( // Unit tests // --------------------------------------------------------------------------- -type GraphConnectorUnitSuite struct { +type ControllerUnitSuite struct { tester.Suite } -func TestGraphConnectorUnitSuite(t *testing.T) { - suite.Run(t, &GraphConnectorUnitSuite{Suite: tester.NewUnitSuite(t)}) +func TestControllerUnitSuite(t *testing.T) { + suite.Run(t, &ControllerUnitSuite{Suite: tester.NewUnitSuite(t)}) } -func (suite *GraphConnectorUnitSuite) TestPopulateOwnerIDAndNamesFrom() { +func (suite *ControllerUnitSuite) TestPopulateOwnerIDAndNamesFrom() { const ( id = "owner-id" name = "owner-name" @@ -47,10 +48,10 @@ func (suite *GraphConnectorUnitSuite) TestPopulateOwnerIDAndNamesFrom() { itn = map[string]string{id: name} nti = map[string]string{name: id} lookup = &resourceClient{ - enum: Users, + enum: resource.Users, getter: &mock.IDNameGetter{ID: id, Name: name}, } - noLookup = &resourceClient{enum: Users, getter: &mock.IDNameGetter{}} + noLookup = &resourceClient{enum: resource.Users, getter: &mock.IDNameGetter{}} ) table := []struct { @@ -211,9 +212,9 @@ func (suite *GraphConnectorUnitSuite) TestPopulateOwnerIDAndNamesFrom() { ctx, flush := tester.NewContext(t) defer flush() - gc := &GraphConnector{ownerLookup: test.rc} + ctrl := &Controller{ownerLookup: test.rc} - rID, rName, err := gc.PopulateOwnerIDAndNamesFrom(ctx, test.owner, test.ins) + rID, rName, err := ctrl.PopulateOwnerIDAndNamesFrom(ctx, test.owner, test.ins) test.expectErr(t, err, clues.ToCore(err)) assert.Equal(t, test.expectID, rID, "id") assert.Equal(t, test.expectName, rName, "name") @@ -221,14 +222,14 @@ func (suite *GraphConnectorUnitSuite) TestPopulateOwnerIDAndNamesFrom() { } } -func (suite *GraphConnectorUnitSuite) TestGraphConnector_Wait() { +func (suite *ControllerUnitSuite) TestController_Wait() { t := suite.T() ctx, flush := tester.NewContext(t) defer flush() var ( - gc = &GraphConnector{ + ctrl = &Controller{ wg: &sync.WaitGroup{}, region: &trace.Region{}, } @@ -240,13 +241,13 @@ func (suite *GraphConnectorUnitSuite) TestGraphConnector_Wait() { status = support.CreateStatus(ctx, support.Backup, 1, metrics, "details") ) - gc.wg.Add(1) - gc.UpdateStatus(status) + ctrl.wg.Add(1) + ctrl.UpdateStatus(status) - result := gc.Wait() + result := ctrl.Wait() require.NotNil(t, result) - assert.Nil(t, gc.region, "region") - assert.Empty(t, gc.status, "status") + assert.Nil(t, ctrl.region, "region") + assert.Empty(t, ctrl.status, "status") assert.Equal(t, 1, result.Folders) assert.Equal(t, 2, result.Objects) assert.Equal(t, 3, result.Successes) @@ -257,15 +258,15 @@ func (suite *GraphConnectorUnitSuite) TestGraphConnector_Wait() { // Integration tests // --------------------------------------------------------------------------- -type GraphConnectorIntegrationSuite struct { +type ControllerIntegrationSuite struct { tester.Suite - connector *GraphConnector + ctrl *Controller user string secondaryUser string } -func TestGraphConnectorIntegrationSuite(t *testing.T) { - suite.Run(t, &GraphConnectorIntegrationSuite{ +func TestControllerIntegrationSuite(t *testing.T) { + suite.Run(t, &ControllerIntegrationSuite{ Suite: tester.NewIntegrationSuite( t, [][]string{tester.M365AcctCredEnvs}, @@ -273,20 +274,20 @@ func TestGraphConnectorIntegrationSuite(t *testing.T) { }) } -func (suite *GraphConnectorIntegrationSuite) SetupSuite() { +func (suite *ControllerIntegrationSuite) SetupSuite() { t := suite.T() ctx, flush := tester.NewContext(t) defer flush() - suite.connector = loadConnector(ctx, t, Users) + suite.ctrl = loadController(ctx, t, resource.Users) suite.user = tester.M365UserID(t) suite.secondaryUser = tester.SecondaryM365UserID(t) tester.LogTimeOfTest(t) } -func (suite *GraphConnectorIntegrationSuite) TestRestoreFailsBadService() { +func (suite *ControllerIntegrationSuite) TestRestoreFailsBadService() { t := suite.T() ctx, flush := tester.NewContext(t) @@ -299,7 +300,7 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreFailsBadService() { } ) - deets, err := suite.connector.ConsumeRestoreCollections( + deets, err := suite.ctrl.ConsumeRestoreCollections( ctx, version.Backup, sel, @@ -313,13 +314,13 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreFailsBadService() { assert.Error(t, err, clues.ToCore(err)) assert.NotNil(t, deets) - status := suite.connector.Wait() + status := suite.ctrl.Wait() assert.Equal(t, 0, status.Objects) assert.Equal(t, 0, status.Folders) assert.Equal(t, 0, status.Successes) } -func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() { +func (suite *ControllerIntegrationSuite) TestEmptyCollections() { restoreCfg := tester.DefaultTestRestoreConfig("") table := []struct { name string @@ -377,7 +378,7 @@ func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() { ctx, flush := tester.NewContext(t) defer flush() - deets, err := suite.connector.ConsumeRestoreCollections( + deets, err := suite.ctrl.ConsumeRestoreCollections( ctx, version.Backup, test.sel, @@ -391,7 +392,7 @@ func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() { require.NoError(t, err, clues.ToCore(err)) assert.NotNil(t, deets) - stats := suite.connector.Wait() + stats := suite.ctrl.Wait() assert.Zero(t, stats.Objects) assert.Zero(t, stats.Folders) assert.Zero(t, stats.Successes) @@ -418,9 +419,9 @@ func runRestore( start := time.Now() - restoreGC := loadConnector(ctx, t, config.Resource) + restoreCtrl := loadController(ctx, t, config.Resource) restoreSel := getSelectorWith(t, config.Service, config.ResourceOwners, true) - deets, err := restoreGC.ConsumeRestoreCollections( + deets, err := restoreCtrl.ConsumeRestoreCollections( ctx, backupVersion, restoreSel, @@ -431,7 +432,7 @@ func runRestore( require.NoError(t, err, clues.ToCore(err)) assert.NotNil(t, deets) - status := restoreGC.Wait() + status := restoreCtrl.Wait() runTime := time.Since(start) assert.Equal(t, numRestoreItems, status.Objects, "restored status.Objects") @@ -480,14 +481,14 @@ func runBackupAndCompare( nameToID[ro] = ro } - backupGC := loadConnector(ctx, t, config.Resource) - backupGC.IDNameLookup = inMock.NewCache(idToName, nameToID) + backupCtrl := loadController(ctx, t, config.Resource) + backupCtrl.IDNameLookup = inMock.NewCache(idToName, nameToID) backupSel := backupSelectorForExpected(t, config.Service, expectedDests) t.Logf("Selective backup of %s\n", backupSel) start := time.Now() - dcs, excludes, canUsePreviousBackup, err := backupGC.ProduceBackupCollections( + dcs, excludes, canUsePreviousBackup, err := backupCtrl.ProduceBackupCollections( ctx, backupSel, backupSel, @@ -512,7 +513,7 @@ func runBackupAndCompare( dcs, config) - status := backupGC.Wait() + status := backupCtrl.Wait() assert.Equalf(t, totalItems+skipped, status.Objects, "backup status.Objects; wanted %d items + %d skipped", totalItems, skipped) @@ -532,7 +533,7 @@ func runRestoreBackupTest( config := ConfigInfo{ Opts: opts, - Resource: test.resource, + Resource: test.resourceCat, Service: test.service, Tenant: tenant, ResourceOwners: resourceOwners, @@ -652,15 +653,15 @@ func runRestoreBackupTestVersions( test.collectionsLatest) } -func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() { +func (suite *ControllerIntegrationSuite) TestRestoreAndBackup() { bodyText := "This email has some text. However, all the text is on the same line." subjectText := "Test message for restore" table := []restoreBackupInfo{ { - name: "EmailsWithAttachments", - service: path.ExchangeService, - resource: Users, + name: "EmailsWithAttachments", + service: path.ExchangeService, + resourceCat: resource.Users, collections: []ColInfo{ { PathElements: []string{"Inbox"}, @@ -685,9 +686,9 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() { }, }, { - name: "MultipleEmailsMultipleFolders", - service: path.ExchangeService, - resource: Users, + name: "MultipleEmailsMultipleFolders", + service: path.ExchangeService, + resourceCat: resource.Users, collections: []ColInfo{ { PathElements: []string{"Inbox"}, @@ -761,9 +762,9 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() { }, }, { - name: "MultipleContactsSingleFolder", - service: path.ExchangeService, - resource: Users, + name: "MultipleContactsSingleFolder", + service: path.ExchangeService, + resourceCat: resource.Users, collections: []ColInfo{ { PathElements: []string{"Contacts"}, @@ -789,9 +790,9 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() { }, }, { - name: "MultipleContactsMultipleFolders", - service: path.ExchangeService, - resource: Users, + name: "MultipleContactsMultipleFolders", + service: path.ExchangeService, + resourceCat: resource.Users, collections: []ColInfo{ { PathElements: []string{"Work"}, @@ -909,7 +910,7 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() { runRestoreBackupTest( suite.T(), test, - suite.connector.tenant, + suite.ctrl.tenant, []string{suite.user}, control.Options{ RestorePermissions: true, @@ -919,12 +920,12 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() { } } -func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames() { +func (suite *ControllerIntegrationSuite) TestMultiFolderBackupDifferentNames() { table := []restoreBackupInfo{ { - name: "Contacts", - service: path.ExchangeService, - resource: Users, + name: "Contacts", + service: path.ExchangeService, + resourceCat: resource.Users, collections: []ColInfo{ { PathElements: []string{"Work"}, @@ -1005,7 +1006,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames totalItems, _, collections, expectedData, err := collectionsForInfo( test.service, - suite.connector.tenant, + suite.ctrl.tenant, suite.user, restoreCfg, []ColInfo{collection}, @@ -1026,8 +1027,8 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames restoreCfg.Location, ) - restoreGC := loadConnector(ctx, t, test.resource) - deets, err := restoreGC.ConsumeRestoreCollections( + restoreCtrl := loadController(ctx, t, test.resourceCat) + deets, err := restoreCtrl.ConsumeRestoreCollections( ctx, version.Backup, restoreSel, @@ -1041,7 +1042,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames require.NoError(t, err, clues.ToCore(err)) require.NotNil(t, deets) - status := restoreGC.Wait() + status := restoreCtrl.Wait() // Always just 1 because it's just 1 collection. assert.Equal(t, totalItems, status.Objects, "status.Objects") assert.Equal(t, totalItems, status.Successes, "status.Successes") @@ -1056,11 +1057,11 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames // Run a backup and compare its output with what we put in. - backupGC := loadConnector(ctx, t, test.resource) + backupCtrl := loadController(ctx, t, test.resourceCat) backupSel := backupSelectorForExpected(t, test.service, expectedDests) t.Log("Selective backup of", backupSel) - dcs, excludes, canUsePreviousBackup, err := backupGC.ProduceBackupCollections( + dcs, excludes, canUsePreviousBackup, err := backupCtrl.ProduceBackupCollections( ctx, backupSel, backupSel, @@ -1088,7 +1089,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames // deadlock. skipped := checkCollections(t, ctx, allItems, allExpectedData, dcs, ci) - status := backupGC.Wait() + status := backupCtrl.Wait() assert.Equal(t, allItems+skipped, status.Objects, "status.Objects") assert.Equal(t, allItems+skipped, status.Successes, "status.Successes") }) @@ -1097,13 +1098,13 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames // TODO: this should only be run during smoke tests, not part of the standard CI. // That's why it's set aside instead of being included in the other test set. -func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup_largeMailAttachment() { +func (suite *ControllerIntegrationSuite) TestRestoreAndBackup_largeMailAttachment() { subjectText := "Test message for restore with large attachment" test := restoreBackupInfo{ - name: "EmailsWithLargeAttachments", - service: path.ExchangeService, - resource: Users, + name: "EmailsWithLargeAttachments", + service: path.ExchangeService, + resourceCat: resource.Users, collections: []ColInfo{ { PathElements: []string{"Inbox"}, @@ -1122,7 +1123,7 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup_largeMailAttac runRestoreBackupTest( suite.T(), test, - suite.connector.tenant, + suite.ctrl.tenant, []string{suite.user}, control.Options{ RestorePermissions: true, @@ -1131,17 +1132,17 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup_largeMailAttac ) } -func (suite *GraphConnectorIntegrationSuite) TestBackup_CreatesPrefixCollections() { +func (suite *ControllerIntegrationSuite) TestBackup_CreatesPrefixCollections() { table := []struct { name string - resource Resource + resourceCat resource.Category selectorFunc func(t *testing.T) selectors.Selector service path.ServiceType categories []string }{ { - name: "Exchange", - resource: Users, + name: "Exchange", + resourceCat: resource.Users, selectorFunc: func(t *testing.T) selectors.Selector { sel := selectors.NewExchangeBackup([]string{suite.user}) sel.Include( @@ -1160,8 +1161,8 @@ func (suite *GraphConnectorIntegrationSuite) TestBackup_CreatesPrefixCollections }, }, { - name: "OneDrive", - resource: Users, + name: "OneDrive", + resourceCat: resource.Users, selectorFunc: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{suite.user}) sel.Include(sel.Folders([]string{selectors.NoneTgt})) @@ -1174,8 +1175,8 @@ func (suite *GraphConnectorIntegrationSuite) TestBackup_CreatesPrefixCollections }, }, { - name: "SharePoint", - resource: Sites, + name: "SharePoint", + resourceCat: resource.Sites, selectorFunc: func(t *testing.T) selectors.Selector { sel := selectors.NewSharePointBackup([]string{tester.M365SiteID(t)}) sel.Include( @@ -1205,18 +1206,18 @@ func (suite *GraphConnectorIntegrationSuite) TestBackup_CreatesPrefixCollections defer flush() var ( - backupGC = loadConnector(ctx, t, test.resource) - backupSel = test.selectorFunc(t) - errs = fault.New(true) - start = time.Now() + backupCtrl = loadController(ctx, t, test.resourceCat) + backupSel = test.selectorFunc(t) + errs = fault.New(true) + start = time.Now() ) - id, name, err := backupGC.PopulateOwnerIDAndNamesFrom(ctx, backupSel.DiscreteOwner, nil) + id, name, err := backupCtrl.PopulateOwnerIDAndNamesFrom(ctx, backupSel.DiscreteOwner, nil) require.NoError(t, err, clues.ToCore(err)) backupSel.SetDiscreteOwnerIDName(id, name) - dcs, excludes, canUsePreviousBackup, err := backupGC.ProduceBackupCollections( + dcs, excludes, canUsePreviousBackup, err := backupCtrl.ProduceBackupCollections( ctx, inMock.NewProvider(id, name), backupSel, @@ -1263,7 +1264,7 @@ func (suite *GraphConnectorIntegrationSuite) TestBackup_CreatesPrefixCollections assert.ElementsMatch(t, test.categories, foundCategories) - backupGC.Wait() + backupCtrl.Wait() assert.NoError(t, errs.Failure()) }) diff --git a/src/internal/connector/discovery/discovery.go b/src/internal/m365/discovery/discovery.go similarity index 98% rename from src/internal/connector/discovery/discovery.go rename to src/internal/m365/discovery/discovery.go index df31402b9..cba4a25a7 100644 --- a/src/internal/connector/discovery/discovery.go +++ b/src/internal/m365/discovery/discovery.go @@ -6,7 +6,7 @@ import ( "github.com/alcionai/clues" "github.com/microsoftgraph/msgraph-sdk-go/models" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/internal/connector/discovery/discovery_test.go b/src/internal/m365/discovery/discovery_test.go similarity index 99% rename from src/internal/connector/discovery/discovery_test.go rename to src/internal/m365/discovery/discovery_test.go index e972d7a80..f8648cd84 100644 --- a/src/internal/connector/discovery/discovery_test.go +++ b/src/internal/m365/discovery/discovery_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/discovery" + "github.com/alcionai/corso/src/internal/m365/discovery" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/credentials" diff --git a/src/internal/connector/exchange/attachment.go b/src/internal/m365/exchange/attachment.go similarity index 100% rename from src/internal/connector/exchange/attachment.go rename to src/internal/m365/exchange/attachment.go diff --git a/src/internal/connector/exchange/attendees.go b/src/internal/m365/exchange/attendees.go similarity index 100% rename from src/internal/connector/exchange/attendees.go rename to src/internal/m365/exchange/attendees.go diff --git a/src/internal/connector/exchange/service_iterators.go b/src/internal/m365/exchange/backup.go similarity index 54% rename from src/internal/connector/exchange/service_iterators.go rename to src/internal/m365/exchange/backup.go index 021c15cbc..a24cc1c44 100644 --- a/src/internal/connector/exchange/service_iterators.go +++ b/src/internal/m365/exchange/backup.go @@ -2,14 +2,18 @@ package exchange import ( "context" + "encoding/json" "github.com/alcionai/clues" + "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/pii" + "github.com/alcionai/corso/src/internal/common/prefixmatcher" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/support" + "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" @@ -18,7 +22,303 @@ import ( "github.com/alcionai/corso/src/pkg/services/m365/api" ) -// filterContainersAndFillCollections is a utility function +// MetadataFileNames produces the category-specific set of filenames used to +// store graph metadata such as delta tokens and folderID->path references. +func MetadataFileNames(cat path.CategoryType) []string { + switch cat { + case path.EmailCategory, path.ContactsCategory: + return []string{graph.DeltaURLsFileName, graph.PreviousPathFileName} + default: + return []string{graph.PreviousPathFileName} + } +} + +type CatDeltaPaths map[path.CategoryType]DeltaPaths + +type DeltaPaths map[string]DeltaPath + +func (dps DeltaPaths) AddDelta(k, d string) { + dp, ok := dps[k] + if !ok { + dp = DeltaPath{} + } + + dp.Delta = d + dps[k] = dp +} + +func (dps DeltaPaths) AddPath(k, p string) { + dp, ok := dps[k] + if !ok { + dp = DeltaPath{} + } + + dp.Path = p + dps[k] = dp +} + +type DeltaPath struct { + Delta string + Path string +} + +// ParseMetadataCollections produces a map of structs holding delta +// and path lookup maps. +func parseMetadataCollections( + ctx context.Context, + colls []data.RestoreCollection, +) (CatDeltaPaths, bool, error) { + // cdp stores metadata + cdp := CatDeltaPaths{ + path.ContactsCategory: {}, + path.EmailCategory: {}, + path.EventsCategory: {}, + } + + // found tracks the metadata we've loaded, to make sure we don't + // fetch overlapping copies. + found := map[path.CategoryType]map[string]struct{}{ + path.ContactsCategory: {}, + path.EmailCategory: {}, + path.EventsCategory: {}, + } + + // errors from metadata items should not stop the backup, + // but it should prevent us from using previous backups + errs := fault.New(true) + + for _, coll := range colls { + var ( + breakLoop bool + items = coll.Items(ctx, errs) + category = coll.FullPath().Category() + ) + + for { + select { + case <-ctx.Done(): + return nil, false, clues.Wrap(ctx.Err(), "parsing collection metadata").WithClues(ctx) + + case item, ok := <-items: + if !ok || errs.Failure() != nil { + breakLoop = true + break + } + + var ( + m = map[string]string{} + cdps = cdp[category] + ) + + err := json.NewDecoder(item.ToReader()).Decode(&m) + if err != nil { + return nil, false, clues.New("decoding metadata json").WithClues(ctx) + } + + switch item.UUID() { + case graph.PreviousPathFileName: + if _, ok := found[category]["path"]; ok { + return nil, false, clues.Wrap(clues.New(category.String()), "multiple versions of path metadata").WithClues(ctx) + } + + for k, p := range m { + cdps.AddPath(k, p) + } + + found[category]["path"] = struct{}{} + + case graph.DeltaURLsFileName: + if _, ok := found[category]["delta"]; ok { + return nil, false, clues.Wrap(clues.New(category.String()), "multiple versions of delta metadata").WithClues(ctx) + } + + for k, d := range m { + cdps.AddDelta(k, d) + } + + found[category]["delta"] = struct{}{} + } + + cdp[category] = cdps + } + + if breakLoop { + break + } + } + } + + if errs.Failure() != nil { + logger.CtxErr(ctx, errs.Failure()).Info("reading metadata collection items") + + return CatDeltaPaths{ + path.ContactsCategory: {}, + path.EmailCategory: {}, + path.EventsCategory: {}, + }, false, nil + } + + // Remove any entries that contain a path or a delta, but not both. + // That metadata is considered incomplete, and needs to incur a + // complete backup on the next run. + for _, dps := range cdp { + for k, dp := range dps { + if len(dp.Path) == 0 { + delete(dps, k) + } + } + } + + return cdp, true, nil +} + +// ProduceBackupCollections returns a DataCollection which the caller can +// use to read mailbox data out for the specified user +func ProduceBackupCollections( + ctx context.Context, + ac api.Client, + selector selectors.Selector, + tenantID string, + user idname.Provider, + metadata []data.RestoreCollection, + su support.StatusUpdater, + ctrlOpts control.Options, + errs *fault.Bus, +) ([]data.BackupCollection, *prefixmatcher.StringSetMatcher, bool, error) { + eb, err := selector.ToExchangeBackup() + if err != nil { + return nil, nil, false, clues.Wrap(err, "exchange dataCollection selector").WithClues(ctx) + } + + var ( + collections = []data.BackupCollection{} + el = errs.Local() + categories = map[path.CategoryType]struct{}{} + handlers = BackupHandlers(ac) + ) + + // Turn on concurrency limiter middleware for exchange backups + // unless explicitly disabled through DisableConcurrencyLimiterFN cli flag + if !ctrlOpts.ToggleFeatures.DisableConcurrencyLimiter { + graph.InitializeConcurrencyLimiter(ctrlOpts.Parallelism.ItemFetch) + } + + cdps, canUsePreviousBackup, err := parseMetadataCollections(ctx, metadata) + if err != nil { + return nil, nil, false, err + } + + for _, scope := range eb.Scopes() { + if el.Failure() != nil { + break + } + + dcs, err := createCollections( + ctx, + handlers, + tenantID, + user, + scope, + cdps[scope.Category().PathType()], + ctrlOpts, + su, + errs) + if err != nil { + el.AddRecoverable(err) + continue + } + + categories[scope.Category().PathType()] = struct{}{} + + collections = append(collections, dcs...) + } + + if len(collections) > 0 { + baseCols, err := graph.BaseCollections( + ctx, + collections, + tenantID, + user.ID(), + path.ExchangeService, + categories, + su, + errs) + if err != nil { + return nil, nil, false, err + } + + collections = append(collections, baseCols...) + } + + return collections, nil, canUsePreviousBackup, el.Failure() +} + +// createCollections - utility function that retrieves M365 +// IDs through Microsoft Graph API. The selectors.ExchangeScope +// determines the type of collections that are retrieved. +func createCollections( + ctx context.Context, + handlers map[path.CategoryType]backupHandler, + tenantID string, + user idname.Provider, + scope selectors.ExchangeScope, + dps DeltaPaths, + ctrlOpts control.Options, + su support.StatusUpdater, + errs *fault.Bus, +) ([]data.BackupCollection, error) { + ctx = clues.Add(ctx, "category", scope.Category().PathType()) + + var ( + allCollections = make([]data.BackupCollection, 0) + category = scope.Category().PathType() + qp = graph.QueryParams{ + Category: category, + ResourceOwner: user, + TenantID: tenantID, + } + ) + + handler, ok := handlers[category] + if !ok { + return nil, clues.New("unsupported backup category type").WithClues(ctx) + } + + foldersComplete := observe.MessageWithCompletion( + ctx, + observe.Bulletf("%s", qp.Category)) + defer close(foldersComplete) + + rootFolder, cc := handler.NewContainerCache(user.ID()) + + if err := cc.Populate(ctx, errs, rootFolder); err != nil { + return nil, clues.Wrap(err, "populating container cache") + } + + collections, err := populateCollections( + ctx, + qp, + handler, + su, + cc, + scope, + dps, + ctrlOpts, + errs) + if err != nil { + return nil, clues.Wrap(err, "filling collections") + } + + foldersComplete <- struct{}{} + + for _, coll := range collections { + allCollections = append(allCollections, coll) + } + + return allCollections, nil +} + +// populateCollections is a utility function // that places the M365 object ids belonging to specific directories // into a BackupCollection. Messages outside of those directories are omitted. // @param collection is filled with during this function. @@ -27,7 +327,7 @@ import ( // TODO(ashmrtn): This should really return []data.BackupCollection but // unfortunately some of our tests rely on being able to lookup returned // collections by ID and it would be non-trivial to change them. -func filterContainersAndFillCollections( +func populateCollections( ctx context.Context, qp graph.QueryParams, bh backupHandler, diff --git a/src/internal/connector/exchange/service_iterators_test.go b/src/internal/m365/exchange/backup_test.go similarity index 62% rename from src/internal/connector/exchange/service_iterators_test.go rename to src/internal/m365/exchange/backup_test.go index 102031ffe..06d5a75c6 100644 --- a/src/internal/connector/exchange/service_iterators_test.go +++ b/src/internal/m365/exchange/backup_test.go @@ -1,7 +1,9 @@ package exchange import ( + "bytes" "context" + "sync" "testing" "github.com/alcionai/clues" @@ -11,9 +13,9 @@ import ( inMock "github.com/alcionai/corso/src/internal/common/idname/mock" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/control" @@ -107,12 +109,12 @@ func (m mockResolver) Items() []graph.CachedContainer { return m.items } -func (m mockResolver) AddToCache(ctx context.Context, gc graph.Container) error { +func (m mockResolver) AddToCache(ctx context.Context, ctrl graph.Container) error { if len(m.added) == 0 { m.added = map[string]string{} } - m.added[ptr.Val(gc.GetDisplayName())] = ptr.Val(gc.GetId()) + m.added[ptr.Val(ctrl.GetDisplayName())] = ptr.Val(ctrl.GetId()) return nil } @@ -125,33 +127,765 @@ func (m mockResolver) LocationInCache(string) (string, bool) func (m mockResolver) Populate(context.Context, *fault.Bus, string, ...string) error { return nil } // --------------------------------------------------------------------------- -// tests +// Unit tests // --------------------------------------------------------------------------- -type ServiceIteratorsSuite struct { +type DataCollectionsUnitSuite struct { + tester.Suite +} + +func TestDataCollectionsUnitSuite(t *testing.T) { + suite.Run(t, &DataCollectionsUnitSuite{Suite: tester.NewUnitSuite(t)}) +} + +func (suite *DataCollectionsUnitSuite) TestParseMetadataCollections() { + type fileValues struct { + fileName string + value string + } + + table := []struct { + name string + data []fileValues + expect map[string]DeltaPath + canUsePreviousBackup bool + expectError assert.ErrorAssertionFunc + }{ + { + name: "delta urls only", + data: []fileValues{ + {graph.DeltaURLsFileName, "delta-link"}, + }, + expect: map[string]DeltaPath{}, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + { + name: "multiple delta urls", + data: []fileValues{ + {graph.DeltaURLsFileName, "delta-link"}, + {graph.DeltaURLsFileName, "delta-link-2"}, + }, + canUsePreviousBackup: false, + expectError: assert.Error, + }, + { + name: "previous path only", + data: []fileValues{ + {graph.PreviousPathFileName, "prev-path"}, + }, + expect: map[string]DeltaPath{ + "key": { + Delta: "delta-link", + Path: "prev-path", + }, + }, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + { + name: "multiple previous paths", + data: []fileValues{ + {graph.PreviousPathFileName, "prev-path"}, + {graph.PreviousPathFileName, "prev-path-2"}, + }, + canUsePreviousBackup: false, + expectError: assert.Error, + }, + { + name: "delta urls and previous paths", + data: []fileValues{ + {graph.DeltaURLsFileName, "delta-link"}, + {graph.PreviousPathFileName, "prev-path"}, + }, + expect: map[string]DeltaPath{ + "key": { + Delta: "delta-link", + Path: "prev-path", + }, + }, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + { + name: "delta urls and empty previous paths", + data: []fileValues{ + {graph.DeltaURLsFileName, "delta-link"}, + {graph.PreviousPathFileName, ""}, + }, + expect: map[string]DeltaPath{}, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + { + name: "empty delta urls and previous paths", + data: []fileValues{ + {graph.DeltaURLsFileName, ""}, + {graph.PreviousPathFileName, "prev-path"}, + }, + expect: map[string]DeltaPath{ + "key": { + Delta: "delta-link", + Path: "prev-path", + }, + }, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + { + name: "delta urls with special chars", + data: []fileValues{ + {graph.DeltaURLsFileName, "`!@#$%^&*()_[]{}/\"\\"}, + {graph.PreviousPathFileName, "prev-path"}, + }, + expect: map[string]DeltaPath{ + "key": { + Delta: "`!@#$%^&*()_[]{}/\"\\", + Path: "prev-path", + }, + }, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + { + name: "delta urls with escaped chars", + data: []fileValues{ + {graph.DeltaURLsFileName, `\n\r\t\b\f\v\0\\`}, + {graph.PreviousPathFileName, "prev-path"}, + }, + expect: map[string]DeltaPath{ + "key": { + Delta: "\\n\\r\\t\\b\\f\\v\\0\\\\", + Path: "prev-path", + }, + }, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + { + name: "delta urls with newline char runes", + data: []fileValues{ + // rune(92) = \, rune(110) = n. Ensuring it's not possible to + // error in serializing/deserializing and produce a single newline + // character from those two runes. + {graph.DeltaURLsFileName, string([]rune{rune(92), rune(110)})}, + {graph.PreviousPathFileName, "prev-path"}, + }, + expect: map[string]DeltaPath{ + "key": { + Delta: "\\n", + Path: "prev-path", + }, + }, + canUsePreviousBackup: true, + expectError: assert.NoError, + }, + } + for _, test := range table { + suite.Run(test.name, func() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + entries := []graph.MetadataCollectionEntry{} + + for _, d := range test.data { + entries = append( + entries, + graph.NewMetadataEntry(d.fileName, map[string]string{"key": d.value})) + } + + coll, err := graph.MakeMetadataCollection( + "t", "u", + path.ExchangeService, + path.EmailCategory, + entries, + func(cos *support.ControllerOperationStatus) {}, + ) + require.NoError(t, err, clues.ToCore(err)) + + cdps, canUsePreviousBackup, err := parseMetadataCollections(ctx, []data.RestoreCollection{ + data.NoFetchRestoreCollection{Collection: coll}, + }) + test.expectError(t, err, clues.ToCore(err)) + + assert.Equal(t, test.canUsePreviousBackup, canUsePreviousBackup, "can use previous backup") + + emails := cdps[path.EmailCategory] + + assert.Len(t, emails, len(test.expect)) + + for k, v := range emails { + assert.Equal(t, v.Delta, emails[k].Delta, "delta") + assert.Equal(t, v.Path, emails[k].Path, "path") + } + }) + } +} + +type failingColl struct { + t *testing.T +} + +func (f failingColl) Items(ctx context.Context, errs *fault.Bus) <-chan data.Stream { + ic := make(chan data.Stream) + defer close(ic) + + errs.AddRecoverable(assert.AnError) + + return ic +} + +func (f failingColl) FullPath() path.Path { + tmp, err := path.Build( + "tenant", + "user", + path.ExchangeService, + path.EmailCategory, + false, + "inbox") + require.NoError(f.t, err, clues.ToCore(err)) + + return tmp +} + +func (f failingColl) FetchItemByName(context.Context, string) (data.Stream, error) { + // no fetch calls will be made + return nil, nil +} + +// This check is to ensure that we don't error out, but still return +// canUsePreviousBackup as false on read errors +func (suite *DataCollectionsUnitSuite) TestParseMetadataCollections_ReadFailure() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + fc := failingColl{t} + + _, canUsePreviousBackup, err := parseMetadataCollections(ctx, []data.RestoreCollection{fc}) + require.NoError(t, err) + require.False(t, canUsePreviousBackup) +} + +// --------------------------------------------------------------------------- +// Integration tests +// --------------------------------------------------------------------------- + +func newStatusUpdater(t *testing.T, wg *sync.WaitGroup) func(status *support.ControllerOperationStatus) { + updater := func(status *support.ControllerOperationStatus) { + defer wg.Done() + } + + return updater +} + +type DataCollectionsIntegrationSuite struct { + tester.Suite + user string + site string + tenantID string + ac api.Client +} + +func TestDataCollectionsIntegrationSuite(t *testing.T) { + suite.Run(t, &DataCollectionsIntegrationSuite{ + Suite: tester.NewIntegrationSuite( + t, + [][]string{tester.M365AcctCredEnvs}, + ), + }) +} + +func (suite *DataCollectionsIntegrationSuite) SetupSuite() { + suite.user = tester.M365UserID(suite.T()) + suite.site = tester.M365SiteID(suite.T()) + + acct := tester.NewM365Account(suite.T()) + creds, err := acct.M365Config() + require.NoError(suite.T(), err, clues.ToCore(err)) + + suite.ac, err = api.NewClient(creds) + require.NoError(suite.T(), err, clues.ToCore(err)) + + suite.tenantID = creds.AzureTenantID + + tester.LogTimeOfTest(suite.T()) +} + +func (suite *DataCollectionsIntegrationSuite) TestMailFetch() { + var ( + userID = tester.M365UserID(suite.T()) + users = []string{userID} + handlers = BackupHandlers(suite.ac) + ) + + tests := []struct { + name string + scope selectors.ExchangeScope + folderNames map[string]struct{} + canMakeDeltaQueries bool + }{ + { + name: "Folder Iterative Check Mail", + scope: selectors.NewExchangeBackup(users).MailFolders( + []string{DefaultMailFolder}, + selectors.PrefixMatch(), + )[0], + folderNames: map[string]struct{}{ + DefaultMailFolder: {}, + }, + canMakeDeltaQueries: true, + }, + { + name: "Folder Iterative Check Mail Non-Delta", + scope: selectors.NewExchangeBackup(users).MailFolders( + []string{DefaultMailFolder}, + selectors.PrefixMatch(), + )[0], + folderNames: map[string]struct{}{ + DefaultMailFolder: {}, + }, + canMakeDeltaQueries: false, + }, + } + + for _, test := range tests { + suite.Run(test.name, func() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + ctrlOpts := control.Defaults() + ctrlOpts.ToggleFeatures.DisableDelta = !test.canMakeDeltaQueries + + collections, err := createCollections( + ctx, + handlers, + suite.tenantID, + inMock.NewProvider(userID, userID), + test.scope, + DeltaPaths{}, + ctrlOpts, + func(status *support.ControllerOperationStatus) {}, + fault.New(true)) + require.NoError(t, err, clues.ToCore(err)) + + for _, c := range collections { + if c.FullPath().Service() == path.ExchangeMetadataService { + continue + } + + require.NotEmpty(t, c.FullPath().Folder(false)) + + // TODO(ashmrtn): Remove when LocationPath is made part of BackupCollection + // interface. + if !assert.Implements(t, (*data.LocationPather)(nil), c) { + continue + } + + loc := c.(data.LocationPather).LocationPath().String() + + require.NotEmpty(t, loc) + + delete(test.folderNames, loc) + } + + assert.Empty(t, test.folderNames) + }) + } +} + +func (suite *DataCollectionsIntegrationSuite) TestDelta() { + var ( + userID = tester.M365UserID(suite.T()) + users = []string{userID} + handlers = BackupHandlers(suite.ac) + ) + + tests := []struct { + name string + scope selectors.ExchangeScope + }{ + { + name: "Mail", + scope: selectors.NewExchangeBackup(users).MailFolders( + []string{DefaultMailFolder}, + selectors.PrefixMatch(), + )[0], + }, + { + name: "Contacts", + scope: selectors.NewExchangeBackup(users).ContactFolders( + []string{DefaultContactFolder}, + selectors.PrefixMatch(), + )[0], + }, + { + name: "Events", + scope: selectors.NewExchangeBackup(users).EventCalendars( + []string{DefaultCalendar}, + selectors.PrefixMatch(), + )[0], + }, + } + for _, test := range tests { + suite.Run(test.name, func() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + // get collections without providing any delta history (ie: full backup) + collections, err := createCollections( + ctx, + handlers, + suite.tenantID, + inMock.NewProvider(userID, userID), + test.scope, + DeltaPaths{}, + control.Defaults(), + func(status *support.ControllerOperationStatus) {}, + fault.New(true)) + require.NoError(t, err, clues.ToCore(err)) + assert.Less(t, 1, len(collections), "retrieved metadata and data collections") + + var metadata data.BackupCollection + + for _, coll := range collections { + if coll.FullPath().Service() == path.ExchangeMetadataService { + metadata = coll + } + } + + require.NotNil(t, metadata, "collections contains a metadata collection") + + cdps, canUsePreviousBackup, err := parseMetadataCollections(ctx, []data.RestoreCollection{ + data.NoFetchRestoreCollection{Collection: metadata}, + }) + require.NoError(t, err, clues.ToCore(err)) + assert.True(t, canUsePreviousBackup, "can use previous backup") + + dps := cdps[test.scope.Category().PathType()] + + // now do another backup with the previous delta tokens, + // which should only contain the difference. + collections, err = createCollections( + ctx, + handlers, + suite.tenantID, + inMock.NewProvider(userID, userID), + test.scope, + dps, + control.Defaults(), + func(status *support.ControllerOperationStatus) {}, + fault.New(true)) + require.NoError(t, err, clues.ToCore(err)) + + // TODO(keepers): this isn't a very useful test at the moment. It needs to + // investigate the items in the original and delta collections to at least + // assert some minimum assumptions, such as "deltas should retrieve fewer items". + // Delta usage is commented out at the moment, anyway. So this is currently + // a sanity check that the minimum behavior won't break. + for _, coll := range collections { + if coll.FullPath().Service() != path.ExchangeMetadataService { + ec, ok := coll.(*Collection) + require.True(t, ok, "collection is *Collection") + assert.NotNil(t, ec) + } + } + }) + } +} + +// TestMailSerializationRegression verifies that all mail data stored in the +// test account can be successfully downloaded into bytes and restored into +// M365 mail objects +func (suite *DataCollectionsIntegrationSuite) TestMailSerializationRegression() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + var ( + wg sync.WaitGroup + users = []string{suite.user} + handlers = BackupHandlers(suite.ac) + ) + + sel := selectors.NewExchangeBackup(users) + sel.Include(sel.MailFolders([]string{DefaultMailFolder}, selectors.PrefixMatch())) + + collections, err := createCollections( + ctx, + handlers, + suite.tenantID, + inMock.NewProvider(suite.user, suite.user), + sel.Scopes()[0], + DeltaPaths{}, + control.Defaults(), + newStatusUpdater(t, &wg), + fault.New(true)) + require.NoError(t, err, clues.ToCore(err)) + + wg.Add(len(collections)) + + for _, edc := range collections { + suite.Run(edc.FullPath().String(), func() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + isMetadata := edc.FullPath().Service() == path.ExchangeMetadataService + streamChannel := edc.Items(ctx, fault.New(true)) + + // Verify that each message can be restored + for stream := range streamChannel { + buf := &bytes.Buffer{} + + read, err := buf.ReadFrom(stream.ToReader()) + assert.NoError(t, err, clues.ToCore(err)) + assert.NotZero(t, read) + + if isMetadata { + continue + } + + message, err := api.BytesToMessageable(buf.Bytes()) + assert.NotNil(t, message) + assert.NoError(t, err, clues.ToCore(err)) + } + }) + } + + wg.Wait() +} + +// TestContactSerializationRegression verifies ability to query contact items +// and to store contact within Collection. Downloaded contacts are run through +// a regression test to ensure that downloaded items can be uploaded. +func (suite *DataCollectionsIntegrationSuite) TestContactSerializationRegression() { + var ( + users = []string{suite.user} + handlers = BackupHandlers(suite.ac) + ) + + tests := []struct { + name string + scope selectors.ExchangeScope + }{ + { + name: "Default Contact Folder", + scope: selectors.NewExchangeBackup(users).ContactFolders( + []string{DefaultContactFolder}, + selectors.PrefixMatch())[0], + }, + } + + for _, test := range tests { + suite.Run(test.name, func() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + var wg sync.WaitGroup + + edcs, err := createCollections( + ctx, + handlers, + suite.tenantID, + inMock.NewProvider(suite.user, suite.user), + test.scope, + DeltaPaths{}, + control.Defaults(), + newStatusUpdater(t, &wg), + fault.New(true)) + require.NoError(t, err, clues.ToCore(err)) + + wg.Add(len(edcs)) + + require.GreaterOrEqual(t, len(edcs), 1, "expected 1 <= num collections <= 2") + require.GreaterOrEqual(t, 2, len(edcs), "expected 1 <= num collections <= 2") + + for _, edc := range edcs { + isMetadata := edc.FullPath().Service() == path.ExchangeMetadataService + count := 0 + + for stream := range edc.Items(ctx, fault.New(true)) { + buf := &bytes.Buffer{} + read, err := buf.ReadFrom(stream.ToReader()) + assert.NoError(t, err, clues.ToCore(err)) + assert.NotZero(t, read) + + if isMetadata { + continue + } + + contact, err := api.BytesToContactable(buf.Bytes()) + assert.NotNil(t, contact) + assert.NoError(t, err, "converting contact bytes: "+buf.String(), clues.ToCore(err)) + count++ + } + + if isMetadata { + continue + } + + // TODO(ashmrtn): Remove when LocationPath is made part of BackupCollection + // interface. + if !assert.Implements(t, (*data.LocationPather)(nil), edc) { + continue + } + + assert.Equal( + t, + edc.(data.LocationPather).LocationPath().String(), + DefaultContactFolder) + assert.NotZero(t, count) + } + + wg.Wait() + }) + } +} + +// TestEventsSerializationRegression ensures functionality of createCollections +// to be able to successfully query, download and restore event objects +func (suite *DataCollectionsIntegrationSuite) TestEventsSerializationRegression() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + var ( + users = []string{suite.user} + handlers = BackupHandlers(suite.ac) + calID string + bdayID string + ) + + fn := func(gcc graph.CachedContainer) error { + if ptr.Val(gcc.GetDisplayName()) == DefaultCalendar { + calID = ptr.Val(gcc.GetId()) + } + + if ptr.Val(gcc.GetDisplayName()) == "Birthdays" { + bdayID = ptr.Val(gcc.GetId()) + } + + return nil + } + + err := suite.ac.Events().EnumerateContainers(ctx, suite.user, DefaultCalendar, fn, fault.New(true)) + require.NoError(t, err, clues.ToCore(err)) + + tests := []struct { + name, expected string + scope selectors.ExchangeScope + }{ + { + name: "Default Event Calendar", + expected: calID, + scope: selectors.NewExchangeBackup(users).EventCalendars( + []string{DefaultCalendar}, + selectors.PrefixMatch(), + )[0], + }, + { + name: "Birthday Calendar", + expected: bdayID, + scope: selectors.NewExchangeBackup(users).EventCalendars( + []string{"Birthdays"}, + selectors.PrefixMatch(), + )[0], + }, + } + + for _, test := range tests { + suite.Run(test.name, func() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + var wg sync.WaitGroup + + collections, err := createCollections( + ctx, + handlers, + suite.tenantID, + inMock.NewProvider(suite.user, suite.user), + test.scope, + DeltaPaths{}, + control.Defaults(), + newStatusUpdater(t, &wg), + fault.New(true)) + require.NoError(t, err, clues.ToCore(err)) + require.Len(t, collections, 2) + + wg.Add(len(collections)) + + for _, edc := range collections { + var isMetadata bool + + if edc.FullPath().Service() != path.ExchangeMetadataService { + isMetadata = true + assert.Equal(t, test.expected, edc.FullPath().Folder(false)) + } else { + assert.Equal(t, "", edc.FullPath().Folder(false)) + } + + for item := range edc.Items(ctx, fault.New(true)) { + buf := &bytes.Buffer{} + + read, err := buf.ReadFrom(item.ToReader()) + assert.NoError(t, err, clues.ToCore(err)) + assert.NotZero(t, read) + + if isMetadata { + continue + } + + event, err := api.BytesToEventable(buf.Bytes()) + assert.NotNil(t, event) + assert.NoError(t, err, "creating event from bytes: "+buf.String(), clues.ToCore(err)) + } + } + + wg.Wait() + }) + } +} + +type CollectionPopulationSuite struct { tester.Suite creds account.M365Config } func TestServiceIteratorsUnitSuite(t *testing.T) { - suite.Run(t, &ServiceIteratorsSuite{Suite: tester.NewUnitSuite(t)}) + suite.Run(t, &CollectionPopulationSuite{Suite: tester.NewUnitSuite(t)}) } -func (suite *ServiceIteratorsSuite) SetupSuite() { +func (suite *CollectionPopulationSuite) SetupSuite() { a := tester.NewMockM365Account(suite.T()) m365, err := a.M365Config() require.NoError(suite.T(), err, clues.ToCore(err)) suite.creds = m365 } -func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections() { +func (suite *CollectionPopulationSuite) TestPopulateCollections() { var ( qp = graph.QueryParams{ Category: path.EmailCategory, // doesn't matter which one we use. ResourceOwner: inMock.NewProvider("user_id", "user_name"), TenantID: suite.creds.AzureTenantID, } - statusUpdater = func(*support.ConnectorOperationStatus) {} + statusUpdater = func(*support.ControllerOperationStatus) {} allScope = selectors.NewExchangeBackup(nil).MailFolders(selectors.Any())[0] dps = DeltaPaths{} // incrementals are tested separately commonResult = mockGetterResults{ @@ -349,7 +1083,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections() { category: qp.Category, } - collections, err := filterContainersAndFillCollections( + collections, err := populateCollections( ctx, qp, mbh, @@ -435,7 +1169,7 @@ func checkMetadata( assert.Equal(t, expect, catPaths[cat]) } -func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_DuplicateFolders() { +func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_DuplicateFolders() { type scopeCat struct { scope selectors.ExchangeScope cat path.CategoryType @@ -447,7 +1181,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_Dupli TenantID: suite.creds.AzureTenantID, } - statusUpdater = func(*support.ConnectorOperationStatus) {} + statusUpdater = func(*support.ControllerOperationStatus) {} dataTypes = []scopeCat{ { @@ -687,7 +1421,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_Dupli category: qp.Category, } - collections, err := filterContainersAndFillCollections( + collections, err := populateCollections( ctx, qp, mbh, @@ -754,7 +1488,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_Dupli } } -func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_repeatedItems() { +func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_repeatedItems() { newDelta := api.DeltaUpdate{URL: "delta_url"} table := []struct { @@ -832,7 +1566,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_repea ResourceOwner: inMock.NewProvider("user_id", "user_name"), TenantID: suite.creds.AzureTenantID, } - statusUpdater = func(*support.ConnectorOperationStatus) {} + statusUpdater = func(*support.ControllerOperationStatus) {} allScope = selectors.NewExchangeBackup(nil).MailFolders(selectors.Any())[0] dps = DeltaPaths{} // incrementals are tested separately container1 = mockContainer{ @@ -851,7 +1585,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_repea require.Equal(t, "user_id", qp.ResourceOwner.ID(), qp.ResourceOwner) require.Equal(t, "user_name", qp.ResourceOwner.Name(), qp.ResourceOwner) - collections, err := filterContainersAndFillCollections( + collections, err := populateCollections( ctx, qp, mbh, @@ -907,7 +1641,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_repea } } -func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_incrementals_nondelta() { +func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_incrementals_nondelta() { var ( userID = "user_id" tenantID = suite.creds.AzureTenantID @@ -917,7 +1651,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_incre ResourceOwner: inMock.NewProvider("user_id", "user_name"), TenantID: suite.creds.AzureTenantID, } - statusUpdater = func(*support.ConnectorOperationStatus) {} + statusUpdater = func(*support.ControllerOperationStatus) {} allScope = selectors.NewExchangeBackup(nil).MailFolders(selectors.Any())[0] commonResults = mockGetterResults{ added: []string{"added"}, @@ -1270,7 +2004,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_incre } } - collections, err := filterContainersAndFillCollections( + collections, err := populateCollections( ctx, qp, mbh, diff --git a/src/internal/connector/exchange/cache_container.go b/src/internal/m365/exchange/cache_container.go similarity index 93% rename from src/internal/connector/exchange/cache_container.go rename to src/internal/m365/exchange/cache_container.go index acad82a31..b4be9e801 100644 --- a/src/internal/connector/exchange/cache_container.go +++ b/src/internal/m365/exchange/cache_container.go @@ -4,7 +4,7 @@ import ( "github.com/alcionai/clues" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" ) // checkIDAndName is a helper function to ensure that diff --git a/src/internal/connector/exchange/exchange_data_collection.go b/src/internal/m365/exchange/collection.go similarity index 98% rename from src/internal/connector/exchange/exchange_data_collection.go rename to src/internal/m365/exchange/collection.go index 921952b88..bc5ff3027 100644 --- a/src/internal/connector/exchange/exchange_data_collection.go +++ b/src/internal/m365/exchange/collection.go @@ -13,9 +13,9 @@ import ( "github.com/alcionai/clues" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control" @@ -125,7 +125,7 @@ func (col *Collection) LocationPath() *path.Builder { return col.locationPath } -// TODO(ashmrtn): Fill in with previous path once GraphConnector compares old +// TODO(ashmrtn): Fill in with previous path once the Controller compares old // and new folder hierarchies. func (col Collection) PreviousPath() path.Path { return col.prevPath diff --git a/src/internal/connector/exchange/exchange_data_collection_test.go b/src/internal/m365/exchange/collection_test.go similarity index 85% rename from src/internal/connector/exchange/exchange_data_collection_test.go rename to src/internal/m365/exchange/collection_test.go index 212f0c96e..2c023d703 100644 --- a/src/internal/connector/exchange/exchange_data_collection_test.go +++ b/src/internal/m365/exchange/collection_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/graph" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control" @@ -46,20 +46,19 @@ func (mi *mockItemer) Serialize( return nil, mi.serializeErr } -type ExchangeDataCollectionSuite struct { +type CollectionSuite struct { tester.Suite } -func TestExchangeDataCollectionSuite(t *testing.T) { - suite.Run(t, &ExchangeDataCollectionSuite{Suite: tester.NewUnitSuite(t)}) +func TestCollectionSuite(t *testing.T) { + suite.Run(t, &CollectionSuite{Suite: tester.NewUnitSuite(t)}) } -func (suite *ExchangeDataCollectionSuite) TestExchangeDataReader_Valid() { +func (suite *CollectionSuite) TestReader_Valid() { m := []byte("test message") description := "aFile" ed := &Stream{id: description, message: m} - // Read the message using the `ExchangeData` reader and validate it matches what we set buf := &bytes.Buffer{} _, err := buf.ReadFrom(ed.ToReader()) assert.NoError(suite.T(), err, clues.ToCore(err)) @@ -67,7 +66,7 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataReader_Valid() { assert.Equal(suite.T(), description, ed.UUID()) } -func (suite *ExchangeDataCollectionSuite) TestExchangeDataReader_Empty() { +func (suite *CollectionSuite) TestReader_Empty() { var ( empty []byte expected int64 @@ -82,7 +81,7 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataReader_Empty() { assert.NoError(t, err, clues.ToCore(err)) } -func (suite *ExchangeDataCollectionSuite) TestExchangeData_FullPath() { +func (suite *CollectionSuite) TestColleciton_FullPath() { t := suite.T() tenant := "a-tenant" user := "a-user" @@ -105,7 +104,7 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeData_FullPath() { assert.Equal(t, fullPath, edc.FullPath()) } -func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_NewExchangeDataCollection() { +func (suite *CollectionSuite) TestCollection_NewCollection() { t := suite.T() tenant := "a-tenant" user := "a-user" @@ -129,7 +128,7 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_NewExchange assert.Equal(t, fullPath, edc.FullPath()) } -func (suite *ExchangeDataCollectionSuite) TestNewCollection_state() { +func (suite *CollectionSuite) TestNewCollection_state() { fooP, err := path.Build("t", "u", path.ExchangeService, path.EmailCategory, false, "foo") require.NoError(suite.T(), err, clues.ToCore(err)) barP, err := path.Build("t", "u", path.ExchangeService, path.EmailCategory, false, "bar") @@ -189,7 +188,7 @@ func (suite *ExchangeDataCollectionSuite) TestNewCollection_state() { } } -func (suite *ExchangeDataCollectionSuite) TestGetItemWithRetries() { +func (suite *CollectionSuite) TestGetItemWithRetries() { table := []struct { name string items *mockItemer diff --git a/src/internal/connector/exchange/consts.go b/src/internal/m365/exchange/consts.go similarity index 100% rename from src/internal/connector/exchange/consts.go rename to src/internal/m365/exchange/consts.go diff --git a/src/internal/connector/exchange/contact_folder_cache.go b/src/internal/m365/exchange/contact_container_cache.go similarity index 89% rename from src/internal/connector/exchange/contact_folder_cache.go rename to src/internal/m365/exchange/contact_container_cache.go index 75cc2f66d..aa9a45518 100644 --- a/src/internal/connector/exchange/contact_folder_cache.go +++ b/src/internal/m365/exchange/contact_container_cache.go @@ -6,13 +6,13 @@ import ( "github.com/alcionai/clues" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" ) var ( - _ graph.ContainerResolver = &contactFolderCache{} + _ graph.ContainerResolver = &contactContainerCache{} _ containerRefresher = &contactRefresher{} ) @@ -35,14 +35,14 @@ func (r *contactRefresher) refreshContainer( return &f, nil } -type contactFolderCache struct { +type contactContainerCache struct { *containerResolver enumer containersEnumerator getter containerGetter userID string } -func (cfc *contactFolderCache) populateContactRoot( +func (cfc *contactContainerCache) populateContactRoot( ctx context.Context, directoryID string, baseContainerPath []string, @@ -67,7 +67,7 @@ func (cfc *contactFolderCache) populateContactRoot( // objects into the Contact Folder Cache // Function does NOT use Delta Queries as it is not supported // as of (Oct-07-2022) -func (cfc *contactFolderCache) Populate( +func (cfc *contactContainerCache) Populate( ctx context.Context, errs *fault.Bus, baseID string, @@ -89,7 +89,7 @@ func (cfc *contactFolderCache) Populate( return nil } -func (cfc *contactFolderCache) init( +func (cfc *contactContainerCache) init( ctx context.Context, baseNode string, baseContainerPath []string, diff --git a/src/internal/connector/exchange/contacts_backup.go b/src/internal/m365/exchange/contacts_backup.go similarity index 85% rename from src/internal/connector/exchange/contacts_backup.go rename to src/internal/m365/exchange/contacts_backup.go index 4054a17a8..fb8fde2ab 100644 --- a/src/internal/connector/exchange/contacts_backup.go +++ b/src/internal/m365/exchange/contacts_backup.go @@ -1,7 +1,7 @@ package exchange import ( - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/services/m365/api" ) @@ -32,7 +32,7 @@ func (h contactBackupHandler) itemHandler() itemGetterSerializer { func (h contactBackupHandler) NewContainerCache( userID string, ) (string, graph.ContainerResolver) { - return DefaultContactFolder, &contactFolderCache{ + return DefaultContactFolder, &contactContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/connector/exchange/contacts_restore.go b/src/internal/m365/exchange/contacts_restore.go similarity index 95% rename from src/internal/connector/exchange/contacts_restore.go rename to src/internal/m365/exchange/contacts_restore.go index 63d0e87c8..82ff1364a 100644 --- a/src/internal/connector/exchange/contacts_restore.go +++ b/src/internal/m365/exchange/contacts_restore.go @@ -7,7 +7,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" @@ -31,7 +31,7 @@ func newContactRestoreHandler( } func (h contactRestoreHandler) newContainerCache(userID string) graph.ContainerResolver { - return &contactFolderCache{ + return &contactContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/connector/exchange/contacts_restore_test.go b/src/internal/m365/exchange/contacts_restore_test.go similarity index 100% rename from src/internal/connector/exchange/contacts_restore_test.go rename to src/internal/m365/exchange/contacts_restore_test.go diff --git a/src/internal/connector/exchange/container_resolver.go b/src/internal/m365/exchange/container_resolver.go similarity index 99% rename from src/internal/connector/exchange/container_resolver.go rename to src/internal/m365/exchange/container_resolver.go index 0e2730449..368b2ae73 100644 --- a/src/internal/connector/exchange/container_resolver.go +++ b/src/internal/m365/exchange/container_resolver.go @@ -6,7 +6,7 @@ import ( "github.com/alcionai/clues" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/internal/connector/exchange/container_resolver_test.go b/src/internal/m365/exchange/container_resolver_test.go similarity index 84% rename from src/internal/connector/exchange/container_resolver_test.go rename to src/internal/m365/exchange/container_resolver_test.go index 1cfe4690e..f3efdce70 100644 --- a/src/internal/connector/exchange/container_resolver_test.go +++ b/src/internal/m365/exchange/container_resolver_test.go @@ -13,10 +13,12 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" + "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" + "github.com/alcionai/corso/src/pkg/services/m365/api" ) // --------------------------------------------------------------------------- @@ -671,6 +673,118 @@ func (suite *ConfiguredFolderCacheUnitSuite) TestAddToCache() { assert.Equal(t, m.expectedLocation, l.String(), "location path") } +type ContainerResolverSuite struct { + tester.Suite + credentials account.M365Config +} + +func TestContainerResolverIntegrationSuite(t *testing.T) { + suite.Run(t, &ContainerResolverSuite{ + Suite: tester.NewIntegrationSuite( + t, + [][]string{tester.M365AcctCredEnvs}), + }) +} + +func (suite *ContainerResolverSuite) SetupSuite() { + t := suite.T() + + a := tester.NewM365Account(t) + m365, err := a.M365Config() + require.NoError(t, err, clues.ToCore(err)) + + suite.credentials = m365 +} + +func (suite *ContainerResolverSuite) TestPopulate() { + ac, err := api.NewClient(suite.credentials) + require.NoError(suite.T(), err, clues.ToCore(err)) + + eventFunc := func(t *testing.T) graph.ContainerResolver { + return &eventContainerCache{ + userID: tester.M365UserID(t), + enumer: ac.Events(), + getter: ac.Events(), + } + } + + contactFunc := func(t *testing.T) graph.ContainerResolver { + return &contactContainerCache{ + userID: tester.M365UserID(t), + enumer: ac.Contacts(), + getter: ac.Contacts(), + } + } + + tests := []struct { + name, folderInCache, root, basePath string + resolverFunc func(t *testing.T) graph.ContainerResolver + canFind assert.BoolAssertionFunc + }{ + { + name: "Default Event Cache", + // Fine as long as this isn't running against a migrated Exchange server. + folderInCache: DefaultCalendar, + root: DefaultCalendar, + basePath: DefaultCalendar, + resolverFunc: eventFunc, + canFind: assert.True, + }, + { + name: "Default Event Folder Hidden", + folderInCache: DefaultContactFolder, + root: DefaultCalendar, + canFind: assert.False, + resolverFunc: eventFunc, + }, + { + name: "Name Not in Cache", + folderInCache: "testFooBarWhoBar", + root: DefaultCalendar, + canFind: assert.False, + resolverFunc: eventFunc, + }, + { + name: "Default Contact Cache", + folderInCache: DefaultContactFolder, + root: DefaultContactFolder, + basePath: DefaultContactFolder, + canFind: assert.True, + resolverFunc: contactFunc, + }, + { + name: "Default Contact Hidden", + folderInCache: DefaultContactFolder, + root: DefaultContactFolder, + canFind: assert.False, + resolverFunc: contactFunc, + }, + { + name: "Name Not in Cache", + folderInCache: "testFooBarWhoBar", + root: DefaultContactFolder, + canFind: assert.False, + resolverFunc: contactFunc, + }, + } + for _, test := range tests { + suite.Run(test.name, func() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + resolver := test.resolverFunc(t) + + err := resolver.Populate(ctx, fault.New(true), test.root, test.basePath) + require.NoError(t, err, clues.ToCore(err)) + + _, isFound := resolver.LocationInCache(test.folderInCache) + test.canFind(t, isFound, "folder path", test.folderInCache) + }) + } +} + // --------------------------------------------------------------------------- // integration suite // --------------------------------------------------------------------------- @@ -688,7 +802,7 @@ func runCreateDestinationTest( var ( svc = path.ExchangeService - gcr = handler.newContainerCache(userID) + gcc = handler.newContainerCache(userID) ) path1, err := path.Build( @@ -700,17 +814,17 @@ func runCreateDestinationTest( containerNames1...) require.NoError(t, err, clues.ToCore(err)) - containerID, gcr, err := createDestination( + containerID, gcc, err := createDestination( ctx, handler, handler.formatRestoreDestination(destinationName, path1), userID, - gcr, + gcc, true, fault.New(true)) require.NoError(t, err, clues.ToCore(err)) - _, _, err = gcr.IDToPath(ctx, containerID) + _, _, err = gcc.IDToPath(ctx, containerID) assert.NoError(t, err, clues.ToCore(err)) path2, err := path.Build( @@ -722,22 +836,22 @@ func runCreateDestinationTest( containerNames2...) require.NoError(t, err, clues.ToCore(err)) - containerID, gcr, err = createDestination( + containerID, gcc, err = createDestination( ctx, handler, handler.formatRestoreDestination(destinationName, path2), userID, - gcr, + gcc, false, fault.New(true)) require.NoError(t, err, clues.ToCore(err)) - p, l, err := gcr.IDToPath(ctx, containerID) + p, l, err := gcc.IDToPath(ctx, containerID) require.NoError(t, err, clues.ToCore(err)) - _, ok := gcr.LocationInCache(l.String()) + _, ok := gcc.LocationInCache(l.String()) require.True(t, ok, "looking for location in cache: %s", l) - _, ok = gcr.PathInCache(p.String()) + _, ok = gcc.PathInCache(p.String()) require.True(t, ok, "looking for path in cache: %s", p) } diff --git a/src/internal/connector/exchange/event_calendar_cache.go b/src/internal/m365/exchange/event_container_cache.go similarity index 87% rename from src/internal/connector/exchange/event_calendar_cache.go rename to src/internal/m365/exchange/event_container_cache.go index 5e99b4b39..d89a5caa2 100644 --- a/src/internal/connector/exchange/event_calendar_cache.go +++ b/src/internal/m365/exchange/event_container_cache.go @@ -6,14 +6,14 @@ import ( "github.com/alcionai/clues" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" ) -var _ graph.ContainerResolver = &eventCalendarCache{} +var _ graph.ContainerResolver = &eventContainerCache{} -type eventCalendarCache struct { +type eventContainerCache struct { *containerResolver enumer containersEnumerator getter containerGetter @@ -23,7 +23,7 @@ type eventCalendarCache struct { // init ensures that the structure's fields are initialized. // Fields Initialized when cache == nil: // [mc.cache] -func (ecc *eventCalendarCache) init( +func (ecc *eventContainerCache) init( ctx context.Context, ) error { if ecc.containerResolver == nil { @@ -37,7 +37,7 @@ func (ecc *eventCalendarCache) init( // DefaultCalendar is the traditional "Calendar". // Action ensures that cache will stop at appropriate level. // @error iff the struct is not properly instantiated -func (ecc *eventCalendarCache) populateEventRoot(ctx context.Context) error { +func (ecc *eventContainerCache) populateEventRoot(ctx context.Context) error { container := DefaultCalendar f, err := ecc.getter.GetContainerByID(ctx, ecc.userID, container) @@ -59,7 +59,7 @@ func (ecc *eventCalendarCache) populateEventRoot(ctx context.Context) error { // Populate utility function for populating eventCalendarCache. // Executes 1 additional Graph Query // @param baseID: ignored. Present to conform to interface -func (ecc *eventCalendarCache) Populate( +func (ecc *eventContainerCache) Populate( ctx context.Context, errs *fault.Bus, baseID string, @@ -88,7 +88,7 @@ func (ecc *eventCalendarCache) Populate( // AddToCache adds container to map in field 'cache' // @returns error iff the required values are not accessible. -func (ecc *eventCalendarCache) AddToCache(ctx context.Context, f graph.Container) error { +func (ecc *eventContainerCache) AddToCache(ctx context.Context, f graph.Container) error { if err := checkIDAndName(f); err != nil { return clues.Wrap(err, "validating container").WithClues(ctx) } diff --git a/src/internal/connector/exchange/events_backup.go b/src/internal/m365/exchange/events_backup.go similarity index 86% rename from src/internal/connector/exchange/events_backup.go rename to src/internal/m365/exchange/events_backup.go index f77a6a1a3..c1502c965 100644 --- a/src/internal/connector/exchange/events_backup.go +++ b/src/internal/m365/exchange/events_backup.go @@ -1,7 +1,7 @@ package exchange import ( - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/services/m365/api" ) @@ -32,7 +32,7 @@ func (h eventBackupHandler) itemHandler() itemGetterSerializer { func (h eventBackupHandler) NewContainerCache( userID string, ) (string, graph.ContainerResolver) { - return DefaultCalendar, &eventCalendarCache{ + return DefaultCalendar, &eventContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/connector/exchange/events_restore.go b/src/internal/m365/exchange/events_restore.go similarity index 96% rename from src/internal/connector/exchange/events_restore.go rename to src/internal/m365/exchange/events_restore.go index a45de05aa..18540ecaf 100644 --- a/src/internal/connector/exchange/events_restore.go +++ b/src/internal/m365/exchange/events_restore.go @@ -7,7 +7,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" @@ -33,7 +33,7 @@ func newEventRestoreHandler( } func (h eventRestoreHandler) newContainerCache(userID string) graph.ContainerResolver { - return &eventCalendarCache{ + return &eventContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/connector/exchange/events_restore_test.go b/src/internal/m365/exchange/events_restore_test.go similarity index 100% rename from src/internal/connector/exchange/events_restore_test.go rename to src/internal/m365/exchange/events_restore_test.go diff --git a/src/internal/connector/exchange/handlers.go b/src/internal/m365/exchange/handlers.go similarity index 98% rename from src/internal/connector/exchange/handlers.go rename to src/internal/m365/exchange/handlers.go index 0538ebd17..9eb7d1fe1 100644 --- a/src/internal/connector/exchange/handlers.go +++ b/src/internal/m365/exchange/handlers.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/kiota-abstractions-go/serialization" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/internal/connector/exchange/mail_backup.go b/src/internal/m365/exchange/mail_backup.go similarity index 86% rename from src/internal/connector/exchange/mail_backup.go rename to src/internal/m365/exchange/mail_backup.go index 1491a683a..ecd31919c 100644 --- a/src/internal/connector/exchange/mail_backup.go +++ b/src/internal/m365/exchange/mail_backup.go @@ -1,7 +1,7 @@ package exchange import ( - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/services/m365/api" ) @@ -32,7 +32,7 @@ func (h mailBackupHandler) itemHandler() itemGetterSerializer { func (h mailBackupHandler) NewContainerCache( userID string, ) (string, graph.ContainerResolver) { - return rootFolderAlias, &mailFolderCache{ + return rootFolderAlias, &mailContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/connector/exchange/mail_folder_cache.go b/src/internal/m365/exchange/mail_container_cache.go similarity index 87% rename from src/internal/connector/exchange/mail_folder_cache.go rename to src/internal/m365/exchange/mail_container_cache.go index 062f91a23..cf7b0bcdc 100644 --- a/src/internal/connector/exchange/mail_folder_cache.go +++ b/src/internal/m365/exchange/mail_container_cache.go @@ -5,13 +5,13 @@ import ( "github.com/alcionai/clues" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" ) var ( - _ graph.ContainerResolver = &mailFolderCache{} + _ graph.ContainerResolver = &mailContainerCache{} _ containerRefresher = &mailRefresher{} ) @@ -34,10 +34,10 @@ func (r *mailRefresher) refreshContainer( return &f, nil } -// mailFolderCache struct used to improve lookup of directories within exchange.Mail +// mailContainerCache struct used to improve lookup of directories within exchange.Mail // cache map of cachedContainers where the key = M365ID // nameLookup map: Key: DisplayName Value: ID -type mailFolderCache struct { +type mailContainerCache struct { *containerResolver enumer containersEnumerator getter containerGetter @@ -47,7 +47,7 @@ type mailFolderCache struct { // init ensures that the structure's fields are initialized. // Fields Initialized when cache == nil: // [mc.cache] -func (mc *mailFolderCache) init( +func (mc *mailContainerCache) init( ctx context.Context, ) error { if mc.containerResolver == nil { @@ -64,7 +64,7 @@ func (mc *mailFolderCache) init( // rootFolderAlias is the top-level directory for exchange.Mail. // Action ensures that cache will stop at appropriate level. // @error iff the struct is not properly instantiated -func (mc *mailFolderCache) populateMailRoot(ctx context.Context) error { +func (mc *mailContainerCache) populateMailRoot(ctx context.Context) error { f, err := mc.getter.GetContainerByID(ctx, mc.userID, rootFolderAlias) if err != nil { return clues.Wrap(err, "fetching root folder") @@ -89,7 +89,7 @@ func (mc *mailFolderCache) populateMailRoot(ctx context.Context) error { // @param baseID: M365ID of the base of the exchange.Mail.Folder // @param baseContainerPath: the set of folder elements that make up the path // for the base container in the cache. -func (mc *mailFolderCache) Populate( +func (mc *mailContainerCache) Populate( ctx context.Context, errs *fault.Bus, baseID string, diff --git a/src/internal/connector/exchange/mail_folder_cache_test.go b/src/internal/m365/exchange/mail_container_cache_test.go similarity index 98% rename from src/internal/connector/exchange/mail_folder_cache_test.go rename to src/internal/m365/exchange/mail_container_cache_test.go index 59be9386e..5aa602b29 100644 --- a/src/internal/connector/exchange/mail_folder_cache_test.go +++ b/src/internal/m365/exchange/mail_container_cache_test.go @@ -87,7 +87,7 @@ func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() { acm := ac.Mail() - mfc := mailFolderCache{ + mfc := mailContainerCache{ userID: userID, enumer: acm, getter: acm, diff --git a/src/internal/connector/exchange/mail_restore.go b/src/internal/m365/exchange/mail_restore.go similarity index 97% rename from src/internal/connector/exchange/mail_restore.go rename to src/internal/m365/exchange/mail_restore.go index a6e8d2e0e..ce0979859 100644 --- a/src/internal/connector/exchange/mail_restore.go +++ b/src/internal/m365/exchange/mail_restore.go @@ -8,7 +8,7 @@ import ( "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" @@ -34,7 +34,7 @@ func newMailRestoreHandler( } func (h mailRestoreHandler) newContainerCache(userID string) graph.ContainerResolver { - return &mailFolderCache{ + return &mailContainerCache{ userID: userID, enumer: h.ac, getter: h.ac, diff --git a/src/internal/connector/exchange/mail_restore_test.go b/src/internal/m365/exchange/mail_restore_test.go similarity index 100% rename from src/internal/connector/exchange/mail_restore_test.go rename to src/internal/m365/exchange/mail_restore_test.go diff --git a/src/internal/connector/exchange/mock/collections.go b/src/internal/m365/exchange/mock/collections.go similarity index 100% rename from src/internal/connector/exchange/mock/collections.go rename to src/internal/m365/exchange/mock/collections.go diff --git a/src/internal/connector/exchange/mock/contact.go b/src/internal/m365/exchange/mock/contact.go similarity index 100% rename from src/internal/connector/exchange/mock/contact.go rename to src/internal/m365/exchange/mock/contact.go diff --git a/src/internal/connector/exchange/mock/event.go b/src/internal/m365/exchange/mock/event.go similarity index 100% rename from src/internal/connector/exchange/mock/event.go rename to src/internal/m365/exchange/mock/event.go diff --git a/src/internal/connector/exchange/mock/mail.go b/src/internal/m365/exchange/mock/mail.go similarity index 100% rename from src/internal/connector/exchange/mock/mail.go rename to src/internal/m365/exchange/mock/mail.go diff --git a/src/internal/connector/exchange/mock/mock_test.go b/src/internal/m365/exchange/mock/mock_test.go similarity index 100% rename from src/internal/connector/exchange/mock/mock_test.go rename to src/internal/m365/exchange/mock/mock_test.go diff --git a/src/internal/connector/exchange/service_restore.go b/src/internal/m365/exchange/restore.go similarity index 93% rename from src/internal/connector/exchange/service_restore.go rename to src/internal/m365/exchange/restore.go index b55c2c318..7703933df 100644 --- a/src/internal/connector/exchange/service_restore.go +++ b/src/internal/m365/exchange/restore.go @@ -9,10 +9,10 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control" @@ -22,16 +22,16 @@ import ( "github.com/alcionai/corso/src/pkg/services/m365/api" ) -// RestoreCollections restores M365 objects in data.RestoreCollection to MSFT +// ConsumeRestoreCollections restores M365 objects in data.RestoreCollection to MSFT // store through GraphAPI. -func RestoreCollections( +func ConsumeRestoreCollections( ctx context.Context, ac api.Client, restoreCfg control.RestoreConfig, dcs []data.RestoreCollection, deets *details.Builder, errs *fault.Bus, -) (*support.ConnectorOperationStatus, error) { +) (*support.ControllerOperationStatus, error) { if len(dcs) == 0 { return support.CreateStatus(ctx, support.Restore, 0, support.CollectionMetrics{}, ""), nil } @@ -73,7 +73,7 @@ func RestoreCollections( isNewCache = true } - containerID, gcr, err := createDestination( + containerID, gcc, err := createDestination( ictx, handler, handler.formatRestoreDestination(restoreCfg.Location, dc.FullPath()), @@ -86,7 +86,7 @@ func RestoreCollections( continue } - directoryCache[category] = gcr + directoryCache[category] = gcc ictx = clues.Add(ictx, "restore_destination_id", containerID) @@ -131,7 +131,7 @@ func restoreCollection( deets *details.Builder, errs *fault.Bus, ) (support.CollectionMetrics, error) { - ctx, end := diagnostics.Span(ctx, "gc:exchange:restoreCollection", diagnostics.Label("path", dc.FullPath())) + ctx, end := diagnostics.Span(ctx, "m365:exchange:restoreCollection", diagnostics.Label("path", dc.FullPath())) defer end() var ( @@ -159,7 +159,7 @@ func restoreCollection( } ictx := clues.Add(ctx, "item_id", itemData.UUID()) - trace.Log(ictx, "gc:exchange:restoreCollection:item", itemData.UUID()) + trace.Log(ictx, "m365:exchange:restoreCollection:item", itemData.UUID()) metrics.Objects++ buf := &bytes.Buffer{} diff --git a/src/internal/connector/exchange/restore_test.go b/src/internal/m365/exchange/restore_test.go similarity index 99% rename from src/internal/connector/exchange/restore_test.go rename to src/internal/m365/exchange/restore_test.go index eb308f2dc..5b4bbb825 100644 --- a/src/internal/connector/exchange/restore_test.go +++ b/src/internal/m365/exchange/restore_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/fault" diff --git a/src/internal/connector/exchange/testdata/handlers.go b/src/internal/m365/exchange/testdata/handlers.go similarity index 86% rename from src/internal/connector/exchange/testdata/handlers.go rename to src/internal/m365/exchange/testdata/handlers.go index 396de9008..559c23b2c 100644 --- a/src/internal/connector/exchange/testdata/handlers.go +++ b/src/internal/m365/exchange/testdata/handlers.go @@ -7,8 +7,8 @@ import ( "github.com/alcionai/clues" "github.com/stretchr/testify/require" - "github.com/alcionai/corso/src/internal/connector/exchange" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/exchange" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/internal/connector/exchange/transform.go b/src/internal/m365/exchange/transform.go similarity index 100% rename from src/internal/connector/exchange/transform.go rename to src/internal/m365/exchange/transform.go diff --git a/src/internal/connector/exchange/transform_test.go b/src/internal/m365/exchange/transform_test.go similarity index 98% rename from src/internal/connector/exchange/transform_test.go rename to src/internal/m365/exchange/transform_test.go index fe1bc1601..4e3ce4278 100644 --- a/src/internal/connector/exchange/transform_test.go +++ b/src/internal/m365/exchange/transform_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/services/m365/api" ) diff --git a/src/internal/connector/graph/betasdk/beta_client.go b/src/internal/m365/graph/betasdk/beta_client.go similarity index 98% rename from src/internal/connector/graph/betasdk/beta_client.go rename to src/internal/m365/graph/betasdk/beta_client.go index 0f7816ac1..62224721b 100644 --- a/src/internal/connector/graph/betasdk/beta_client.go +++ b/src/internal/m365/graph/betasdk/beta_client.go @@ -8,7 +8,7 @@ import ( ktext "github.com/microsoft/kiota-serialization-text-go" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" - i1a3c1a5501c5e41b7fd169f2d4c768dce9b096ac28fb5431bf02afcc57295411 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/sites" + i1a3c1a5501c5e41b7fd169f2d4c768dce9b096ac28fb5431bf02afcc57295411 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/sites" ) // BetaClient the main entry point of the SDK, exposes the configuration and the fluent API. diff --git a/src/internal/connector/graph/betasdk/beta_client_test.go b/src/internal/m365/graph/betasdk/beta_client_test.go similarity index 97% rename from src/internal/connector/graph/betasdk/beta_client_test.go rename to src/internal/m365/graph/betasdk/beta_client_test.go index d0d19de11..9e7fcab00 100644 --- a/src/internal/connector/graph/betasdk/beta_client_test.go +++ b/src/internal/m365/graph/betasdk/beta_client_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" ) diff --git a/src/internal/connector/graph/betasdk/kiota-lock.json b/src/internal/m365/graph/betasdk/kiota-lock.json similarity index 99% rename from src/internal/connector/graph/betasdk/kiota-lock.json rename to src/internal/m365/graph/betasdk/kiota-lock.json index 21a111aef..c1819639e 100644 --- a/src/internal/connector/graph/betasdk/kiota-lock.json +++ b/src/internal/m365/graph/betasdk/kiota-lock.json @@ -2,7 +2,7 @@ "lockFileVersion": "1.0.0", "kiotaVersion": "0.10.0.0", "clientClassName": "BetaClient", - "clientNamespaceName": "github.com/alcionai/corso/src/internal/connector/graph/betasdk", + "clientNamespaceName": "github.com/alcionai/corso/src/internal/m365/graph/betasdk", "language": "Go", "betaVersion": "0.53.0", "usesBackingStore": false, diff --git a/src/internal/connector/graph/betasdk/models/base_item.go b/src/internal/m365/graph/betasdk/models/base_item.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/base_item.go rename to src/internal/m365/graph/betasdk/models/base_item.go diff --git a/src/internal/connector/graph/betasdk/models/canvas_layout.go b/src/internal/m365/graph/betasdk/models/canvas_layout.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/canvas_layout.go rename to src/internal/m365/graph/betasdk/models/canvas_layout.go diff --git a/src/internal/connector/graph/betasdk/models/canvas_layoutable.go b/src/internal/m365/graph/betasdk/models/canvas_layoutable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/canvas_layoutable.go rename to src/internal/m365/graph/betasdk/models/canvas_layoutable.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section.go b/src/internal/m365/graph/betasdk/models/horizontal_section.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section.go rename to src/internal/m365/graph/betasdk/models/horizontal_section.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section_collection_response.go b/src/internal/m365/graph/betasdk/models/horizontal_section_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section_collection_response.go rename to src/internal/m365/graph/betasdk/models/horizontal_section_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section_collection_responseable.go b/src/internal/m365/graph/betasdk/models/horizontal_section_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/horizontal_section_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section_column.go b/src/internal/m365/graph/betasdk/models/horizontal_section_column.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section_column.go rename to src/internal/m365/graph/betasdk/models/horizontal_section_column.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section_column_collection_response.go b/src/internal/m365/graph/betasdk/models/horizontal_section_column_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section_column_collection_response.go rename to src/internal/m365/graph/betasdk/models/horizontal_section_column_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section_column_collection_responseable.go b/src/internal/m365/graph/betasdk/models/horizontal_section_column_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section_column_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/horizontal_section_column_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section_columnable.go b/src/internal/m365/graph/betasdk/models/horizontal_section_columnable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section_columnable.go rename to src/internal/m365/graph/betasdk/models/horizontal_section_columnable.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_section_layout_type.go b/src/internal/m365/graph/betasdk/models/horizontal_section_layout_type.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_section_layout_type.go rename to src/internal/m365/graph/betasdk/models/horizontal_section_layout_type.go diff --git a/src/internal/connector/graph/betasdk/models/horizontal_sectionable.go b/src/internal/m365/graph/betasdk/models/horizontal_sectionable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/horizontal_sectionable.go rename to src/internal/m365/graph/betasdk/models/horizontal_sectionable.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_string_pair.go b/src/internal/m365/graph/betasdk/models/meta_data_key_string_pair.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_string_pair.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_string_pair.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_string_pair_collection_response.go b/src/internal/m365/graph/betasdk/models/meta_data_key_string_pair_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_string_pair_collection_response.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_string_pair_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_string_pair_collection_responseable.go b/src/internal/m365/graph/betasdk/models/meta_data_key_string_pair_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_string_pair_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_string_pair_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_string_pairable.go b/src/internal/m365/graph/betasdk/models/meta_data_key_string_pairable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_string_pairable.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_string_pairable.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_value_pair.go b/src/internal/m365/graph/betasdk/models/meta_data_key_value_pair.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_value_pair.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_value_pair.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_value_pair_collection_response.go b/src/internal/m365/graph/betasdk/models/meta_data_key_value_pair_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_value_pair_collection_response.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_value_pair_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_value_pair_collection_responseable.go b/src/internal/m365/graph/betasdk/models/meta_data_key_value_pair_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_value_pair_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_value_pair_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/meta_data_key_value_pairable.go b/src/internal/m365/graph/betasdk/models/meta_data_key_value_pairable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/meta_data_key_value_pairable.go rename to src/internal/m365/graph/betasdk/models/meta_data_key_value_pairable.go diff --git a/src/internal/connector/graph/betasdk/models/page_layout_type.go b/src/internal/m365/graph/betasdk/models/page_layout_type.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/page_layout_type.go rename to src/internal/m365/graph/betasdk/models/page_layout_type.go diff --git a/src/internal/connector/graph/betasdk/models/page_promotion_type.go b/src/internal/m365/graph/betasdk/models/page_promotion_type.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/page_promotion_type.go rename to src/internal/m365/graph/betasdk/models/page_promotion_type.go diff --git a/src/internal/connector/graph/betasdk/models/publication_facet.go b/src/internal/m365/graph/betasdk/models/publication_facet.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/publication_facet.go rename to src/internal/m365/graph/betasdk/models/publication_facet.go diff --git a/src/internal/connector/graph/betasdk/models/publication_facetable.go b/src/internal/m365/graph/betasdk/models/publication_facetable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/publication_facetable.go rename to src/internal/m365/graph/betasdk/models/publication_facetable.go diff --git a/src/internal/connector/graph/betasdk/models/reactions_facet.go b/src/internal/m365/graph/betasdk/models/reactions_facet.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/reactions_facet.go rename to src/internal/m365/graph/betasdk/models/reactions_facet.go diff --git a/src/internal/connector/graph/betasdk/models/reactions_facetable.go b/src/internal/m365/graph/betasdk/models/reactions_facetable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/reactions_facetable.go rename to src/internal/m365/graph/betasdk/models/reactions_facetable.go diff --git a/src/internal/connector/graph/betasdk/models/section_emphasis_type.go b/src/internal/m365/graph/betasdk/models/section_emphasis_type.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/section_emphasis_type.go rename to src/internal/m365/graph/betasdk/models/section_emphasis_type.go diff --git a/src/internal/connector/graph/betasdk/models/server_processed_content.go b/src/internal/m365/graph/betasdk/models/server_processed_content.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/server_processed_content.go rename to src/internal/m365/graph/betasdk/models/server_processed_content.go diff --git a/src/internal/connector/graph/betasdk/models/server_processed_contentable.go b/src/internal/m365/graph/betasdk/models/server_processed_contentable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/server_processed_contentable.go rename to src/internal/m365/graph/betasdk/models/server_processed_contentable.go diff --git a/src/internal/connector/graph/betasdk/models/site_access_type.go b/src/internal/m365/graph/betasdk/models/site_access_type.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_access_type.go rename to src/internal/m365/graph/betasdk/models/site_access_type.go diff --git a/src/internal/connector/graph/betasdk/models/site_page.go b/src/internal/m365/graph/betasdk/models/site_page.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_page.go rename to src/internal/m365/graph/betasdk/models/site_page.go diff --git a/src/internal/connector/graph/betasdk/models/site_page_collection_response.go b/src/internal/m365/graph/betasdk/models/site_page_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_page_collection_response.go rename to src/internal/m365/graph/betasdk/models/site_page_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/site_page_collection_responseable.go b/src/internal/m365/graph/betasdk/models/site_page_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_page_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/site_page_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/site_pageable.go b/src/internal/m365/graph/betasdk/models/site_pageable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_pageable.go rename to src/internal/m365/graph/betasdk/models/site_pageable.go diff --git a/src/internal/connector/graph/betasdk/models/site_security_level.go b/src/internal/m365/graph/betasdk/models/site_security_level.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_security_level.go rename to src/internal/m365/graph/betasdk/models/site_security_level.go diff --git a/src/internal/connector/graph/betasdk/models/site_settings.go b/src/internal/m365/graph/betasdk/models/site_settings.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_settings.go rename to src/internal/m365/graph/betasdk/models/site_settings.go diff --git a/src/internal/connector/graph/betasdk/models/site_settingsable.go b/src/internal/m365/graph/betasdk/models/site_settingsable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/site_settingsable.go rename to src/internal/m365/graph/betasdk/models/site_settingsable.go diff --git a/src/internal/connector/graph/betasdk/models/standard_web_part.go b/src/internal/m365/graph/betasdk/models/standard_web_part.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/standard_web_part.go rename to src/internal/m365/graph/betasdk/models/standard_web_part.go diff --git a/src/internal/connector/graph/betasdk/models/standard_web_part_collection_response.go b/src/internal/m365/graph/betasdk/models/standard_web_part_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/standard_web_part_collection_response.go rename to src/internal/m365/graph/betasdk/models/standard_web_part_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/standard_web_part_collection_responseable.go b/src/internal/m365/graph/betasdk/models/standard_web_part_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/standard_web_part_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/standard_web_part_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/standard_web_partable.go b/src/internal/m365/graph/betasdk/models/standard_web_partable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/standard_web_partable.go rename to src/internal/m365/graph/betasdk/models/standard_web_partable.go diff --git a/src/internal/connector/graph/betasdk/models/text_web_part.go b/src/internal/m365/graph/betasdk/models/text_web_part.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/text_web_part.go rename to src/internal/m365/graph/betasdk/models/text_web_part.go diff --git a/src/internal/connector/graph/betasdk/models/text_web_part_collection_response.go b/src/internal/m365/graph/betasdk/models/text_web_part_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/text_web_part_collection_response.go rename to src/internal/m365/graph/betasdk/models/text_web_part_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/text_web_part_collection_responseable.go b/src/internal/m365/graph/betasdk/models/text_web_part_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/text_web_part_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/text_web_part_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/text_web_partable.go b/src/internal/m365/graph/betasdk/models/text_web_partable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/text_web_partable.go rename to src/internal/m365/graph/betasdk/models/text_web_partable.go diff --git a/src/internal/connector/graph/betasdk/models/title_area.go b/src/internal/m365/graph/betasdk/models/title_area.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/title_area.go rename to src/internal/m365/graph/betasdk/models/title_area.go diff --git a/src/internal/connector/graph/betasdk/models/title_area_layout_type.go b/src/internal/m365/graph/betasdk/models/title_area_layout_type.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/title_area_layout_type.go rename to src/internal/m365/graph/betasdk/models/title_area_layout_type.go diff --git a/src/internal/connector/graph/betasdk/models/title_area_text_alignment_type.go b/src/internal/m365/graph/betasdk/models/title_area_text_alignment_type.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/title_area_text_alignment_type.go rename to src/internal/m365/graph/betasdk/models/title_area_text_alignment_type.go diff --git a/src/internal/connector/graph/betasdk/models/title_areaable.go b/src/internal/m365/graph/betasdk/models/title_areaable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/title_areaable.go rename to src/internal/m365/graph/betasdk/models/title_areaable.go diff --git a/src/internal/connector/graph/betasdk/models/vertical_section.go b/src/internal/m365/graph/betasdk/models/vertical_section.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/vertical_section.go rename to src/internal/m365/graph/betasdk/models/vertical_section.go diff --git a/src/internal/connector/graph/betasdk/models/vertical_sectionable.go b/src/internal/m365/graph/betasdk/models/vertical_sectionable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/vertical_sectionable.go rename to src/internal/m365/graph/betasdk/models/vertical_sectionable.go diff --git a/src/internal/connector/graph/betasdk/models/web_part.go b/src/internal/m365/graph/betasdk/models/web_part.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_part.go rename to src/internal/m365/graph/betasdk/models/web_part.go diff --git a/src/internal/connector/graph/betasdk/models/web_part_collection_response.go b/src/internal/m365/graph/betasdk/models/web_part_collection_response.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_part_collection_response.go rename to src/internal/m365/graph/betasdk/models/web_part_collection_response.go diff --git a/src/internal/connector/graph/betasdk/models/web_part_collection_responseable.go b/src/internal/m365/graph/betasdk/models/web_part_collection_responseable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_part_collection_responseable.go rename to src/internal/m365/graph/betasdk/models/web_part_collection_responseable.go diff --git a/src/internal/connector/graph/betasdk/models/web_part_data.go b/src/internal/m365/graph/betasdk/models/web_part_data.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_part_data.go rename to src/internal/m365/graph/betasdk/models/web_part_data.go diff --git a/src/internal/connector/graph/betasdk/models/web_part_dataable.go b/src/internal/m365/graph/betasdk/models/web_part_dataable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_part_dataable.go rename to src/internal/m365/graph/betasdk/models/web_part_dataable.go diff --git a/src/internal/connector/graph/betasdk/models/web_part_position.go b/src/internal/m365/graph/betasdk/models/web_part_position.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_part_position.go rename to src/internal/m365/graph/betasdk/models/web_part_position.go diff --git a/src/internal/connector/graph/betasdk/models/web_part_positionable.go b/src/internal/m365/graph/betasdk/models/web_part_positionable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_part_positionable.go rename to src/internal/m365/graph/betasdk/models/web_part_positionable.go diff --git a/src/internal/connector/graph/betasdk/models/web_partable.go b/src/internal/m365/graph/betasdk/models/web_partable.go similarity index 100% rename from src/internal/connector/graph/betasdk/models/web_partable.go rename to src/internal/m365/graph/betasdk/models/web_partable.go diff --git a/src/internal/connector/graph/betasdk/sites/count_request_builder.go b/src/internal/m365/graph/betasdk/sites/count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_count_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_count_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_horizontal_section_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_horizontal_section_item_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_horizontal_section_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_horizontal_section_item_request_builder.go index 0845ecee4..c5ad01383 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_horizontal_section_item_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_horizontal_section_item_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutHorizontalSectionsHorizontalSectionItemRequestBuilder diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_count_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_horizontal_section_column_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_horizontal_section_column_item_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_horizontal_section_column_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_horizontal_section_column_item_request_builder.go index c1a8315ce..761a7930e 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_horizontal_section_column_item_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_horizontal_section_column_item_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutHorizontalSectionsItemColumnsHorizontalSectionColumnItemRequestBuilder provides operations to manage the columns property of the microsoft.graph.horizontalSection entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_count_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_item_get_position_of_web_part_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_item_get_position_of_web_part_request_builder.go similarity index 98% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_item_get_position_of_web_part_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_item_get_position_of_web_part_request_builder.go index 14429d80f..8e7e069ac 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_item_get_position_of_web_part_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_item_get_position_of_web_part_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutHorizontalSectionsItemColumnsItemWebpartsItemGetPositionOfWebPartRequestBuilder provides operations to call the getPositionOfWebPart method. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_request_builder.go index 4d2a94186..e4627c8d2 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutHorizontalSectionsItemColumnsItemWebpartsRequestBuilder provides operations to manage the webparts property of the microsoft.graph.horizontalSectionColumn entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_web_part_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_web_part_item_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_web_part_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_web_part_item_request_builder.go index 0ce7becda..728610b97 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_web_part_item_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_item_webparts_web_part_item_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutHorizontalSectionsItemColumnsItemWebpartsWebPartItemRequestBuilder provides operations to manage the webparts property of the microsoft.graph.horizontalSectionColumn entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_request_builder.go index 368738104..df91fde72 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_item_columns_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutHorizontalSectionsItemColumnsRequestBuilder provides operations to manage the columns property of the microsoft.graph.horizontalSection entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_request_builder.go index 829b830f0..ddce74a8c 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_horizontal_sections_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutHorizontalSectionsRequestBuilder provides operations to manage the horizontalSections property of the microsoft.graph.canvasLayout entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_request_builder.go index bbca05a9b..d717ca335 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutRequestBuilder provides operations to manage the canvasLayout property of the microsoft.graph.sitePage entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_request_builder.go index 3fbb916ca..47eecd453 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutVerticalSectionRequestBuilder provides operations to manage the verticalSection property of the microsoft.graph.canvasLayout entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_count_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_item_get_position_of_web_part_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_item_get_position_of_web_part_request_builder.go similarity index 98% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_item_get_position_of_web_part_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_item_get_position_of_web_part_request_builder.go index d63ff729a..095417526 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_item_get_position_of_web_part_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_item_get_position_of_web_part_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutVerticalSectionWebpartsItemGetPositionOfWebPartRequestBuilder provides operations to call the getPositionOfWebPart method. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_request_builder.go index bd1885be1..c6e339cc2 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutVerticalSectionWebpartsRequestBuilder provides operations to manage the webparts property of the microsoft.graph.verticalSection entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_web_part_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_web_part_item_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_web_part_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_web_part_item_request_builder.go index fdb5025c5..02fa2b0ac 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_web_part_item_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_canvas_layout_vertical_section_webparts_web_part_item_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemCanvasLayoutVerticalSectionWebpartsWebPartItemRequestBuilder provides operations to manage the webparts property of the microsoft.graph.verticalSection entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_body.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_body.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_body.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_body.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_bodyable.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_bodyable.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_bodyable.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_post_request_bodyable.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_response.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_response.go similarity index 97% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_response.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_response.go index fa89d8855..3e2b17cd8 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_response.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_response.go @@ -4,7 +4,7 @@ import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" msmodel "github.com/microsoftgraph/msgraph-sdk-go/models" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemGetWebPartsByPositionResponse provides operations to call the getWebPartsByPosition method. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_responseable.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_responseable.go similarity index 90% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_responseable.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_responseable.go index f862929ab..ef91ec75c 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_responseable.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_get_web_parts_by_position_responseable.go @@ -4,7 +4,7 @@ import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" msmodel "github.com/microsoftgraph/msgraph-sdk-go/models" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemGetWebPartsByPositionResponseable diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_publish_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_publish_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_publish_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_publish_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_count_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_item_get_position_of_web_part_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_item_get_position_of_web_part_request_builder.go similarity index 98% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_item_get_position_of_web_part_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_item_get_position_of_web_part_request_builder.go index 9db79ace5..af2795798 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_item_get_position_of_web_part_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_item_get_position_of_web_part_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemWebPartsItemGetPositionOfWebPartRequestBuilder provides operations to call the getPositionOfWebPart method. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_request_builder.go index e2e32c640..6d93b9b76 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemWebPartsRequestBuilder provides operations to manage the webParts property of the microsoft.graph.sitePage entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_web_part_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_web_part_item_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_web_part_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_web_part_item_request_builder.go index 1c16fc8df..e8be53a64 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_item_web_parts_web_part_item_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_item_web_parts_web_part_item_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesItemWebPartsWebPartItemRequestBuilder provides operations to manage the webParts property of the microsoft.graph.sitePage entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_request_builder.go index 6c82f58df..aa5e63865 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesRequestBuilder provides operations to manage the pages property of the microsoft.graph.site entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_pages_site_page_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_pages_site_page_item_request_builder.go similarity index 99% rename from src/internal/connector/graph/betasdk/sites/item_pages_site_page_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_pages_site_page_item_request_builder.go index 29fda72bd..6b118713a 100644 --- a/src/internal/connector/graph/betasdk/sites/item_pages_site_page_item_request_builder.go +++ b/src/internal/m365/graph/betasdk/sites/item_pages_site_page_item_request_builder.go @@ -6,7 +6,7 @@ import ( i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" i7ad325c11fbf3db4d761c429267362d8b24daa1eda0081f914ebc3cdc85181a0 "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors" - ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + ifda19816f54f079134d70c11e75d6b26799300cf72079e282f1d3bb9a6750354 "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // ItemPagesSitePageItemRequestBuilder provides operations to manage the pages property of the microsoft.graph.site entity. diff --git a/src/internal/connector/graph/betasdk/sites/item_sites_count_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_sites_count_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_sites_count_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_sites_count_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/item_sites_site_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/item_sites_site_item_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/item_sites_site_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/item_sites_site_item_request_builder.go diff --git a/src/internal/connector/graph/betasdk/sites/site_item_request_builder.go b/src/internal/m365/graph/betasdk/sites/site_item_request_builder.go similarity index 100% rename from src/internal/connector/graph/betasdk/sites/site_item_request_builder.go rename to src/internal/m365/graph/betasdk/sites/site_item_request_builder.go diff --git a/src/internal/connector/graph/cache_container.go b/src/internal/m365/graph/cache_container.go similarity index 100% rename from src/internal/connector/graph/cache_container.go rename to src/internal/m365/graph/cache_container.go diff --git a/src/internal/connector/graph/collections.go b/src/internal/m365/graph/collections.go similarity index 98% rename from src/internal/connector/graph/collections.go rename to src/internal/m365/graph/collections.go index ee941f81c..24a8138f3 100644 --- a/src/internal/connector/graph/collections.go +++ b/src/internal/m365/graph/collections.go @@ -5,8 +5,8 @@ import ( "github.com/alcionai/clues" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/internal/connector/graph/collections_test.go b/src/internal/m365/graph/collections_test.go similarity index 100% rename from src/internal/connector/graph/collections_test.go rename to src/internal/m365/graph/collections_test.go diff --git a/src/internal/connector/graph/concurrency_middleware.go b/src/internal/m365/graph/concurrency_middleware.go similarity index 100% rename from src/internal/connector/graph/concurrency_middleware.go rename to src/internal/m365/graph/concurrency_middleware.go diff --git a/src/internal/connector/graph/concurrency_middleware_test.go b/src/internal/m365/graph/concurrency_middleware_test.go similarity index 100% rename from src/internal/connector/graph/concurrency_middleware_test.go rename to src/internal/m365/graph/concurrency_middleware_test.go diff --git a/src/internal/connector/graph/consts.go b/src/internal/m365/graph/consts.go similarity index 100% rename from src/internal/connector/graph/consts.go rename to src/internal/m365/graph/consts.go diff --git a/src/internal/connector/graph/consts_test.go b/src/internal/m365/graph/consts_test.go similarity index 100% rename from src/internal/connector/graph/consts_test.go rename to src/internal/m365/graph/consts_test.go diff --git a/src/internal/connector/graph/errors.go b/src/internal/m365/graph/errors.go similarity index 100% rename from src/internal/connector/graph/errors.go rename to src/internal/m365/graph/errors.go diff --git a/src/internal/connector/graph/errors_test.go b/src/internal/m365/graph/errors_test.go similarity index 100% rename from src/internal/connector/graph/errors_test.go rename to src/internal/m365/graph/errors_test.go diff --git a/src/internal/connector/graph/http_wrapper.go b/src/internal/m365/graph/http_wrapper.go similarity index 100% rename from src/internal/connector/graph/http_wrapper.go rename to src/internal/m365/graph/http_wrapper.go diff --git a/src/internal/connector/graph/http_wrapper_test.go b/src/internal/m365/graph/http_wrapper_test.go similarity index 100% rename from src/internal/connector/graph/http_wrapper_test.go rename to src/internal/m365/graph/http_wrapper_test.go diff --git a/src/internal/connector/graph/metadata/metadata.go b/src/internal/m365/graph/metadata/metadata.go similarity index 83% rename from src/internal/connector/graph/metadata/metadata.go rename to src/internal/m365/graph/metadata/metadata.go index 6aa0d5fa6..9b61a3fc0 100644 --- a/src/internal/connector/graph/metadata/metadata.go +++ b/src/internal/m365/graph/metadata/metadata.go @@ -1,7 +1,7 @@ package metadata import ( - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/internal/connector/graph/metadata/metadata_test.go b/src/internal/m365/graph/metadata/metadata_test.go similarity index 95% rename from src/internal/connector/graph/metadata/metadata_test.go rename to src/internal/m365/graph/metadata/metadata_test.go index 2abef52d3..6501c667c 100644 --- a/src/internal/connector/graph/metadata/metadata_test.go +++ b/src/internal/m365/graph/metadata/metadata_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/graph/metadata" - odmetadata "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/graph/metadata" + odmetadata "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/internal/connector/graph/metadata_collection.go b/src/internal/m365/graph/metadata_collection.go similarity index 96% rename from src/internal/connector/graph/metadata_collection.go rename to src/internal/m365/graph/metadata_collection.go index 4b29aa792..1c8112d47 100644 --- a/src/internal/connector/graph/metadata_collection.go +++ b/src/internal/m365/graph/metadata_collection.go @@ -8,8 +8,8 @@ import ( "github.com/alcionai/clues" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" ) @@ -115,13 +115,13 @@ func (md MetadataCollection) FullPath() path.Path { return md.fullPath } -// TODO(ashmrtn): Fill in with previous path once GraphConnector compares old +// TODO(ashmrtn): Fill in with previous path once the Controller compares old // and new folder hierarchies. func (md MetadataCollection) PreviousPath() path.Path { return nil } -// TODO(ashmrtn): Fill in once GraphConnector compares old and new folder +// TODO(ashmrtn): Fill in once the Controller compares old and new folder // hierarchies. func (md MetadataCollection) State() data.CollectionState { return data.NewState diff --git a/src/internal/connector/graph/metadata_collection_test.go b/src/internal/m365/graph/metadata_collection_test.go similarity index 96% rename from src/internal/connector/graph/metadata_collection_test.go rename to src/internal/m365/graph/metadata_collection_test.go index ef3058c90..3748d03b2 100644 --- a/src/internal/connector/graph/metadata_collection_test.go +++ b/src/internal/m365/graph/metadata_collection_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/support" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" @@ -82,7 +82,7 @@ func (suite *MetadataCollectionUnitSuite) TestItems() { c := NewMetadataCollection( p, items, - func(c *support.ConnectorOperationStatus) { + func(c *support.ControllerOperationStatus) { assert.Equal(t, len(itemNames), c.Metrics.Objects) assert.Equal(t, len(itemNames), c.Metrics.Successes) }, @@ -167,7 +167,7 @@ func (suite *MetadataCollectionUnitSuite) TestMakeMetadataCollection() { test.service, test.cat, []MetadataCollectionEntry{test.metadata}, - func(*support.ConnectorOperationStatus) {}) + func(*support.ControllerOperationStatus) {}) test.errCheck(t, err, clues.ToCore(err)) if err != nil { diff --git a/src/internal/connector/graph/middleware.go b/src/internal/m365/graph/middleware.go similarity index 100% rename from src/internal/connector/graph/middleware.go rename to src/internal/m365/graph/middleware.go diff --git a/src/internal/connector/graph/middleware_test.go b/src/internal/m365/graph/middleware_test.go similarity index 100% rename from src/internal/connector/graph/middleware_test.go rename to src/internal/m365/graph/middleware_test.go diff --git a/src/internal/connector/graph/mock/service.go b/src/internal/m365/graph/mock/service.go similarity index 95% rename from src/internal/connector/graph/mock/service.go rename to src/internal/m365/graph/mock/service.go index a44d9f1ca..813488626 100644 --- a/src/internal/connector/graph/mock/service.go +++ b/src/internal/m365/graph/mock/service.go @@ -5,7 +5,7 @@ import ( "github.com/h2non/gock" msgraphsdkgo "github.com/microsoftgraph/msgraph-sdk-go" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/account" ) diff --git a/src/internal/connector/graph/service.go b/src/internal/m365/graph/service.go similarity index 100% rename from src/internal/connector/graph/service.go rename to src/internal/m365/graph/service.go diff --git a/src/internal/connector/graph/service_test.go b/src/internal/m365/graph/service_test.go similarity index 100% rename from src/internal/connector/graph/service_test.go rename to src/internal/m365/graph/service_test.go diff --git a/src/internal/connector/graph/uploadsession.go b/src/internal/m365/graph/uploadsession.go similarity index 100% rename from src/internal/connector/graph/uploadsession.go rename to src/internal/m365/graph/uploadsession.go diff --git a/src/internal/connector/graph/uploadsession_test.go b/src/internal/m365/graph/uploadsession_test.go similarity index 100% rename from src/internal/connector/graph/uploadsession_test.go rename to src/internal/m365/graph/uploadsession_test.go diff --git a/src/internal/connector/graph_connector_disconnected_test.go b/src/internal/m365/graph_connector_disconnected_test.go similarity index 88% rename from src/internal/connector/graph_connector_disconnected_test.go rename to src/internal/m365/graph_connector_disconnected_test.go index 845e00693..c2dee9d58 100644 --- a/src/internal/connector/graph_connector_disconnected_test.go +++ b/src/internal/m365/graph_connector_disconnected_test.go @@ -1,4 +1,4 @@ -package connector +package m365 import ( "sync" @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/support" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/selectors" selTD "github.com/alcionai/corso/src/pkg/selectors/testdata" @@ -17,12 +17,12 @@ import ( // --------------------------------------------------------------- // Disconnected Test Section // --------------------------------------------------------------- -type DisconnectedGraphConnectorSuite struct { +type DisconnectedSuite struct { tester.Suite } -func TestDisconnectedGraphSuite(t *testing.T) { - s := &DisconnectedGraphConnectorSuite{ +func TestSuite(t *testing.T) { + s := &DisconnectedSuite{ Suite: tester.NewUnitSuite(t), } @@ -31,7 +31,7 @@ func TestDisconnectedGraphSuite(t *testing.T) { func statusTestTask( t *testing.T, - gc *GraphConnector, + ctrl *Controller, objects, success, folder int, ) { ctx, flush := tester.NewContext(t) @@ -46,24 +46,24 @@ func statusTestTask( Bytes: 0, }, "statusTestTask") - gc.UpdateStatus(status) + ctrl.UpdateStatus(status) } -func (suite *DisconnectedGraphConnectorSuite) TestGraphConnector_Status() { +func (suite *DisconnectedSuite) TestController_Status() { t := suite.T() - gc := GraphConnector{wg: &sync.WaitGroup{}} + ctrl := Controller{wg: &sync.WaitGroup{}} // Two tasks - gc.incrementAwaitingMessages() - gc.incrementAwaitingMessages() + ctrl.incrementAwaitingMessages() + ctrl.incrementAwaitingMessages() // Each helper task processes 4 objects, 1 success, 3 errors, 1 folders - go statusTestTask(t, &gc, 4, 1, 1) - go statusTestTask(t, &gc, 4, 1, 1) + go statusTestTask(t, &ctrl, 4, 1, 1) + go statusTestTask(t, &ctrl, 4, 1, 1) - stats := gc.Wait() + stats := ctrl.Wait() - assert.NotEmpty(t, gc.PrintableStatus()) + assert.NotEmpty(t, ctrl.PrintableStatus()) // Expect 8 objects assert.Equal(t, 8, stats.Objects) // Expect 2 success @@ -72,7 +72,7 @@ func (suite *DisconnectedGraphConnectorSuite) TestGraphConnector_Status() { assert.Equal(t, 2, stats.Folders) } -func (suite *DisconnectedGraphConnectorSuite) TestVerifyBackupInputs_allServices() { +func (suite *DisconnectedSuite) TestVerifyBackupInputs_allServices() { sites := []string{"abc.site.foo", "bar.site.baz"} tests := []struct { diff --git a/src/internal/connector/graph_connector_helper_test.go b/src/internal/m365/graph_connector_helper_test.go similarity index 98% rename from src/internal/connector/graph_connector_helper_test.go rename to src/internal/m365/graph_connector_helper_test.go index 5a80c1cda..1fc1573c7 100644 --- a/src/internal/connector/graph_connector_helper_test.go +++ b/src/internal/m365/graph_connector_helper_test.go @@ -1,4 +1,4 @@ -package connector +package m365 import ( "context" @@ -16,9 +16,10 @@ import ( "golang.org/x/exp/slices" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/onedrive" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/onedrive" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" @@ -102,14 +103,14 @@ type restoreBackupInfo struct { name string service path.ServiceType collections []ColInfo - resource Resource + resourceCat resource.Category } type restoreBackupInfoMultiVersion struct { service path.ServiceType collectionsLatest []ColInfo collectionsPrevious []ColInfo - resource Resource + resource resource.Category backupVersion int } @@ -940,7 +941,7 @@ func checkCollections( ) // Need to iterate through all items even if we don't expect to find a match - // because otherwise we'll deadlock waiting for GC status. Unexpected or + // because otherwise we'll deadlock waiting for the status. Unexpected or // missing collection paths will be reported by checkHasCollections. for item := range returned.Items(ctx, fault.New(true)) { // Skip metadata collections as they aren't directly related to items to @@ -984,7 +985,7 @@ func checkCollections( checkHasCollections(t, expected, collectionsWithItems) // Return how many metadata files were skipped so we can account for it in the - // check on GraphConnector status. + // check on Controller status. return skipped } @@ -1151,10 +1152,10 @@ func getSelectorWith( } } -func loadConnector(ctx context.Context, t *testing.T, r Resource) *GraphConnector { +func loadController(ctx context.Context, t *testing.T, r resource.Category) *Controller { a := tester.NewM365Account(t) - connector, err := NewGraphConnector(ctx, a, r) + connector, err := NewController(ctx, a, r) require.NoError(t, err, clues.ToCore(err)) return connector diff --git a/src/internal/connector/graph_connector_onedrive_test.go b/src/internal/m365/graph_connector_onedrive_test.go similarity index 87% rename from src/internal/connector/graph_connector_onedrive_test.go rename to src/internal/m365/graph_connector_onedrive_test.go index 0b20245ee..1a45992d3 100644 --- a/src/internal/connector/graph_connector_onedrive_test.go +++ b/src/internal/m365/graph_connector_onedrive_test.go @@ -1,4 +1,4 @@ -package connector +package m365 import ( "context" @@ -13,9 +13,10 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/graph" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/control" @@ -86,7 +87,7 @@ type suiteInfo interface { // also be a site. ResourceOwner() string Service() path.ServiceType - Resource() Resource + Resource() resource.Category } type oneDriveSuite interface { @@ -96,9 +97,9 @@ type oneDriveSuite interface { type suiteInfoImpl struct { ac api.Client - connector *GraphConnector + controller *Controller resourceOwner string - resourceType Resource + resourceCat resource.Category secondaryUser string secondaryUserID string service path.ServiceType @@ -114,18 +115,18 @@ func NewSuiteInfoImpl( resourceOwner string, service path.ServiceType, ) suiteInfoImpl { - resource := Users + rc := resource.Users if service == path.SharePointService { - resource = Sites + rc = resource.Sites } - gc := loadConnector(ctx, t, resource) + ctrl := loadController(ctx, t, rc) return suiteInfoImpl{ - ac: gc.AC, - connector: gc, + ac: ctrl.AC, + controller: ctrl, resourceOwner: resourceOwner, - resourceType: resource, + resourceCat: rc, secondaryUser: tester.SecondaryM365UserID(t), service: service, tertiaryUser: tester.TertiaryM365UserID(t), @@ -138,7 +139,7 @@ func (si suiteInfoImpl) APIClient() api.Client { } func (si suiteInfoImpl) Tenant() string { - return si.connector.tenant + return si.controller.tenant } func (si suiteInfoImpl) PrimaryUser() (string, string) { @@ -161,8 +162,8 @@ func (si suiteInfoImpl) Service() path.ServiceType { return si.service } -func (si suiteInfoImpl) Resource() Resource { - return si.resourceType +func (si suiteInfoImpl) Resource() resource.Category { + return si.resourceCat } // --------------------------------------------------------------------------- @@ -172,20 +173,20 @@ func (si suiteInfoImpl) Resource() Resource { // only test simple things here and leave the more extensive testing to // OneDrive. -type GraphConnectorSharePointIntegrationSuite struct { +type SharePointIntegrationSuite struct { tester.Suite suiteInfo } -func TestGraphConnectorSharePointIntegrationSuite(t *testing.T) { - suite.Run(t, &GraphConnectorSharePointIntegrationSuite{ +func TestSharePointIntegrationSuite(t *testing.T) { + suite.Run(t, &SharePointIntegrationSuite{ Suite: tester.NewIntegrationSuite( t, [][]string{tester.M365AcctCredEnvs}), }) } -func (suite *GraphConnectorSharePointIntegrationSuite) SetupSuite() { +func (suite *SharePointIntegrationSuite) SetupSuite() { t := suite.T() ctx, flush := tester.NewContext(t) @@ -194,38 +195,38 @@ func (suite *GraphConnectorSharePointIntegrationSuite) SetupSuite() { si := NewSuiteInfoImpl(suite.T(), ctx, tester.M365SiteID(suite.T()), path.SharePointService) // users needed for permissions - user, err := si.connector.AC.Users().GetByID(ctx, si.user) + user, err := si.controller.AC.Users().GetByID(ctx, si.user) require.NoError(t, err, "fetching user", si.user, clues.ToCore(err)) si.userID = ptr.Val(user.GetId()) - secondaryUser, err := si.connector.AC.Users().GetByID(ctx, si.secondaryUser) + secondaryUser, err := si.controller.AC.Users().GetByID(ctx, si.secondaryUser) require.NoError(t, err, "fetching user", si.secondaryUser, clues.ToCore(err)) si.secondaryUserID = ptr.Val(secondaryUser.GetId()) - tertiaryUser, err := si.connector.AC.Users().GetByID(ctx, si.tertiaryUser) + tertiaryUser, err := si.controller.AC.Users().GetByID(ctx, si.tertiaryUser) require.NoError(t, err, "fetching user", si.tertiaryUser, clues.ToCore(err)) si.tertiaryUserID = ptr.Val(tertiaryUser.GetId()) suite.suiteInfo = si } -func (suite *GraphConnectorSharePointIntegrationSuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() { +func (suite *SharePointIntegrationSuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() { testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, version.Backup) } -func (suite *GraphConnectorSharePointIntegrationSuite) TestPermissionsRestoreAndBackup() { +func (suite *SharePointIntegrationSuite) TestPermissionsRestoreAndBackup() { testPermissionsRestoreAndBackup(suite, version.Backup) } -func (suite *GraphConnectorSharePointIntegrationSuite) TestPermissionsBackupAndNoRestore() { +func (suite *SharePointIntegrationSuite) TestPermissionsBackupAndNoRestore() { testPermissionsBackupAndNoRestore(suite, version.Backup) } -func (suite *GraphConnectorSharePointIntegrationSuite) TestPermissionsInheritanceRestoreAndBackup() { +func (suite *SharePointIntegrationSuite) TestPermissionsInheritanceRestoreAndBackup() { testPermissionsInheritanceRestoreAndBackup(suite, version.Backup) } -func (suite *GraphConnectorSharePointIntegrationSuite) TestRestoreFolderNamedFolderRegression() { +func (suite *SharePointIntegrationSuite) TestRestoreFolderNamedFolderRegression() { // No reason why it couldn't work with previous versions, but this is when it got introduced. testRestoreFolderNamedFolderRegression(suite, version.All8MigrateUserPNToID) } @@ -233,20 +234,20 @@ func (suite *GraphConnectorSharePointIntegrationSuite) TestRestoreFolderNamedFol // --------------------------------------------------------------------------- // OneDrive most recent backup version // --------------------------------------------------------------------------- -type GraphConnectorOneDriveIntegrationSuite struct { +type OneDriveIntegrationSuite struct { tester.Suite suiteInfo } -func TestGraphConnectorOneDriveIntegrationSuite(t *testing.T) { - suite.Run(t, &GraphConnectorOneDriveIntegrationSuite{ +func TestOneDriveIntegrationSuite(t *testing.T) { + suite.Run(t, &OneDriveIntegrationSuite{ Suite: tester.NewIntegrationSuite( t, [][]string{tester.M365AcctCredEnvs}), }) } -func (suite *GraphConnectorOneDriveIntegrationSuite) SetupSuite() { +func (suite *OneDriveIntegrationSuite) SetupSuite() { t := suite.T() ctx, flush := tester.NewContext(t) @@ -254,38 +255,38 @@ func (suite *GraphConnectorOneDriveIntegrationSuite) SetupSuite() { si := NewSuiteInfoImpl(t, ctx, tester.M365UserID(t), path.OneDriveService) - user, err := si.connector.AC.Users().GetByID(ctx, si.user) + user, err := si.controller.AC.Users().GetByID(ctx, si.user) require.NoError(t, err, "fetching user", si.user, clues.ToCore(err)) si.userID = ptr.Val(user.GetId()) - secondaryUser, err := si.connector.AC.Users().GetByID(ctx, si.secondaryUser) + secondaryUser, err := si.controller.AC.Users().GetByID(ctx, si.secondaryUser) require.NoError(t, err, "fetching user", si.secondaryUser, clues.ToCore(err)) si.secondaryUserID = ptr.Val(secondaryUser.GetId()) - tertiaryUser, err := si.connector.AC.Users().GetByID(ctx, si.tertiaryUser) + tertiaryUser, err := si.controller.AC.Users().GetByID(ctx, si.tertiaryUser) require.NoError(t, err, "fetching user", si.tertiaryUser, clues.ToCore(err)) si.tertiaryUserID = ptr.Val(tertiaryUser.GetId()) suite.suiteInfo = si } -func (suite *GraphConnectorOneDriveIntegrationSuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() { +func (suite *OneDriveIntegrationSuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() { testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, version.Backup) } -func (suite *GraphConnectorOneDriveIntegrationSuite) TestPermissionsRestoreAndBackup() { +func (suite *OneDriveIntegrationSuite) TestPermissionsRestoreAndBackup() { testPermissionsRestoreAndBackup(suite, version.Backup) } -func (suite *GraphConnectorOneDriveIntegrationSuite) TestPermissionsBackupAndNoRestore() { +func (suite *OneDriveIntegrationSuite) TestPermissionsBackupAndNoRestore() { testPermissionsBackupAndNoRestore(suite, version.Backup) } -func (suite *GraphConnectorOneDriveIntegrationSuite) TestPermissionsInheritanceRestoreAndBackup() { +func (suite *OneDriveIntegrationSuite) TestPermissionsInheritanceRestoreAndBackup() { testPermissionsInheritanceRestoreAndBackup(suite, version.Backup) } -func (suite *GraphConnectorOneDriveIntegrationSuite) TestRestoreFolderNamedFolderRegression() { +func (suite *OneDriveIntegrationSuite) TestRestoreFolderNamedFolderRegression() { // No reason why it couldn't work with previous versions, but this is when it got introduced. testRestoreFolderNamedFolderRegression(suite, version.All8MigrateUserPNToID) } @@ -293,20 +294,20 @@ func (suite *GraphConnectorOneDriveIntegrationSuite) TestRestoreFolderNamedFolde // --------------------------------------------------------------------------- // OneDrive regression // --------------------------------------------------------------------------- -type GraphConnectorOneDriveNightlySuite struct { +type OneDriveNightlySuite struct { tester.Suite suiteInfo } -func TestGraphConnectorOneDriveNightlySuite(t *testing.T) { - suite.Run(t, &GraphConnectorOneDriveNightlySuite{ +func TestOneDriveNightlySuite(t *testing.T) { + suite.Run(t, &OneDriveNightlySuite{ Suite: tester.NewNightlySuite( t, [][]string{tester.M365AcctCredEnvs}), }) } -func (suite *GraphConnectorOneDriveNightlySuite) SetupSuite() { +func (suite *OneDriveNightlySuite) SetupSuite() { t := suite.T() ctx, flush := tester.NewContext(t) @@ -314,39 +315,39 @@ func (suite *GraphConnectorOneDriveNightlySuite) SetupSuite() { si := NewSuiteInfoImpl(t, ctx, tester.M365UserID(t), path.OneDriveService) - user, err := si.connector.AC.Users().GetByID(ctx, si.user) + user, err := si.controller.AC.Users().GetByID(ctx, si.user) require.NoError(t, err, "fetching user", si.user, clues.ToCore(err)) si.userID = ptr.Val(user.GetId()) - secondaryUser, err := si.connector.AC.Users().GetByID(ctx, si.secondaryUser) + secondaryUser, err := si.controller.AC.Users().GetByID(ctx, si.secondaryUser) require.NoError(t, err, "fetching user", si.secondaryUser, clues.ToCore(err)) si.secondaryUserID = ptr.Val(secondaryUser.GetId()) - tertiaryUser, err := si.connector.AC.Users().GetByID(ctx, si.tertiaryUser) + tertiaryUser, err := si.controller.AC.Users().GetByID(ctx, si.tertiaryUser) require.NoError(t, err, "fetching user", si.tertiaryUser, clues.ToCore(err)) si.tertiaryUserID = ptr.Val(tertiaryUser.GetId()) suite.suiteInfo = si } -func (suite *GraphConnectorOneDriveNightlySuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() { +func (suite *OneDriveNightlySuite) TestRestoreAndBackup_MultipleFilesAndFolders_NoPermissions() { testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(suite, 0) } -func (suite *GraphConnectorOneDriveNightlySuite) TestPermissionsRestoreAndBackup() { +func (suite *OneDriveNightlySuite) TestPermissionsRestoreAndBackup() { testPermissionsRestoreAndBackup(suite, version.OneDrive1DataAndMetaFiles) } -func (suite *GraphConnectorOneDriveNightlySuite) TestPermissionsBackupAndNoRestore() { +func (suite *OneDriveNightlySuite) TestPermissionsBackupAndNoRestore() { testPermissionsBackupAndNoRestore(suite, version.OneDrive1DataAndMetaFiles) } -func (suite *GraphConnectorOneDriveNightlySuite) TestPermissionsInheritanceRestoreAndBackup() { +func (suite *OneDriveNightlySuite) TestPermissionsInheritanceRestoreAndBackup() { // No reason why it couldn't work with previous versions, but this is when it got introduced. testPermissionsInheritanceRestoreAndBackup(suite, version.OneDrive4DirIncludesPermissions) } -func (suite *GraphConnectorOneDriveNightlySuite) TestRestoreFolderNamedFolderRegression() { +func (suite *OneDriveNightlySuite) TestRestoreFolderNamedFolderRegression() { // No reason why it couldn't work with previous versions, but this is when it got introduced. testRestoreFolderNamedFolderRegression(suite, version.All8MigrateUserPNToID) } diff --git a/src/internal/connector/graph_connector_onedrive_test_helper.go b/src/internal/m365/graph_connector_onedrive_test_helper.go similarity index 98% rename from src/internal/connector/graph_connector_onedrive_test_helper.go rename to src/internal/m365/graph_connector_onedrive_test_helper.go index b70543019..77acc1b7d 100644 --- a/src/internal/connector/graph_connector_onedrive_test_helper.go +++ b/src/internal/m365/graph_connector_onedrive_test_helper.go @@ -1,4 +1,4 @@ -package connector +package m365 import ( "encoding/json" @@ -8,9 +8,9 @@ import ( "github.com/google/uuid" "golang.org/x/exp/maps" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" "github.com/alcionai/corso/src/internal/data" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/internal/connector/graph_connector_test_helper.go b/src/internal/m365/graph_connector_test_helper.go similarity index 95% rename from src/internal/connector/graph_connector_test_helper.go rename to src/internal/m365/graph_connector_test_helper.go index 8ea552190..f95d1781f 100644 --- a/src/internal/connector/graph_connector_test_helper.go +++ b/src/internal/m365/graph_connector_test_helper.go @@ -1,13 +1,14 @@ -package connector +package m365 import ( "bytes" "context" "io" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" "github.com/alcionai/corso/src/internal/data" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/path" ) @@ -39,7 +40,7 @@ type ItemInfo struct { type ConfigInfo struct { Opts control.Options - Resource Resource + Resource resource.Category Service path.ServiceType Tenant string ResourceOwners []string diff --git a/src/internal/connector/mock/connector.go b/src/internal/m365/mock/connector.go similarity index 73% rename from src/internal/connector/mock/connector.go rename to src/internal/m365/mock/connector.go index 2e2faec77..870e0b549 100644 --- a/src/internal/connector/mock/connector.go +++ b/src/internal/m365/mock/connector.go @@ -14,9 +14,9 @@ import ( "github.com/alcionai/corso/src/pkg/selectors" ) -var _ inject.BackupProducer = &GraphConnector{} +var _ inject.BackupProducer = &Controller{} -type GraphConnector struct { +type Controller struct { Collections []data.BackupCollection Exclude *prefixmatcher.StringSetMatcher @@ -27,7 +27,7 @@ type GraphConnector struct { Stats data.CollectionStats } -func (gc GraphConnector) ProduceBackupCollections( +func (ctrl Controller) ProduceBackupCollections( _ context.Context, _ idname.Provider, _ selectors.Selector, @@ -41,22 +41,22 @@ func (gc GraphConnector) ProduceBackupCollections( bool, error, ) { - return gc.Collections, gc.Exclude, gc.Err == nil, gc.Err + return ctrl.Collections, ctrl.Exclude, ctrl.Err == nil, ctrl.Err } -func (gc GraphConnector) IsBackupRunnable( +func (ctrl Controller) IsBackupRunnable( _ context.Context, _ path.ServiceType, _ string, ) (bool, error) { - return true, gc.Err + return true, ctrl.Err } -func (gc GraphConnector) Wait() *data.CollectionStats { - return &gc.Stats +func (ctrl Controller) Wait() *data.CollectionStats { + return &ctrl.Stats } -func (gc GraphConnector) ConsumeRestoreCollections( +func (ctrl Controller) ConsumeRestoreCollections( _ context.Context, _ int, _ selectors.Selector, @@ -65,5 +65,5 @@ func (gc GraphConnector) ConsumeRestoreCollections( _ []data.RestoreCollection, _ *fault.Bus, ) (*details.Details, error) { - return gc.Deets, gc.Err + return ctrl.Deets, ctrl.Err } diff --git a/src/internal/connector/mock/id_name_getter.go b/src/internal/m365/mock/id_name_getter.go similarity index 100% rename from src/internal/connector/mock/id_name_getter.go rename to src/internal/m365/mock/id_name_getter.go diff --git a/src/internal/connector/onedrive/data_collections.go b/src/internal/m365/onedrive/backup.go similarity index 94% rename from src/internal/connector/onedrive/data_collections.go rename to src/internal/m365/onedrive/backup.go index b4823428d..06aab38ae 100644 --- a/src/internal/connector/onedrive/data_collections.go +++ b/src/internal/m365/onedrive/backup.go @@ -7,9 +7,9 @@ import ( "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/prefixmatcher" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" @@ -31,9 +31,9 @@ func (fm odFolderMatcher) Matches(dir string) bool { return fm.scope.Matches(selectors.OneDriveFolder, dir) } -// OneDriveDataCollections returns a set of DataCollection which represents the OneDrive data +// ProduceBackupCollections returns a set of DataCollection which represents the OneDrive data // for the specified user -func DataCollections( +func ProduceBackupCollections( ctx context.Context, ac api.Client, selector selectors.Selector, diff --git a/src/internal/connector/onedrive/data_collections_test.go b/src/internal/m365/onedrive/backup_test.go similarity index 91% rename from src/internal/connector/onedrive/data_collections_test.go rename to src/internal/m365/onedrive/backup_test.go index 62af1fd6b..f5a4261ad 100644 --- a/src/internal/connector/onedrive/data_collections_test.go +++ b/src/internal/m365/onedrive/backup_test.go @@ -16,15 +16,15 @@ import ( "github.com/alcionai/corso/src/pkg/selectors" ) -type DataCollectionsUnitSuite struct { +type BackupUnitSuite struct { tester.Suite } -func TestDataCollectionsUnitSuite(t *testing.T) { - suite.Run(t, &DataCollectionsUnitSuite{Suite: tester.NewUnitSuite(t)}) +func TestBackupUnitSuite(t *testing.T) { + suite.Run(t, &BackupUnitSuite{Suite: tester.NewUnitSuite(t)}) } -func (suite *DataCollectionsUnitSuite) TestMigrationCollections() { +func (suite *BackupUnitSuite) TestMigrationCollections() { u := selectors.Selector{} u = u.SetDiscreteOwnerIDName("i", "n") diff --git a/src/internal/connector/onedrive/collection.go b/src/internal/m365/onedrive/collection.go similarity index 98% rename from src/internal/connector/onedrive/collection.go rename to src/internal/m365/onedrive/collection.go index b2abbdcc9..3e9fe5157 100644 --- a/src/internal/connector/onedrive/collection.go +++ b/src/internal/m365/onedrive/collection.go @@ -14,10 +14,10 @@ import ( "github.com/spatialcurrent/go-lazy/pkg/lazy" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control" diff --git a/src/internal/connector/onedrive/collection_test.go b/src/internal/m365/onedrive/collection_test.go similarity index 96% rename from src/internal/connector/onedrive/collection_test.go rename to src/internal/m365/onedrive/collection_test.go index 31d46b7bb..2cfb65cae 100644 --- a/src/internal/connector/onedrive/collection_test.go +++ b/src/internal/m365/onedrive/collection_test.go @@ -17,13 +17,13 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" - metaTD "github.com/alcionai/corso/src/internal/connector/onedrive/metadata/testdata" - "github.com/alcionai/corso/src/internal/connector/onedrive/mock" - odTD "github.com/alcionai/corso/src/internal/connector/onedrive/testdata" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + metaTD "github.com/alcionai/corso/src/internal/m365/onedrive/metadata/testdata" + "github.com/alcionai/corso/src/internal/m365/onedrive/mock" + odTD "github.com/alcionai/corso/src/internal/m365/onedrive/testdata" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control" @@ -46,9 +46,9 @@ func TestCollectionUnitTestSuite(t *testing.T) { // Returns a status update function that signals the specified WaitGroup when it is done func (suite *CollectionUnitTestSuite) testStatusUpdater( wg *sync.WaitGroup, - statusToUpdate *support.ConnectorOperationStatus, + statusToUpdate *support.ControllerOperationStatus, ) support.StatusUpdater { - return func(s *support.ConnectorOperationStatus) { + return func(s *support.ControllerOperationStatus) { suite.T().Logf("Update status %v, count %d, success %d", s, s.Metrics.Objects, s.Metrics.Successes) *statusToUpdate = *s @@ -170,7 +170,7 @@ func (suite *CollectionUnitTestSuite) TestCollection() { var ( wg = sync.WaitGroup{} - collStatus = support.ConnectorOperationStatus{} + collStatus = support.ControllerOperationStatus{} readItems = []data.Stream{} ) @@ -276,7 +276,7 @@ func (suite *CollectionUnitTestSuite) TestCollectionReadError() { var ( t = suite.T() stubItemID = "fakeItemID" - collStatus = support.ConnectorOperationStatus{} + collStatus = support.ControllerOperationStatus{} wg = sync.WaitGroup{} name = "name" size int64 = 42 @@ -343,7 +343,7 @@ func (suite *CollectionUnitTestSuite) TestCollectionReadUnauthorizedErrorRetry() var ( t = suite.T() stubItemID = "fakeItemID" - collStatus = support.ConnectorOperationStatus{} + collStatus = support.ControllerOperationStatus{} wg = sync.WaitGroup{} name = "name" size int64 = 42 @@ -412,7 +412,7 @@ func (suite *CollectionUnitTestSuite) TestCollectionPermissionBackupLatestModTim stubItemID = "fakeItemID" stubItemName = "Fake Item" stubItemSize = int64(10) - collStatus = support.ConnectorOperationStatus{} + collStatus = support.ControllerOperationStatus{} wg = sync.WaitGroup{} ) diff --git a/src/internal/connector/onedrive/collections.go b/src/internal/m365/onedrive/collections.go similarity index 98% rename from src/internal/connector/onedrive/collections.go rename to src/internal/m365/onedrive/collections.go index c367477d8..d05b06820 100644 --- a/src/internal/connector/onedrive/collections.go +++ b/src/internal/m365/onedrive/collections.go @@ -13,11 +13,11 @@ import ( "github.com/alcionai/corso/src/internal/common/prefixmatcher" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" diff --git a/src/internal/connector/onedrive/collections_test.go b/src/internal/m365/onedrive/collections_test.go similarity index 99% rename from src/internal/connector/onedrive/collections_test.go rename to src/internal/m365/onedrive/collections_test.go index f5bed49a4..2888bc149 100644 --- a/src/internal/connector/onedrive/collections_test.go +++ b/src/internal/m365/onedrive/collections_test.go @@ -15,12 +15,12 @@ import ( "github.com/alcionai/corso/src/internal/common/prefixmatcher" pmMock "github.com/alcionai/corso/src/internal/common/prefixmatcher/mock" - "github.com/alcionai/corso/src/internal/connector/graph" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" - "github.com/alcionai/corso/src/internal/connector/onedrive/mock" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/onedrive/mock" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" @@ -1135,7 +1135,7 @@ func (suite *OneDriveCollectionsUnitSuite) TestDeserializeMetadata() { path.OneDriveService, path.FilesCategory, c(), - func(*support.ConnectorOperationStatus) {}) + func(*support.ControllerOperationStatus) {}) require.NoError(t, err, clues.ToCore(err)) cols = append(cols, data.NoFetchRestoreCollection{Collection: mc}) @@ -2346,7 +2346,7 @@ func (suite *OneDriveCollectionsUnitSuite) TestGet() { tenant, user, testFolderMatcher{anyFolder}, - func(*support.ConnectorOperationStatus) {}, + func(*support.ControllerOperationStatus) {}, control.Options{ToggleFeatures: control.Toggles{}}) prevDelta := "prev-delta" @@ -2366,7 +2366,7 @@ func (suite *OneDriveCollectionsUnitSuite) TestGet() { graph.PreviousPathFileName, test.prevFolderPaths), }, - func(*support.ConnectorOperationStatus) {}, + func(*support.ControllerOperationStatus) {}, ) assert.NoError(t, err, "creating metadata collection", clues.ToCore(err)) diff --git a/src/internal/connector/onedrive/consts/consts.go b/src/internal/m365/onedrive/consts/consts.go similarity index 100% rename from src/internal/connector/onedrive/consts/consts.go rename to src/internal/m365/onedrive/consts/consts.go diff --git a/src/internal/connector/onedrive/drive.go b/src/internal/m365/onedrive/drive.go similarity index 99% rename from src/internal/connector/onedrive/drive.go rename to src/internal/m365/onedrive/drive.go index 5f7841e28..5a4fadf68 100644 --- a/src/internal/connector/onedrive/drive.go +++ b/src/internal/m365/onedrive/drive.go @@ -9,7 +9,7 @@ import ( "golang.org/x/exp/maps" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/internal/connector/onedrive/drive_test.go b/src/internal/m365/onedrive/drive_test.go similarity index 99% rename from src/internal/connector/onedrive/drive_test.go rename to src/internal/m365/onedrive/drive_test.go index 393da8405..348722b78 100644 --- a/src/internal/connector/onedrive/drive_test.go +++ b/src/internal/m365/onedrive/drive_test.go @@ -16,7 +16,7 @@ import ( "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/prefixmatcher" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/control" diff --git a/src/internal/connector/onedrive/folder_cache.go b/src/internal/m365/onedrive/folder_cache.go similarity index 100% rename from src/internal/connector/onedrive/folder_cache.go rename to src/internal/m365/onedrive/folder_cache.go diff --git a/src/internal/connector/onedrive/handlers.go b/src/internal/m365/onedrive/handlers.go similarity index 100% rename from src/internal/connector/onedrive/handlers.go rename to src/internal/m365/onedrive/handlers.go diff --git a/src/internal/connector/onedrive/item.go b/src/internal/m365/onedrive/item.go similarity index 96% rename from src/internal/connector/onedrive/item.go rename to src/internal/m365/onedrive/item.go index 6c954fd40..c6215e9ae 100644 --- a/src/internal/connector/onedrive/item.go +++ b/src/internal/m365/onedrive/item.go @@ -11,8 +11,8 @@ import ( "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/common/str" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/pkg/services/m365/api" ) diff --git a/src/internal/connector/onedrive/item_handler.go b/src/internal/m365/onedrive/item_handler.go similarity index 98% rename from src/internal/connector/onedrive/item_handler.go rename to src/internal/m365/onedrive/item_handler.go index 001c3a019..a95791237 100644 --- a/src/internal/connector/onedrive/item_handler.go +++ b/src/internal/m365/onedrive/item_handler.go @@ -9,7 +9,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/internal/connector/onedrive/item_handler_test.go b/src/internal/m365/onedrive/item_handler_test.go similarity index 100% rename from src/internal/connector/onedrive/item_handler_test.go rename to src/internal/m365/onedrive/item_handler_test.go diff --git a/src/internal/connector/onedrive/item_test.go b/src/internal/m365/onedrive/item_test.go similarity index 100% rename from src/internal/connector/onedrive/item_test.go rename to src/internal/m365/onedrive/item_test.go diff --git a/src/internal/connector/onedrive/metadata/consts.go b/src/internal/m365/onedrive/metadata/consts.go similarity index 100% rename from src/internal/connector/onedrive/metadata/consts.go rename to src/internal/m365/onedrive/metadata/consts.go diff --git a/src/internal/connector/onedrive/metadata/metadata.go b/src/internal/m365/onedrive/metadata/metadata.go similarity index 100% rename from src/internal/connector/onedrive/metadata/metadata.go rename to src/internal/m365/onedrive/metadata/metadata.go diff --git a/src/internal/connector/onedrive/metadata/permissions.go b/src/internal/m365/onedrive/metadata/permissions.go similarity index 100% rename from src/internal/connector/onedrive/metadata/permissions.go rename to src/internal/m365/onedrive/metadata/permissions.go diff --git a/src/internal/connector/onedrive/metadata/permissions_test.go b/src/internal/m365/onedrive/metadata/permissions_test.go similarity index 100% rename from src/internal/connector/onedrive/metadata/permissions_test.go rename to src/internal/m365/onedrive/metadata/permissions_test.go diff --git a/src/internal/connector/onedrive/metadata/testdata/permissions.go b/src/internal/m365/onedrive/metadata/testdata/permissions.go similarity index 94% rename from src/internal/connector/onedrive/metadata/testdata/permissions.go rename to src/internal/m365/onedrive/metadata/testdata/permissions.go index 130368a37..a3ccc5cb3 100644 --- a/src/internal/connector/onedrive/metadata/testdata/permissions.go +++ b/src/internal/m365/onedrive/metadata/testdata/permissions.go @@ -6,7 +6,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/stretchr/testify/assert" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" ) func AssertMetadataEqual(t *testing.T, expect, got metadata.Metadata) { diff --git a/src/internal/connector/onedrive/mock/handlers.go b/src/internal/m365/onedrive/mock/handlers.go similarity index 98% rename from src/internal/connector/onedrive/mock/handlers.go rename to src/internal/m365/onedrive/mock/handlers.go index 0c33d8158..0b48ffa6c 100644 --- a/src/internal/connector/onedrive/mock/handlers.go +++ b/src/internal/m365/onedrive/mock/handlers.go @@ -7,7 +7,7 @@ import ( "github.com/alcionai/clues" "github.com/microsoftgraph/msgraph-sdk-go/models" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/internal/connector/onedrive/mock/item.go b/src/internal/m365/onedrive/mock/item.go similarity index 100% rename from src/internal/connector/onedrive/mock/item.go rename to src/internal/m365/onedrive/mock/item.go diff --git a/src/internal/connector/onedrive/permission.go b/src/internal/m365/onedrive/permission.go similarity index 98% rename from src/internal/connector/onedrive/permission.go rename to src/internal/m365/onedrive/permission.go index 683ca90e7..642f8d751 100644 --- a/src/internal/connector/onedrive/permission.go +++ b/src/internal/m365/onedrive/permission.go @@ -8,8 +8,8 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/internal/connector/onedrive/permission_test.go b/src/internal/m365/onedrive/permission_test.go similarity index 96% rename from src/internal/connector/onedrive/permission_test.go rename to src/internal/m365/onedrive/permission_test.go index 672db97f8..c345d693e 100644 --- a/src/internal/connector/onedrive/permission_test.go +++ b/src/internal/m365/onedrive/permission_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/internal/connector/onedrive/restore.go b/src/internal/m365/onedrive/restore.go similarity index 98% rename from src/internal/connector/onedrive/restore.go rename to src/internal/m365/onedrive/restore.go index 67c5f53bf..cdd6a9844 100644 --- a/src/internal/connector/onedrive/restore.go +++ b/src/internal/m365/onedrive/restore.go @@ -15,11 +15,11 @@ import ( "github.com/pkg/errors" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/backup/details" @@ -69,7 +69,7 @@ func RestoreCollections( dcs []data.RestoreCollection, deets *details.Builder, errs *fault.Bus, -) (*support.ConnectorOperationStatus, error) { +) (*support.ControllerOperationStatus, error) { var ( restoreMetrics support.CollectionMetrics caches = NewRestoreCaches() @@ -102,7 +102,7 @@ func RestoreCollections( "full_path", dc.FullPath()) ) - metrics, err = RestoreCollection( + metrics, err = ProduceRestoreCollection( ictx, rh, backupVersion, @@ -133,12 +133,12 @@ func RestoreCollections( return status, el.Failure() } -// RestoreCollection handles restoration of an individual collection. +// ProduceRestoreCollection handles restoration of an individual collection. // returns: // - the collection's item and byte count metrics // - the updated metadata map that include metadata for folders in this collection // - error, if any besides recoverable -func RestoreCollection( +func ProduceRestoreCollection( ctx context.Context, rh RestoreHandler, backupVersion int, diff --git a/src/internal/connector/onedrive/restore_test.go b/src/internal/m365/onedrive/restore_test.go similarity index 100% rename from src/internal/connector/onedrive/restore_test.go rename to src/internal/m365/onedrive/restore_test.go diff --git a/src/internal/connector/onedrive/service_test.go b/src/internal/m365/onedrive/service_test.go similarity index 84% rename from src/internal/connector/onedrive/service_test.go rename to src/internal/m365/onedrive/service_test.go index 455520e75..046b72085 100644 --- a/src/internal/connector/onedrive/service_test.go +++ b/src/internal/m365/onedrive/service_test.go @@ -6,7 +6,7 @@ import ( "github.com/alcionai/clues" "github.com/stretchr/testify/require" - "github.com/alcionai/corso/src/internal/connector/support" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/services/m365/api" @@ -15,7 +15,7 @@ import ( // TODO(ashmrtn): Merge with similar structs in graph and exchange packages. type oneDriveService struct { credentials account.M365Config - status support.ConnectorOperationStatus + status support.ControllerOperationStatus ac api.Client } @@ -33,7 +33,7 @@ func NewOneDriveService(credentials account.M365Config) (*oneDriveService, error return &service, nil } -func (ods *oneDriveService) updateStatus(status *support.ConnectorOperationStatus) { +func (ods *oneDriveService) updateStatus(status *support.ControllerOperationStatus) { if status == nil { return } diff --git a/src/internal/connector/onedrive/testdata/item.go b/src/internal/m365/onedrive/testdata/item.go similarity index 100% rename from src/internal/connector/onedrive/testdata/item.go rename to src/internal/m365/onedrive/testdata/item.go diff --git a/src/internal/connector/onedrive/url_cache.go b/src/internal/m365/onedrive/url_cache.go similarity index 100% rename from src/internal/connector/onedrive/url_cache.go rename to src/internal/m365/onedrive/url_cache.go diff --git a/src/internal/connector/onedrive/url_cache_test.go b/src/internal/m365/onedrive/url_cache_test.go similarity index 98% rename from src/internal/connector/onedrive/url_cache_test.go rename to src/internal/m365/onedrive/url_cache_test.go index 97a7b87b1..c3674c8c7 100644 --- a/src/internal/connector/onedrive/url_cache_test.go +++ b/src/internal/m365/onedrive/url_cache_test.go @@ -13,7 +13,7 @@ import ( "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/internal/m365/resource/resource.go b/src/internal/m365/resource/resource.go new file mode 100644 index 000000000..f91a853a6 --- /dev/null +++ b/src/internal/m365/resource/resource.go @@ -0,0 +1,9 @@ +package resource + +type Category string + +const ( + UnknownResource Category = "" + Users Category = "users" + Sites Category = "sites" +) diff --git a/src/internal/m365/restore.go b/src/internal/m365/restore.go new file mode 100644 index 000000000..f04d3296c --- /dev/null +++ b/src/internal/m365/restore.go @@ -0,0 +1,75 @@ +package m365 + +import ( + "context" + + "github.com/alcionai/clues" + + "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/diagnostics" + "github.com/alcionai/corso/src/internal/m365/exchange" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive" + "github.com/alcionai/corso/src/internal/m365/sharepoint" + "github.com/alcionai/corso/src/internal/m365/support" + "github.com/alcionai/corso/src/pkg/backup/details" + "github.com/alcionai/corso/src/pkg/control" + "github.com/alcionai/corso/src/pkg/fault" + "github.com/alcionai/corso/src/pkg/selectors" +) + +// ConsumeRestoreCollections restores data from the specified collections +// into M365 using the GraphAPI. +// SideEffect: status is updated at the completion of operation +func (ctrl *Controller) ConsumeRestoreCollections( + ctx context.Context, + backupVersion int, + sels selectors.Selector, + restoreCfg control.RestoreConfig, + opts control.Options, + dcs []data.RestoreCollection, + errs *fault.Bus, +) (*details.Details, error) { + ctx, end := diagnostics.Span(ctx, "m365:restore") + defer end() + + ctx = graph.BindRateLimiterConfig(ctx, graph.LimiterCfg{Service: sels.PathService()}) + + var ( + status *support.ControllerOperationStatus + deets = &details.Builder{} + err error + ) + + switch sels.Service { + case selectors.ServiceExchange: + status, err = exchange.ConsumeRestoreCollections(ctx, ctrl.AC, restoreCfg, dcs, deets, errs) + case selectors.ServiceOneDrive: + status, err = onedrive.RestoreCollections( + ctx, + onedrive.NewRestoreHandler(ctrl.AC), + backupVersion, + restoreCfg, + opts, + dcs, + deets, + errs) + case selectors.ServiceSharePoint: + status, err = sharepoint.ConsumeRestoreCollections( + ctx, + backupVersion, + ctrl.AC, + restoreCfg, + opts, + dcs, + deets, + errs) + default: + err = clues.Wrap(clues.New(sels.Service.String()), "service not supported") + } + + ctrl.incrementAwaitingMessages() + ctrl.UpdateStatus(status) + + return deets.Details(), err +} diff --git a/src/internal/connector/sharepoint/api/beta_service.go b/src/internal/m365/sharepoint/api/beta_service.go similarity index 94% rename from src/internal/connector/sharepoint/api/beta_service.go rename to src/internal/m365/sharepoint/api/beta_service.go index 13bafbaa4..b184002a1 100644 --- a/src/internal/connector/sharepoint/api/beta_service.go +++ b/src/internal/m365/sharepoint/api/beta_service.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/kiota-abstractions-go/serialization" msgraphsdkgo "github.com/microsoftgraph/msgraph-sdk-go" - "github.com/alcionai/corso/src/internal/connector/graph/betasdk" + "github.com/alcionai/corso/src/internal/m365/graph/betasdk" ) // Service wraps BetaClient's functionality. diff --git a/src/internal/connector/sharepoint/api/beta_service_test.go b/src/internal/m365/sharepoint/api/beta_service_test.go similarity index 88% rename from src/internal/connector/sharepoint/api/beta_service_test.go rename to src/internal/m365/sharepoint/api/beta_service_test.go index 802719f8e..4f4853274 100644 --- a/src/internal/connector/sharepoint/api/beta_service_test.go +++ b/src/internal/m365/sharepoint/api/beta_service_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" "github.com/alcionai/corso/src/internal/tester" ) diff --git a/src/internal/connector/sharepoint/api/pages.go b/src/internal/m365/sharepoint/api/pages.go similarity index 97% rename from src/internal/connector/sharepoint/api/pages.go rename to src/internal/m365/sharepoint/api/pages.go index f3ee314e5..0434ff0a5 100644 --- a/src/internal/connector/sharepoint/api/pages.go +++ b/src/internal/m365/sharepoint/api/pages.go @@ -9,11 +9,11 @@ import ( "github.com/alcionai/clues" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - betamodels "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" - betasites "github.com/alcionai/corso/src/internal/connector/graph/betasdk/sites" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" + "github.com/alcionai/corso/src/internal/m365/graph" + betamodels "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" + betasites "github.com/alcionai/corso/src/internal/m365/graph/betasdk/sites" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" ) diff --git a/src/internal/connector/sharepoint/api/pages_test.go b/src/internal/m365/sharepoint/api/pages_test.go similarity index 91% rename from src/internal/connector/sharepoint/api/pages_test.go rename to src/internal/m365/sharepoint/api/pages_test.go index ae9635ff8..0f2fa0471 100644 --- a/src/internal/connector/sharepoint/api/pages_test.go +++ b/src/internal/m365/sharepoint/api/pages_test.go @@ -10,10 +10,10 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/sharepoint" - "github.com/alcionai/corso/src/internal/connector/sharepoint/api" - spMock "github.com/alcionai/corso/src/internal/connector/sharepoint/mock" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/sharepoint" + "github.com/alcionai/corso/src/internal/m365/sharepoint/api" + spMock "github.com/alcionai/corso/src/internal/m365/sharepoint/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/fault" diff --git a/src/internal/connector/sharepoint/api/serialization.go b/src/internal/m365/sharepoint/api/serialization.go similarity index 98% rename from src/internal/connector/sharepoint/api/serialization.go rename to src/internal/m365/sharepoint/api/serialization.go index e1382ed94..c377bd998 100644 --- a/src/internal/connector/sharepoint/api/serialization.go +++ b/src/internal/m365/sharepoint/api/serialization.go @@ -9,7 +9,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - betamodels "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + betamodels "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" ) // createFromBytes generates an m365 object form bytes. diff --git a/src/internal/connector/sharepoint/api/serialization_test.go b/src/internal/m365/sharepoint/api/serialization_test.go similarity index 94% rename from src/internal/connector/sharepoint/api/serialization_test.go rename to src/internal/m365/sharepoint/api/serialization_test.go index df6389f8d..099691d16 100644 --- a/src/internal/connector/sharepoint/api/serialization_test.go +++ b/src/internal/m365/sharepoint/api/serialization_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - bmodels "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" - spMock "github.com/alcionai/corso/src/internal/connector/sharepoint/mock" + bmodels "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" + spMock "github.com/alcionai/corso/src/internal/m365/sharepoint/mock" "github.com/alcionai/corso/src/internal/tester" ) diff --git a/src/internal/connector/sharepoint/data_collections.go b/src/internal/m365/sharepoint/backup.go similarity index 94% rename from src/internal/connector/sharepoint/data_collections.go rename to src/internal/m365/sharepoint/backup.go index 2575f12d3..ba5c45c23 100644 --- a/src/internal/connector/sharepoint/data_collections.go +++ b/src/internal/m365/sharepoint/backup.go @@ -7,11 +7,11 @@ import ( "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/prefixmatcher" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/onedrive" - betaAPI "github.com/alcionai/corso/src/internal/connector/sharepoint/api" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive" + betaAPI "github.com/alcionai/corso/src/internal/m365/sharepoint/api" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/control" @@ -23,12 +23,12 @@ import ( ) type statusUpdater interface { - UpdateStatus(status *support.ConnectorOperationStatus) + UpdateStatus(status *support.ControllerOperationStatus) } -// DataCollections returns a set of DataCollection which represents the SharePoint data +// ProduceBackupCollections returns a set of DataCollection which represents the SharePoint data // for the specified user -func DataCollections( +func ProduceBackupCollections( ctx context.Context, ac api.Client, selector selectors.Selector, diff --git a/src/internal/connector/sharepoint/data_collections_test.go b/src/internal/m365/sharepoint/backup_test.go similarity index 93% rename from src/internal/connector/sharepoint/data_collections_test.go rename to src/internal/m365/sharepoint/backup_test.go index 056d5c41d..d36e40377 100644 --- a/src/internal/connector/sharepoint/data_collections_test.go +++ b/src/internal/m365/sharepoint/backup_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/idname/mock" - "github.com/alcionai/corso/src/internal/connector/onedrive" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" @@ -45,15 +45,15 @@ func (fm testFolderMatcher) Matches(p string) bool { // tests // --------------------------------------------------------------------------- -type SharePointLibrariesUnitSuite struct { +type LibrariesBackupUnitSuite struct { tester.Suite } -func TestSharePointLibrariesUnitSuite(t *testing.T) { - suite.Run(t, &SharePointLibrariesUnitSuite{Suite: tester.NewUnitSuite(t)}) +func TestLibrariesBackupUnitSuite(t *testing.T) { + suite.Run(t, &LibrariesBackupUnitSuite{Suite: tester.NewUnitSuite(t)}) } -func (suite *SharePointLibrariesUnitSuite) TestUpdateCollections() { +func (suite *LibrariesBackupUnitSuite) TestUpdateCollections() { anyFolder := (&selectors.SharePointBackup{}).LibraryFolders(selectors.Any())[0] const ( diff --git a/src/internal/connector/sharepoint/collection.go b/src/internal/m365/sharepoint/collection.go similarity index 96% rename from src/internal/connector/sharepoint/collection.go rename to src/internal/m365/sharepoint/collection.go index 16cb016db..12db281a4 100644 --- a/src/internal/connector/sharepoint/collection.go +++ b/src/internal/m365/sharepoint/collection.go @@ -11,10 +11,10 @@ import ( kjson "github.com/microsoft/kiota-serialization-json-go" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - betaAPI "github.com/alcionai/corso/src/internal/connector/sharepoint/api" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/m365/graph" + betaAPI "github.com/alcionai/corso/src/internal/m365/sharepoint/api" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control" @@ -90,7 +90,7 @@ func (sc *Collection) FullPath() path.Path { return sc.fullPath } -// TODO(ashmrtn): Fill in with previous path once GraphConnector compares old +// TODO(ashmrtn): Fill in with previous path once the Controller compares old // and new folder hierarchies. func (sc Collection) PreviousPath() path.Path { return nil diff --git a/src/internal/connector/sharepoint/collection_test.go b/src/internal/m365/sharepoint/collection_test.go similarity index 97% rename from src/internal/connector/sharepoint/collection_test.go rename to src/internal/m365/sharepoint/collection_test.go index 4d66a33c0..5381710c2 100644 --- a/src/internal/connector/sharepoint/collection_test.go +++ b/src/internal/m365/sharepoint/collection_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - betaAPI "github.com/alcionai/corso/src/internal/connector/sharepoint/api" - spMock "github.com/alcionai/corso/src/internal/connector/sharepoint/mock" "github.com/alcionai/corso/src/internal/data" + betaAPI "github.com/alcionai/corso/src/internal/m365/sharepoint/api" + spMock "github.com/alcionai/corso/src/internal/m365/sharepoint/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/control" diff --git a/src/internal/connector/sharepoint/datacategory_string.go b/src/internal/m365/sharepoint/datacategory_string.go similarity index 100% rename from src/internal/connector/sharepoint/datacategory_string.go rename to src/internal/m365/sharepoint/datacategory_string.go diff --git a/src/internal/connector/sharepoint/helper_test.go b/src/internal/m365/sharepoint/helper_test.go similarity index 81% rename from src/internal/connector/sharepoint/helper_test.go rename to src/internal/m365/sharepoint/helper_test.go index 7e6d592b2..006a5648c 100644 --- a/src/internal/connector/sharepoint/helper_test.go +++ b/src/internal/m365/sharepoint/helper_test.go @@ -7,8 +7,8 @@ import ( msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" "github.com/stretchr/testify/require" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/support" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/pkg/account" ) @@ -18,10 +18,10 @@ import ( type MockGraphService struct{} type MockUpdater struct { - UpdateState func(*support.ConnectorOperationStatus) + UpdateState func(*support.ControllerOperationStatus) } -func (mu *MockUpdater) UpdateStatus(input *support.ConnectorOperationStatus) { +func (mu *MockUpdater) UpdateStatus(input *support.ControllerOperationStatus) { if mu.UpdateState != nil { mu.UpdateState(input) } @@ -39,7 +39,7 @@ func (ms *MockGraphService) Adapter() *msgraphsdk.GraphRequestAdapter { return nil } -func (ms *MockGraphService) UpdateStatus(*support.ConnectorOperationStatus) { +func (ms *MockGraphService) UpdateStatus(*support.ControllerOperationStatus) { } // --------------------------------------------------------------------------- diff --git a/src/internal/connector/sharepoint/library_handler.go b/src/internal/m365/sharepoint/library_handler.go similarity index 98% rename from src/internal/connector/sharepoint/library_handler.go rename to src/internal/m365/sharepoint/library_handler.go index 4ba928f8f..4ea9e1e92 100644 --- a/src/internal/connector/sharepoint/library_handler.go +++ b/src/internal/m365/sharepoint/library_handler.go @@ -9,8 +9,8 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/onedrive" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/services/m365/api" diff --git a/src/internal/connector/sharepoint/library_handler_test.go b/src/internal/m365/sharepoint/library_handler_test.go similarity index 100% rename from src/internal/connector/sharepoint/library_handler_test.go rename to src/internal/m365/sharepoint/library_handler_test.go diff --git a/src/internal/connector/sharepoint/list.go b/src/internal/m365/sharepoint/list.go similarity index 99% rename from src/internal/connector/sharepoint/list.go rename to src/internal/m365/sharepoint/list.go index 0da99fcea..3532e029b 100644 --- a/src/internal/connector/sharepoint/list.go +++ b/src/internal/m365/sharepoint/list.go @@ -9,7 +9,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/sites" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" ) diff --git a/src/internal/connector/sharepoint/listInfo.go b/src/internal/m365/sharepoint/list_info.go similarity index 100% rename from src/internal/connector/sharepoint/listInfo.go rename to src/internal/m365/sharepoint/list_info.go diff --git a/src/internal/connector/sharepoint/listInfo_test.go b/src/internal/m365/sharepoint/list_info_test.go similarity index 100% rename from src/internal/connector/sharepoint/listInfo_test.go rename to src/internal/m365/sharepoint/list_info_test.go diff --git a/src/internal/connector/sharepoint/list_test.go b/src/internal/m365/sharepoint/list_test.go similarity index 100% rename from src/internal/connector/sharepoint/list_test.go rename to src/internal/m365/sharepoint/list_test.go diff --git a/src/internal/connector/sharepoint/mock/list.go b/src/internal/m365/sharepoint/mock/list.go similarity index 100% rename from src/internal/connector/sharepoint/mock/list.go rename to src/internal/m365/sharepoint/mock/list.go diff --git a/src/internal/connector/sharepoint/mock/mock_test.go b/src/internal/m365/sharepoint/mock/mock_test.go similarity index 96% rename from src/internal/connector/sharepoint/mock/mock_test.go rename to src/internal/m365/sharepoint/mock/mock_test.go index 01776ea36..52070c2cb 100644 --- a/src/internal/connector/sharepoint/mock/mock_test.go +++ b/src/internal/m365/sharepoint/mock/mock_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/sharepoint/api" + "github.com/alcionai/corso/src/internal/m365/sharepoint/api" "github.com/alcionai/corso/src/internal/tester" ) diff --git a/src/internal/connector/sharepoint/mock/page.go b/src/internal/m365/sharepoint/mock/page.go similarity index 100% rename from src/internal/connector/sharepoint/mock/page.go rename to src/internal/m365/sharepoint/mock/page.go diff --git a/src/internal/connector/sharepoint/pageInfo.go b/src/internal/m365/sharepoint/pageInfo.go similarity index 93% rename from src/internal/connector/sharepoint/pageInfo.go rename to src/internal/m365/sharepoint/pageInfo.go index 97dc618ae..8b5060bdd 100644 --- a/src/internal/connector/sharepoint/pageInfo.go +++ b/src/internal/m365/sharepoint/pageInfo.go @@ -4,7 +4,7 @@ import ( "time" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" "github.com/alcionai/corso/src/pkg/backup/details" ) diff --git a/src/internal/connector/sharepoint/pageInfo_test.go b/src/internal/m365/sharepoint/pageInfo_test.go similarity index 94% rename from src/internal/connector/sharepoint/pageInfo_test.go rename to src/internal/m365/sharepoint/pageInfo_test.go index 924a9eed2..7490b117f 100644 --- a/src/internal/connector/sharepoint/pageInfo_test.go +++ b/src/internal/m365/sharepoint/pageInfo_test.go @@ -3,7 +3,7 @@ package sharepoint import ( "github.com/stretchr/testify/assert" - "github.com/alcionai/corso/src/internal/connector/graph/betasdk/models" + "github.com/alcionai/corso/src/internal/m365/graph/betasdk/models" "github.com/alcionai/corso/src/pkg/backup/details" ) diff --git a/src/internal/connector/sharepoint/restore.go b/src/internal/m365/sharepoint/restore.go similarity index 88% rename from src/internal/connector/sharepoint/restore.go rename to src/internal/m365/sharepoint/restore.go index be307fb86..5bf53a4d6 100644 --- a/src/internal/connector/sharepoint/restore.go +++ b/src/internal/m365/sharepoint/restore.go @@ -11,12 +11,12 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/onedrive" - betaAPI "github.com/alcionai/corso/src/internal/connector/sharepoint/api" - "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/onedrive" + betaAPI "github.com/alcionai/corso/src/internal/m365/sharepoint/api" + "github.com/alcionai/corso/src/internal/m365/support" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" @@ -25,21 +25,8 @@ import ( "github.com/alcionai/corso/src/pkg/services/m365/api" ) -//---------------------------------------------------------------------------- -// SharePoint Restore WorkFlow: -// - RestoreCollections called by GC component -// -- Collections are iterated within, Control Flow Switch -// -- Switch: -// ---- Libraries restored via the same workflow as oneDrive -// ---- Lists call RestoreCollection() -// ----> for each data.Stream within RestoreCollection.Items() -// ----> restoreListItems() is called -// Restored List can be found in the Site's `Site content` page -// Restored Libraries can be found within the Site's `Pages` page -//------------------------------------------ - -// RestoreCollections will restore the specified data collections into OneDrive -func RestoreCollections( +// ConsumeRestoreCollections will restore the specified data collections into OneDrive +func ConsumeRestoreCollections( ctx context.Context, backupVersion int, ac api.Client, @@ -48,7 +35,7 @@ func RestoreCollections( dcs []data.RestoreCollection, deets *details.Builder, errs *fault.Bus, -) (*support.ConnectorOperationStatus, error) { +) (*support.ControllerOperationStatus, error) { var ( restoreMetrics support.CollectionMetrics caches = onedrive.NewRestoreCaches() @@ -78,7 +65,7 @@ func RestoreCollections( switch dc.FullPath().Category() { case path.LibrariesCategory: - metrics, err = onedrive.RestoreCollection( + metrics, err = onedrive.ProduceRestoreCollection( ictx, libraryRestoreHandler{ac.Drives()}, backupVersion, diff --git a/src/internal/connector/support/operation_string.go b/src/internal/m365/support/operation_string.go similarity index 100% rename from src/internal/connector/support/operation_string.go rename to src/internal/m365/support/operation_string.go diff --git a/src/internal/connector/support/status.go b/src/internal/m365/support/status.go similarity index 84% rename from src/internal/connector/support/status.go rename to src/internal/m365/support/status.go index 6b3f154b5..f241909fe 100644 --- a/src/internal/connector/support/status.go +++ b/src/internal/m365/support/status.go @@ -7,13 +7,13 @@ import ( "github.com/dustin/go-humanize" ) -// ConnectorOperationStatus is a data type used to describe the state of +// ControllerOperationStatus is a data type used to describe the state of // the sequence of operations. // @param ObjectCount integer representation of how many objects have downloaded or uploaded. // @param Successful: Number of objects that are sent through the connector without incident. // @param incomplete: Bool representation of whether all intended items were download or uploaded. // @param bytes: represents the total number of bytes that have been downloaded or uploaded. -type ConnectorOperationStatus struct { +type ControllerOperationStatus struct { Folders int Metrics CollectionMetrics details string @@ -49,8 +49,8 @@ func CreateStatus( folders int, cm CollectionMetrics, details string, -) *ConnectorOperationStatus { - status := ConnectorOperationStatus{ +) *ControllerOperationStatus { + status := ControllerOperationStatus{ Folders: folders, Metrics: cm, details: details, @@ -63,10 +63,10 @@ func CreateStatus( // Function signature for a status updater // Used to define a function that an async connector task can call // to on completion with its ConnectorOperationStatus -type StatusUpdater func(*ConnectorOperationStatus) +type StatusUpdater func(*ControllerOperationStatus) // MergeStatus combines ConnectorOperationsStatus value into a single status -func MergeStatus(one, two ConnectorOperationStatus) ConnectorOperationStatus { +func MergeStatus(one, two ControllerOperationStatus) ControllerOperationStatus { if one.op == OpUnknown { return two } @@ -75,7 +75,7 @@ func MergeStatus(one, two ConnectorOperationStatus) ConnectorOperationStatus { return one } - status := ConnectorOperationStatus{ + status := ControllerOperationStatus{ Folders: one.Folders + two.Folders, Metrics: CombineMetrics(one.Metrics, two.Metrics), details: one.details + ", " + two.details, @@ -85,7 +85,7 @@ func MergeStatus(one, two ConnectorOperationStatus) ConnectorOperationStatus { return status } -func (cos *ConnectorOperationStatus) String() string { +func (cos *ControllerOperationStatus) String() string { var operationStatement string switch cos.op { diff --git a/src/internal/connector/support/status_test.go b/src/internal/m365/support/status_test.go similarity index 93% rename from src/internal/connector/support/status_test.go rename to src/internal/m365/support/status_test.go index cad22d22f..79277242b 100644 --- a/src/internal/connector/support/status_test.go +++ b/src/internal/m365/support/status_test.go @@ -13,7 +13,7 @@ type StatusUnitSuite struct { tester.Suite } -func TestGraphConnectorStatus(t *testing.T) { +func TestStatusUnitSuite(t *testing.T) { suite.Run(t, &StatusUnitSuite{tester.NewUnitSuite(t)}) } @@ -71,8 +71,8 @@ func (suite *StatusUnitSuite) TestMergeStatus() { table := []struct { name string - one ConnectorOperationStatus - two ConnectorOperationStatus + one ControllerOperationStatus + two ControllerOperationStatus expectOp Operation expectMetrics CollectionMetrics expectFolders int @@ -80,14 +80,14 @@ func (suite *StatusUnitSuite) TestMergeStatus() { { name: "Test: Status + unknown", one: *CreateStatus(ctx, Backup, 1, CollectionMetrics{1, 1, 0}, ""), - two: ConnectorOperationStatus{}, + two: ControllerOperationStatus{}, expectOp: Backup, expectMetrics: CollectionMetrics{1, 1, 0}, expectFolders: 1, }, { name: "Test: unknown + Status", - one: ConnectorOperationStatus{}, + one: ControllerOperationStatus{}, two: *CreateStatus(ctx, Backup, 1, CollectionMetrics{1, 1, 0}, ""), expectOp: Backup, expectMetrics: CollectionMetrics{1, 1, 0}, diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index f5739246f..4772f8b20 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -11,12 +11,12 @@ import ( "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/prefixmatcher" - "github.com/alcionai/corso/src/internal/connector/graph" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" "github.com/alcionai/corso/src/internal/events" "github.com/alcionai/corso/src/internal/kopia" kinject "github.com/alcionai/corso/src/internal/kopia/inject" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/internal/operations/inject" @@ -117,7 +117,7 @@ func (op BackupOperation) validate() error { // get populated asynchronously. type backupStats struct { k *kopia.BackupStats - gc *data.CollectionStats + ctrl *data.CollectionStats resourceCount int } @@ -370,9 +370,9 @@ func (op *BackupOperation) do( return nil, clues.Wrap(err, "merging details") } - opStats.gc = op.bp.Wait() + opStats.ctrl = op.bp.Wait() - logger.Ctx(ctx).Debug(opStats.gc) + logger.Ctx(ctx).Debug(opStats.ctrl) return deets, nil } @@ -870,16 +870,16 @@ func (op *BackupOperation) persistResults( op.Results.NonMetaItemsWritten = opStats.k.TotalNonMetaFileCount op.Results.ResourceOwners = opStats.resourceCount - if opStats.gc == nil { + if opStats.ctrl == nil { op.Status = Failed return clues.New("backup population never completed") } - if op.Status != Failed && opStats.gc.IsZero() { + if op.Status != Failed && opStats.ctrl.IsZero() { op.Status = NoData } - op.Results.ItemsRead = opStats.gc.Successes + op.Results.ItemsRead = opStats.ctrl.Successes return op.Errors.Failure() } diff --git a/src/internal/operations/backup_integration_test.go b/src/internal/operations/backup_integration_test.go index 8fbd9d2ce..df57dea03 100644 --- a/src/internal/operations/backup_integration_test.go +++ b/src/internal/operations/backup_integration_test.go @@ -21,20 +21,21 @@ import ( "github.com/alcionai/corso/src/internal/common/idname" inMock "github.com/alcionai/corso/src/internal/common/idname/mock" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector" - "github.com/alcionai/corso/src/internal/connector/exchange" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" - exchTD "github.com/alcionai/corso/src/internal/connector/exchange/testdata" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/mock" - "github.com/alcionai/corso/src/internal/connector/onedrive" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" - "github.com/alcionai/corso/src/internal/connector/sharepoint" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/events" evmock "github.com/alcionai/corso/src/internal/events/mock" "github.com/alcionai/corso/src/internal/kopia" + "github.com/alcionai/corso/src/internal/m365" + "github.com/alcionai/corso/src/internal/m365/exchange" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" + exchTD "github.com/alcionai/corso/src/internal/m365/exchange/testdata" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/mock" + "github.com/alcionai/corso/src/internal/m365/onedrive" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/resource" + "github.com/alcionai/corso/src/internal/m365/sharepoint" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/operations/inject" "github.com/alcionai/corso/src/internal/streamstore" @@ -79,7 +80,7 @@ func prepNewTestBackupOp( *kopia.Wrapper, *kopia.ModelStore, streamstore.Streamer, - *connector.GraphConnector, + *m365.Controller, selectors.Selector, func(), ) { @@ -120,17 +121,17 @@ func prepNewTestBackupOp( ms.Close(ctx) } - connectorResource := connector.Users + connectorResource := resource.Users if sel.Service == selectors.ServiceSharePoint { - connectorResource = connector.Sites + connectorResource = resource.Sites } - gc, sel := GCWithSelector(t, ctx, acct, connectorResource, sel, nil, closer) - bo := newTestBackupOp(t, ctx, kw, ms, gc, acct, sel, bus, featureToggles, closer) + ctrl, sel := ControllerWithSelector(t, ctx, acct, connectorResource, sel, nil, closer) + bo := newTestBackupOp(t, ctx, kw, ms, ctrl, acct, sel, bus, featureToggles, closer) ss := streamstore.NewStreamer(kw, acct.ID(), sel.PathService()) - return bo, acct, kw, ms, ss, gc, sel, closer + return bo, acct, kw, ms, ss, ctrl, sel, closer } // newTestBackupOp accepts the clients required to compose a backup operation, plus @@ -142,7 +143,7 @@ func newTestBackupOp( ctx context.Context, //revive:disable-line:context-as-argument kw *kopia.Wrapper, ms *kopia.ModelStore, - gc *connector.GraphConnector, + ctrl *m365.Controller, acct account.Account, sel selectors.Selector, bus events.Eventer, @@ -155,9 +156,9 @@ func newTestBackupOp( ) opts.ToggleFeatures = featureToggles - gc.IDNameLookup = idname.NewCache(map[string]string{sel.ID(): sel.Name()}) + ctrl.IDNameLookup = idname.NewCache(map[string]string{sel.ID(): sel.Name()}) - bo, err := NewBackupOperation(ctx, opts, kw, sw, gc, acct, sel, sel, bus) + bo, err := NewBackupOperation(ctx, opts, kw, sw, ctrl, acct, sel, sel, bus) if !assert.NoError(t, err, clues.ToCore(err)) { closer() t.FailNow() @@ -346,7 +347,7 @@ type dataBuilderFunc func(id, timeStamp, subject, body string) []byte func generateContainerOfItems( t *testing.T, ctx context.Context, //revive:disable-line:context-as-argument - gc *connector.GraphConnector, + ctrl *m365.Controller, service path.ServiceType, cat path.CategoryType, sel selectors.Selector, @@ -394,7 +395,7 @@ func generateContainerOfItems( opts := control.Defaults() opts.RestorePermissions = true - deets, err := gc.ConsumeRestoreCollections( + deets, err := ctrl.ConsumeRestoreCollections( ctx, backupVersion, sel, @@ -405,8 +406,8 @@ func generateContainerOfItems( require.NoError(t, err, clues.ToCore(err)) // have to wait here, both to ensure the process - // finishes, and also to clean up the gc status - gc.Wait() + // finishes, and also to clean up the status + ctrl.Wait() return deets } @@ -542,7 +543,7 @@ func (suite *BackupOpIntegrationSuite) TestNewBackupOperation() { var ( kw = &kopia.Wrapper{} sw = &store.Wrapper{} - gc = &mock.GraphConnector{} + ctrl = &mock.Controller{} acct = tester.NewM365Account(suite.T()) opts = control.Defaults() ) @@ -556,9 +557,9 @@ func (suite *BackupOpIntegrationSuite) TestNewBackupOperation() { targets []string errCheck assert.ErrorAssertionFunc }{ - {"good", kw, sw, gc, acct, nil, assert.NoError}, - {"missing kopia", nil, sw, gc, acct, nil, assert.Error}, - {"missing modelstore", kw, nil, gc, acct, nil, assert.Error}, + {"good", kw, sw, ctrl, acct, nil, assert.NoError}, + {"missing kopia", nil, sw, ctrl, acct, nil, assert.Error}, + {"missing modelstore", kw, nil, ctrl, acct, nil, assert.Error}, {"missing backup producer", kw, sw, nil, acct, nil, assert.Error}, } for _, test := range table { @@ -645,7 +646,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchange() { whatSet = deeTD.CategoryFromRepoRef ) - bo, acct, kw, ms, ss, gc, sel, closer := prepNewTestBackupOp(t, ctx, mb, sel, ffs, version.Backup) + bo, acct, kw, ms, ss, ctrl, sel, closer := prepNewTestBackupOp(t, ctx, mb, sel, ffs, version.Backup) defer closer() userID := sel.ID() @@ -684,7 +685,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchange() { // produces fewer results than the last backup. var ( incMB = evmock.NewBus() - incBO = newTestBackupOp(t, ctx, kw, ms, gc, acct, sel, incMB, ffs, closer) + incBO = newTestBackupOp(t, ctx, kw, ms, ctrl, acct, sel, incMB, ffs, closer) ) runAndCheckBackup(t, ctx, &incBO, incMB, true) @@ -766,7 +767,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont whatSet = deeTD.CategoryFromRepoRef ) - gc, sels := GCWithSelector(t, ctx, acct, connector.Users, sel.Selector, nil, nil) + ctrl, sels := ControllerWithSelector(t, ctx, acct, resource.Users, sel.Selector, nil, nil) sel.DiscreteOwner = sels.ID() sel.DiscreteOwnerName = sels.Name() @@ -776,10 +777,10 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont sel.MailFolders(containers, selectors.PrefixMatch()), sel.ContactFolders(containers, selectors.PrefixMatch())) - m365, err := acct.M365Config() + creds, err := acct.M365Config() require.NoError(t, err, clues.ToCore(err)) - ac, err := api.NewClient(m365) + ac, err := api.NewClient(creds) require.NoError(t, err, clues.ToCore(err)) // generate 3 new folders with two items each. @@ -855,11 +856,11 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont deets := generateContainerOfItems( t, ctx, - gc, + ctrl, service, category, selectors.NewExchangeRestore([]string{uidn.ID()}).Selector, - m365.AzureTenantID, uidn.ID(), "", destName, + creds.AzureTenantID, uidn.ID(), "", destName, 2, version.Backup, gen.dbf) @@ -883,7 +884,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont } } - bo, acct, kw, ms, ss, gc, sels, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, toggles, version.Backup) + bo, acct, kw, ms, ss, ctrl, sels, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, toggles, version.Backup) defer closer() // run the initial backup @@ -1036,11 +1037,11 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont deets := generateContainerOfItems( t, ctx, - gc, + ctrl, service, category, selectors.NewExchangeRestore([]string{uidn.ID()}).Selector, - m365.AzureTenantID, suite.user, "", container3, + creds.AzureTenantID, suite.user, "", container3, 2, version.Backup, gen.dbf) @@ -1245,8 +1246,8 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont var ( t = suite.T() incMB = evmock.NewBus() - incBO = newTestBackupOp(t, ctx, kw, ms, gc, acct, sels, incMB, toggles, closer) - atid = m365.AzureTenantID + incBO = newTestBackupOp(t, ctx, kw, ms, ctrl, acct, sels, incMB, toggles, closer) + atid = creds.AzureTenantID ) test.updateUserData(t) @@ -1347,7 +1348,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_incrementalOneDrive() { suite, suite.user, suite.user, - connector.Users, + resource.Users, path.OneDriveService, path.FilesCategory, ic, @@ -1390,7 +1391,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_incrementalSharePoint() { suite, suite.site, suite.user, - connector.Sites, + resource.Sites, path.SharePointService, path.LibrariesCategory, ic, @@ -1402,7 +1403,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_incrementalSharePoint() { func runDriveIncrementalTest( suite *BackupOpIntegrationSuite, owner, permissionsUser string, - resource connector.Resource, + rc resource.Category, service path.ServiceType, category path.CategoryType, includeContainers func([]string) selectors.Selector, @@ -1445,9 +1446,9 @@ func runDriveIncrementalTest( creds, err := acct.M365Config() require.NoError(t, err, clues.ToCore(err)) - gc, sel := GCWithSelector(t, ctx, acct, resource, sel, nil, nil) - ac := gc.AC.Drives() - rh := getRestoreHandler(gc.AC) + ctrl, sel := ControllerWithSelector(t, ctx, acct, rc, sel, nil, nil) + ac := ctrl.AC.Drives() + rh := getRestoreHandler(ctrl.AC) roidn := inMock.NewProvider(sel.ID(), sel.Name()) @@ -1479,7 +1480,7 @@ func runDriveIncrementalTest( deets := generateContainerOfItems( t, ctx, - gc, + ctrl, service, category, sel, @@ -1506,14 +1507,14 @@ func runDriveIncrementalTest( // onedrive package `getFolder` function. itemURL := fmt.Sprintf("https://graph.microsoft.com/v1.0/drives/%s/root:/%s", driveID, destName) resp, err := drives. - NewItemItemsDriveItemItemRequestBuilder(itemURL, gc.AC.Stable.Adapter()). + NewItemItemsDriveItemItemRequestBuilder(itemURL, ctrl.AC.Stable.Adapter()). Get(ctx, nil) require.NoError(t, err, "getting drive folder ID", "folder name", destName, clues.ToCore(err)) containerIDs[destName] = ptr.Val(resp.GetId()) } - bo, _, kw, ms, ss, gc, _, closer := prepNewTestBackupOp(t, ctx, mb, sel, ffs, version.Backup) + bo, _, kw, ms, ss, ctrl, _, closer := prepNewTestBackupOp(t, ctx, mb, sel, ffs, version.Backup) defer closer() // run the initial backup @@ -1812,7 +1813,7 @@ func runDriveIncrementalTest( generateContainerOfItems( t, ctx, - gc, + ctrl, service, category, sel, @@ -1826,7 +1827,7 @@ func runDriveIncrementalTest( "https://graph.microsoft.com/v1.0/drives/%s/root:/%s", driveID, container3) - resp, err := drives.NewItemItemsDriveItemItemRequestBuilder(itemURL, gc.AC.Stable.Adapter()). + resp, err := drives.NewItemItemsDriveItemItemRequestBuilder(itemURL, ctrl.AC.Stable.Adapter()). Get(ctx, nil) require.NoError(t, err, "getting drive folder ID", "folder name", container3, clues.ToCore(err)) @@ -1841,13 +1842,13 @@ func runDriveIncrementalTest( } for _, test := range table { suite.Run(test.name, func() { - cleanGC, err := connector.NewGraphConnector(ctx, acct, resource) + cleanCtrl, err := m365.NewController(ctx, acct, rc) require.NoError(t, err, clues.ToCore(err)) var ( t = suite.T() incMB = evmock.NewBus() - incBO = newTestBackupOp(t, ctx, kw, ms, cleanGC, acct, sel, incMB, ffs, closer) + incBO = newTestBackupOp(t, ctx, kw, ms, cleanCtrl, acct, sel, incMB, ffs, closer) ) tester.LogTimeOfTest(suite.T()) @@ -1914,13 +1915,13 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDriveOwnerMigration() { creds, err := acct.M365Config() require.NoError(t, err, clues.ToCore(err)) - gc, err := connector.NewGraphConnector( + ctrl, err := m365.NewController( ctx, acct, - connector.Users) + resource.Users) require.NoError(t, err, clues.ToCore(err)) - userable, err := gc.AC.Users().GetByID(ctx, suite.user) + userable, err := ctrl.AC.Users().GetByID(ctx, suite.user) require.NoError(t, err, clues.ToCore(err)) uid := ptr.Val(userable.GetId()) @@ -1929,7 +1930,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDriveOwnerMigration() { oldsel := selectors.NewOneDriveBackup([]string{uname}) oldsel.Include(selTD.OneDriveBackupFolderScope(oldsel)) - bo, _, kw, ms, _, gc, sel, closer := prepNewTestBackupOp(t, ctx, mb, oldsel.Selector, ffs, 0) + bo, _, kw, ms, _, ctrl, sel, closer := prepNewTestBackupOp(t, ctx, mb, oldsel.Selector, ffs, 0) defer closer() // ensure the initial owner uses name in both cases @@ -1955,7 +1956,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDriveOwnerMigration() { var ( incMB = evmock.NewBus() // the incremental backup op should have a proper user ID for the id. - incBO = newTestBackupOp(t, ctx, kw, ms, gc, acct, sel, incMB, ffs, closer) + incBO = newTestBackupOp(t, ctx, kw, ms, ctrl, acct, sel, incMB, ffs, closer) ) require.NotEqualf( diff --git a/src/internal/operations/backup_test.go b/src/internal/operations/backup_test.go index a8648d97b..248d40087 100644 --- a/src/internal/operations/backup_test.go +++ b/src/internal/operations/backup_test.go @@ -15,11 +15,11 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/prefixmatcher" - "github.com/alcionai/corso/src/internal/connector/mock" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" "github.com/alcionai/corso/src/internal/data" evmock "github.com/alcionai/corso/src/internal/events/mock" "github.com/alcionai/corso/src/internal/kopia" + "github.com/alcionai/corso/src/internal/m365/mock" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/internal/model" ssmock "github.com/alcionai/corso/src/internal/streamstore/mock" "github.com/alcionai/corso/src/internal/tester" @@ -414,7 +414,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { var ( kw = &kopia.Wrapper{} sw = &store.Wrapper{} - gc = &mock.GraphConnector{} + ctrl = &mock.Controller{} acct = account.Account{} now = time.Now() ) @@ -435,7 +435,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { TotalHashedBytes: 1, TotalUploadedBytes: 1, }, - gc: &data.CollectionStats{Successes: 1}, + ctrl: &data.CollectionStats{Successes: 1}, }, }, { @@ -443,16 +443,16 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { expectErr: assert.Error, fail: assert.AnError, stats: backupStats{ - k: &kopia.BackupStats{}, - gc: &data.CollectionStats{}, + k: &kopia.BackupStats{}, + ctrl: &data.CollectionStats{}, }, }, { expectStatus: NoData, expectErr: assert.NoError, stats: backupStats{ - k: &kopia.BackupStats{}, - gc: &data.CollectionStats{}, + k: &kopia.BackupStats{}, + ctrl: &data.CollectionStats{}, }, }, } @@ -471,7 +471,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { control.Defaults(), kw, sw, - gc, + ctrl, acct, sel, sel, @@ -483,7 +483,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { test.expectErr(t, op.persistResults(now, &test.stats)) assert.Equal(t, test.expectStatus.String(), op.Status.String(), "status") - assert.Equal(t, test.stats.gc.Successes, op.Results.ItemsRead, "items read") + assert.Equal(t, test.stats.ctrl.Successes, op.Results.ItemsRead, "items read") assert.Equal(t, test.stats.k.TotalFileCount, op.Results.ItemsWritten, "items written") assert.Equal(t, test.stats.k.TotalHashedBytes, op.Results.BytesRead, "bytes read") assert.Equal(t, test.stats.k.TotalUploadedBytes, op.Results.BytesUploaded, "bytes written") diff --git a/src/internal/operations/help_test.go b/src/internal/operations/help_test.go index f5b01dc9b..c1830bf25 100644 --- a/src/internal/operations/help_test.go +++ b/src/internal/operations/help_test.go @@ -8,24 +8,25 @@ import ( "github.com/stretchr/testify/assert" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/connector" + "github.com/alcionai/corso/src/internal/m365" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/selectors" ) -// A QoL builder for live GC instances that updates +// A QoL builder for live instances that updates // the selector's owner id and name in the process // to help avoid gotchas. -func GCWithSelector( +func ControllerWithSelector( t *testing.T, ctx context.Context, //revive:disable-line:context-as-argument acct account.Account, - cr connector.Resource, + cr resource.Category, sel selectors.Selector, ins idname.Cacher, onFail func(), -) (*connector.GraphConnector, selectors.Selector) { - gc, err := connector.NewGraphConnector(ctx, acct, cr) +) (*m365.Controller, selectors.Selector) { + ctrl, err := m365.NewController(ctx, acct, cr) if !assert.NoError(t, err, clues.ToCore(err)) { if onFail != nil { onFail() @@ -34,7 +35,7 @@ func GCWithSelector( t.FailNow() } - id, name, err := gc.PopulateOwnerIDAndNamesFrom(ctx, sel.DiscreteOwner, ins) + id, name, err := ctrl.PopulateOwnerIDAndNamesFrom(ctx, sel.DiscreteOwner, ins) if !assert.NoError(t, err, clues.ToCore(err)) { if onFail != nil { onFail() @@ -45,5 +46,5 @@ func GCWithSelector( sel = sel.SetDiscreteOwnerIDName(id, name) - return gc, sel + return ctrl, sel } diff --git a/src/internal/operations/manifests.go b/src/internal/operations/manifests.go index 2b028c55a..121481066 100644 --- a/src/internal/operations/manifests.go +++ b/src/internal/operations/manifests.go @@ -8,10 +8,10 @@ import ( "github.com/pkg/errors" "golang.org/x/exp/maps" - "github.com/alcionai/corso/src/internal/connector/graph" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/kopia" "github.com/alcionai/corso/src/internal/kopia/inject" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/pkg/backup" "github.com/alcionai/corso/src/pkg/fault" diff --git a/src/internal/operations/restore.go b/src/internal/operations/restore.go index 02f406e0a..ef7e7ea38 100644 --- a/src/internal/operations/restore.go +++ b/src/internal/operations/restore.go @@ -10,11 +10,11 @@ import ( "github.com/alcionai/corso/src/internal/common/crash" "github.com/alcionai/corso/src/internal/common/dttm" - "github.com/alcionai/corso/src/internal/connector/onedrive" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" "github.com/alcionai/corso/src/internal/events" "github.com/alcionai/corso/src/internal/kopia" + "github.com/alcionai/corso/src/internal/m365/onedrive" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/internal/operations/inject" @@ -94,7 +94,7 @@ func (op RestoreOperation) validate() error { // get populated asynchronously. type restoreStats struct { cs []data.RestoreCollection - gc *data.CollectionStats + ctrl *data.CollectionStats bytesRead *stats.ByteCounter resourceCount int @@ -265,9 +265,9 @@ func (op *RestoreOperation) do( return nil, clues.Wrap(err, "restoring collections") } - opStats.gc = op.rc.Wait() + opStats.ctrl = op.rc.Wait() - logger.Ctx(ctx).Debug(opStats.gc) + logger.Ctx(ctx).Debug(opStats.ctrl) return deets, nil } @@ -291,16 +291,16 @@ func (op *RestoreOperation) persistResults( op.Results.ItemsRead = len(opStats.cs) // TODO: file count, not collection count op.Results.ResourceOwners = opStats.resourceCount - if opStats.gc == nil { + if opStats.ctrl == nil { op.Status = Failed return clues.New("restoration never completed") } - if op.Status != Failed && opStats.gc.IsZero() { + if op.Status != Failed && opStats.ctrl.IsZero() { op.Status = NoData } - op.Results.ItemsWritten = opStats.gc.Successes + op.Results.ItemsWritten = opStats.ctrl.Successes return op.Errors.Failure() } diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index 63c92c208..5eb1d4fda 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -12,14 +12,15 @@ import ( "github.com/alcionai/corso/src/internal/common/dttm" inMock "github.com/alcionai/corso/src/internal/common/idname/mock" - "github.com/alcionai/corso/src/internal/connector" - "github.com/alcionai/corso/src/internal/connector/exchange" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" - "github.com/alcionai/corso/src/internal/connector/mock" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/events" evmock "github.com/alcionai/corso/src/internal/events/mock" "github.com/alcionai/corso/src/internal/kopia" + "github.com/alcionai/corso/src/internal/m365" + "github.com/alcionai/corso/src/internal/m365/exchange" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" + "github.com/alcionai/corso/src/internal/m365/mock" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/operations/inject" "github.com/alcionai/corso/src/internal/stats" @@ -48,7 +49,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { var ( kw = &kopia.Wrapper{} sw = &store.Wrapper{} - gc = &mock.GraphConnector{} + ctrl = &mock.Controller{} now = time.Now() restoreCfg = tester.DefaultTestRestoreConfig("") ) @@ -72,7 +73,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { Collection: &exchMock.DataCollection{}, }, }, - gc: &data.CollectionStats{ + ctrl: &data.CollectionStats{ Objects: 1, Successes: 1, }, @@ -84,7 +85,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { fail: assert.AnError, stats: restoreStats{ bytesRead: &stats.ByteCounter{}, - gc: &data.CollectionStats{}, + ctrl: &data.CollectionStats{}, }, }, { @@ -93,7 +94,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { stats: restoreStats{ bytesRead: &stats.ByteCounter{}, cs: []data.RestoreCollection{}, - gc: &data.CollectionStats{}, + ctrl: &data.CollectionStats{}, }, }, } @@ -109,7 +110,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { control.Defaults(), kw, sw, - gc, + ctrl, account.Account{}, "foo", selectors.Selector{DiscreteOwner: "test"}, @@ -124,7 +125,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { assert.Equal(t, test.expectStatus.String(), op.Status.String(), "status") assert.Equal(t, len(test.stats.cs), op.Results.ItemsRead, "items read") - assert.Equal(t, test.stats.gc.Successes, op.Results.ItemsWritten, "items written") + assert.Equal(t, test.stats.ctrl.Successes, op.Results.ItemsWritten, "items written") assert.Equal(t, test.stats.bytesRead.NumBytes, op.Results.BytesRead, "resource owners") assert.Equal(t, test.stats.resourceCount, op.Results.ResourceOwners, "resource owners") assert.Equal(t, now, op.Results.StartedAt, "started at") @@ -141,7 +142,7 @@ type bupResults struct { selectorResourceOwners []string backupID model.StableID items int - gc *connector.GraphConnector + ctrl *m365.Controller } type RestoreOpIntegrationSuite struct { @@ -217,7 +218,7 @@ func (suite *RestoreOpIntegrationSuite) TestNewRestoreOperation() { var ( kw = &kopia.Wrapper{} sw = &store.Wrapper{} - gc = &mock.GraphConnector{} + ctrl = &mock.Controller{} restoreCfg = tester.DefaultTestRestoreConfig("") opts = control.Defaults() ) @@ -230,9 +231,9 @@ func (suite *RestoreOpIntegrationSuite) TestNewRestoreOperation() { targets []string errCheck assert.ErrorAssertionFunc }{ - {"good", kw, sw, gc, nil, assert.NoError}, - {"missing kopia", nil, sw, gc, nil, assert.Error}, - {"missing modelstore", kw, nil, gc, nil, assert.Error}, + {"good", kw, sw, ctrl, nil, assert.NoError}, + {"missing kopia", nil, sw, ctrl, nil, assert.Error}, + {"missing modelstore", kw, nil, ctrl, nil, assert.Error}, {"missing restore consumer", kw, sw, nil, nil, assert.Error}, } for _, test := range table { @@ -279,14 +280,14 @@ func setupExchangeBackup( esel.ContactFolders([]string{exchange.DefaultContactFolder}, selectors.PrefixMatch()), esel.EventCalendars([]string{exchange.DefaultCalendar}, selectors.PrefixMatch())) - gc, sel := GCWithSelector(t, ctx, acct, connector.Users, esel.Selector, nil, nil) + ctrl, sel := ControllerWithSelector(t, ctx, acct, resource.Users, esel.Selector, nil, nil) bo, err := NewBackupOperation( ctx, control.Defaults(), kw, sw, - gc, + ctrl, acct, sel, inMock.NewProvider(owner, owner), @@ -304,7 +305,7 @@ func setupExchangeBackup( // These meta files are used to aid restore, but are not themselves // restored (ie: counted as writes). items: bo.Results.ItemsWritten - 6, - gc: gc, + ctrl: ctrl, } } @@ -330,21 +331,21 @@ func setupSharePointBackup( ssel.Include(ssel.LibraryFolders([]string{"test"}, selectors.PrefixMatch())) ssel.DiscreteOwner = owner - gc, sel := GCWithSelector(t, ctx, acct, connector.Sites, ssel.Selector, nil, nil) + ctrl, sel := ControllerWithSelector(t, ctx, acct, resource.Sites, ssel.Selector, nil, nil) bo, err := NewBackupOperation( ctx, control.Defaults(), kw, sw, - gc, + ctrl, acct, sel, inMock.NewProvider(owner, owner), evmock.NewBus()) require.NoError(t, err, clues.ToCore(err)) - spPgr := gc.AC.Drives().NewSiteDrivePager(owner, []string{"id", "name"}) + spPgr := ctrl.AC.Drives().NewSiteDrivePager(owner, []string{"id", "name"}) drives, err := api.GetAllDrives(ctx, spPgr, true, 3) require.NoError(t, err, clues.ToCore(err)) @@ -362,7 +363,7 @@ func setupSharePointBackup( // These meta files are used to aid restore, but are not themselves // restored (ie: counted as writes). items: bo.Results.ItemsWritten - 2 - len(drives) - len(drives), - gc: gc, + ctrl: ctrl, } } @@ -419,7 +420,7 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run() { control.Options{FailureHandling: control.FailFast}, suite.kw, suite.sw, - bup.gc, + bup.ctrl, tester.NewM365Account(t), bup.backupID, test.getSelector(t, bup.selectorResourceOwners), @@ -460,10 +461,10 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoBackup() { rsel := selectors.NewExchangeRestore(selectors.None()) rsel.Include(rsel.AllData()) - gc, err := connector.NewGraphConnector( + ctrl, err := m365.NewController( ctx, suite.acct, - connector.Users) + resource.Users) require.NoError(t, err, clues.ToCore(err)) ro, err := NewRestoreOperation( @@ -471,7 +472,7 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoBackup() { control.Defaults(), suite.kw, suite.sw, - gc, + ctrl, tester.NewM365Account(t), "backupID", rsel.Selector, diff --git a/src/internal/tester/account.go b/src/internal/tester/account.go index 94552c771..6684c0bf1 100644 --- a/src/internal/tester/account.go +++ b/src/internal/tester/account.go @@ -16,7 +16,7 @@ var M365AcctCredEnvs = []string{ } // NewM365Account returns an account.Account object initialized with environment -// variables used for integration tests that use Graph Connector. +// variables used for integration tests that use the m365 Controller. func NewM365Account(t *testing.T) account.Account { cfg, err := readTestConfig() require.NoError(t, err, "configuring m365 account from test configuration", clues.ToCore(err)) diff --git a/src/pkg/backup/details/details.go b/src/pkg/backup/details/details.go index c24f8fb42..f394d02b7 100644 --- a/src/pkg/backup/details/details.go +++ b/src/pkg/backup/details/details.go @@ -15,7 +15,7 @@ import ( "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/internal/common/dttm" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/pkg/backup/details/details_test.go b/src/pkg/backup/details/details_test.go index f6c1097ae..4646b484a 100644 --- a/src/pkg/backup/details/details_test.go +++ b/src/pkg/backup/details/details_test.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/dttm" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/version" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/pkg/errs/errs.go b/src/pkg/errs/errs.go index f93e0e51a..ce6e9c58a 100644 --- a/src/pkg/errs/errs.go +++ b/src/pkg/errs/errs.go @@ -3,7 +3,7 @@ package errs import ( "errors" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/repository" ) diff --git a/src/pkg/errs/errs_test.go b/src/pkg/errs/errs_test.go index 789c88658..50b583143 100644 --- a/src/pkg/errs/errs_test.go +++ b/src/pkg/errs/errs_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/repository" ) diff --git a/src/pkg/logger/example_logger_test.go b/src/pkg/logger/example_logger_test.go index b141efecf..3c97bfd0e 100644 --- a/src/pkg/logger/example_logger_test.go +++ b/src/pkg/logger/example_logger_test.go @@ -5,8 +5,8 @@ import ( "github.com/alcionai/clues" - "github.com/alcionai/corso/src/internal/connector" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/path" ) @@ -188,7 +188,7 @@ func Example_logger_clues_standards() { // preferred log.With( // internal type, safe to log plainly - "resource_type", connector.Users, + "resource_type", resource.Users, // string containing sensitive info, wrap with Hide() "user_name", clues.Hide("your_user_name@microsoft.example"), // string partially concealed by a managed concealer. diff --git a/src/pkg/path/drive_test.go b/src/pkg/path/drive_test.go index 5a6853caf..131c17b9c 100644 --- a/src/pkg/path/drive_test.go +++ b/src/pkg/path/drive_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/path" ) diff --git a/src/pkg/repository/repository.go b/src/pkg/repository/repository.go index 13385cbb8..b58cf3eac 100644 --- a/src/pkg/repository/repository.go +++ b/src/pkg/repository/repository.go @@ -10,11 +10,12 @@ import ( "github.com/alcionai/corso/src/internal/common/crash" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/connector" - "github.com/alcionai/corso/src/internal/connector/onedrive/metadata" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/events" "github.com/alcionai/corso/src/internal/kopia" + "github.com/alcionai/corso/src/internal/m365" + "github.com/alcionai/corso/src/internal/m365/onedrive/metadata" + "github.com/alcionai/corso/src/internal/m365/resource" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/internal/operations" @@ -306,12 +307,12 @@ func (r repository) NewBackupWithLookup( sel selectors.Selector, ins idname.Cacher, ) (operations.BackupOperation, error) { - gc, err := connectToM365(ctx, sel, r.Account) + ctrl, err := connectToM365(ctx, sel, r.Account) if err != nil { return operations.BackupOperation{}, errors.Wrap(err, "connecting to m365") } - ownerID, ownerName, err := gc.PopulateOwnerIDAndNamesFrom(ctx, sel.DiscreteOwner, ins) + ownerID, ownerName, err := ctrl.PopulateOwnerIDAndNamesFrom(ctx, sel.DiscreteOwner, ins) if err != nil { return operations.BackupOperation{}, errors.Wrap(err, "resolving resource owner details") } @@ -324,7 +325,7 @@ func (r repository) NewBackupWithLookup( r.Opts, r.dataLayer, store.NewKopiaStore(r.modelStore), - gc, + ctrl, r.Account, sel, sel, // the selector acts as an IDNamer for its discrete resource owner. @@ -338,7 +339,7 @@ func (r repository) NewRestore( sel selectors.Selector, restoreCfg control.RestoreConfig, ) (operations.RestoreOperation, error) { - gc, err := connectToM365(ctx, sel, r.Account) + ctrl, err := connectToM365(ctx, sel, r.Account) if err != nil { return operations.RestoreOperation{}, errors.Wrap(err, "connecting to m365") } @@ -348,7 +349,7 @@ func (r repository) NewRestore( r.Opts, r.dataLayer, store.NewKopiaStore(r.modelStore), - gc, + ctrl, r.Account, model.StableID(backupID), sel, @@ -623,12 +624,12 @@ func newRepoID(s storage.Storage) string { // helpers // --------------------------------------------------------------------------- -// produces a graph connector. +// produces a graph m365. func connectToM365( ctx context.Context, sel selectors.Selector, acct account.Account, -) (*connector.GraphConnector, error) { +) (*m365.Controller, error) { complete := observe.MessageWithCompletion(ctx, "Connecting to M365") defer func() { complete <- struct{}{} @@ -636,17 +637,17 @@ func connectToM365( }() // retrieve data from the producer - resource := connector.Users + rc := resource.Users if sel.Service == selectors.ServiceSharePoint { - resource = connector.Sites + rc = resource.Sites } - gc, err := connector.NewGraphConnector(ctx, acct, resource) + ctrl, err := m365.NewController(ctx, acct, rc) if err != nil { return nil, err } - return gc, nil + return ctrl, nil } func errWrapper(err error) error { diff --git a/src/pkg/selectors/onedrive_test.go b/src/pkg/selectors/onedrive_test.go index 1946fac28..aeb2f19cd 100644 --- a/src/pkg/selectors/onedrive_test.go +++ b/src/pkg/selectors/onedrive_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/dttm" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" diff --git a/src/pkg/selectors/sharepoint_test.go b/src/pkg/selectors/sharepoint_test.go index 93654f0e7..a8003951e 100644 --- a/src/pkg/selectors/sharepoint_test.go +++ b/src/pkg/selectors/sharepoint_test.go @@ -12,7 +12,7 @@ import ( "golang.org/x/exp/slices" "github.com/alcionai/corso/src/internal/common/dttm" - odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + odConsts "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" diff --git a/src/pkg/services/m365/api/client.go b/src/pkg/services/m365/api/client.go index ee546be75..338ce9c29 100644 --- a/src/pkg/services/m365/api/client.go +++ b/src/pkg/services/m365/api/client.go @@ -6,7 +6,7 @@ import ( "github.com/alcionai/clues" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/account" ) diff --git a/src/pkg/services/m365/api/client_test.go b/src/pkg/services/m365/api/client_test.go index 3fb248200..e2b0722a3 100644 --- a/src/pkg/services/m365/api/client_test.go +++ b/src/pkg/services/m365/api/client_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" ) diff --git a/src/pkg/services/m365/api/contacts.go b/src/pkg/services/m365/api/contacts.go index 2410e032a..fa52d8312 100644 --- a/src/pkg/services/m365/api/contacts.go +++ b/src/pkg/services/m365/api/contacts.go @@ -11,7 +11,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/users" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/selectors" diff --git a/src/pkg/services/m365/api/contacts_test.go b/src/pkg/services/m365/api/contacts_test.go index 13b5330cf..ddba9da87 100644 --- a/src/pkg/services/m365/api/contacts_test.go +++ b/src/pkg/services/m365/api/contacts_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" ) diff --git a/src/pkg/services/m365/api/drive.go b/src/pkg/services/m365/api/drive.go index f938e3263..478da708e 100644 --- a/src/pkg/services/m365/api/drive.go +++ b/src/pkg/services/m365/api/drive.go @@ -8,7 +8,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/drives" "github.com/microsoftgraph/msgraph-sdk-go/models" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" ) // --------------------------------------------------------------------------- diff --git a/src/pkg/services/m365/api/drive_pager.go b/src/pkg/services/m365/api/drive_pager.go index 8bb50ecab..8199dc8e8 100644 --- a/src/pkg/services/m365/api/drive_pager.go +++ b/src/pkg/services/m365/api/drive_pager.go @@ -12,8 +12,8 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/users" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - onedrive "github.com/alcionai/corso/src/internal/connector/onedrive/consts" + "github.com/alcionai/corso/src/internal/m365/graph" + onedrive "github.com/alcionai/corso/src/internal/m365/onedrive/consts" "github.com/alcionai/corso/src/pkg/logger" ) diff --git a/src/pkg/services/m365/api/events.go b/src/pkg/services/m365/api/events.go index b4af00fda..8f35481e2 100644 --- a/src/pkg/services/m365/api/events.go +++ b/src/pkg/services/m365/api/events.go @@ -15,7 +15,7 @@ import ( "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/pkg/services/m365/api/events_test.go b/src/pkg/services/m365/api/events_test.go index 9f185bacc..2daa66454 100644 --- a/src/pkg/services/m365/api/events_test.go +++ b/src/pkg/services/m365/api/events_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/dttm" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" ) diff --git a/src/pkg/services/m365/api/item_pager.go b/src/pkg/services/m365/api/item_pager.go index aaa3f2248..00a93ea13 100644 --- a/src/pkg/services/m365/api/item_pager.go +++ b/src/pkg/services/m365/api/item_pager.go @@ -8,7 +8,7 @@ import ( "github.com/alcionai/clues" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/logger" ) diff --git a/src/pkg/services/m365/api/item_pager_test.go b/src/pkg/services/m365/api/item_pager_test.go index b2fd90fdf..4c6dbfbeb 100644 --- a/src/pkg/services/m365/api/item_pager_test.go +++ b/src/pkg/services/m365/api/item_pager_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/internal/tester" ) diff --git a/src/pkg/services/m365/api/mail.go b/src/pkg/services/m365/api/mail.go index 34ce4b18f..8c7ca138c 100644 --- a/src/pkg/services/m365/api/mail.go +++ b/src/pkg/services/m365/api/mail.go @@ -13,7 +13,7 @@ import ( "github.com/microsoftgraph/msgraph-sdk-go/users" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" diff --git a/src/pkg/services/m365/api/mail_test.go b/src/pkg/services/m365/api/mail_test.go index 581dcd2b0..236bc9b4c 100644 --- a/src/pkg/services/m365/api/mail_test.go +++ b/src/pkg/services/m365/api/mail_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/common/ptr" - exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" + exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/backup/details" diff --git a/src/pkg/services/m365/api/mock/mail.go b/src/pkg/services/m365/api/mock/mail.go index b05cec1a4..8a71d1067 100644 --- a/src/pkg/services/m365/api/mock/mail.go +++ b/src/pkg/services/m365/api/mock/mail.go @@ -1,8 +1,8 @@ package mock import ( - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/graph/mock" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/graph/mock" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/services/m365/api" ) diff --git a/src/pkg/services/m365/api/sites.go b/src/pkg/services/m365/api/sites.go index fb7db5d20..d1f506cda 100644 --- a/src/pkg/services/m365/api/sites.go +++ b/src/pkg/services/m365/api/sites.go @@ -13,8 +13,8 @@ import ( "github.com/pkg/errors" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" - "github.com/alcionai/corso/src/internal/connector/graph/betasdk/sites" + "github.com/alcionai/corso/src/internal/m365/graph" + "github.com/alcionai/corso/src/internal/m365/graph/betasdk/sites" "github.com/alcionai/corso/src/pkg/fault" ) diff --git a/src/pkg/services/m365/api/users.go b/src/pkg/services/m365/api/users.go index fa1d29a36..908128579 100644 --- a/src/pkg/services/m365/api/users.go +++ b/src/pkg/services/m365/api/users.go @@ -12,7 +12,7 @@ import ( "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/path" diff --git a/src/pkg/services/m365/m365.go b/src/pkg/services/m365/m365.go index 697e34005..305a10bbf 100644 --- a/src/pkg/services/m365/m365.go +++ b/src/pkg/services/m365/m365.go @@ -8,8 +8,8 @@ import ( "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/common/ptr" - "github.com/alcionai/corso/src/internal/connector/discovery" - "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/m365/discovery" + "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/services/m365/api" @@ -251,7 +251,7 @@ type Site struct { func Sites(ctx context.Context, acct account.Account, errs *fault.Bus) ([]*Site, error) { sites, err := discovery.Sites(ctx, acct, errs) if err != nil { - return nil, clues.Wrap(err, "initializing M365 graph connection") + return nil, clues.Wrap(err, "initializing M365 api connection") } ret := make([]*Site, 0, len(sites))