rename graph.Service to Servicer (#1787)

## Description

`graph.Service -> graph.Servicer`,  no other changes.

More compliant with golang naming standards,
and will allow us to eventually migrate the
Service struct out of connector and into graph.

## Type of change

- [x] 🐹 Trivial/Minor

## Issue(s)

* #1725
This commit is contained in:
Keepers 2022-12-13 10:37:03 -07:00 committed by GitHub
parent 675712c14a
commit fc5f42545f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 94 additions and 94 deletions

View File

@ -93,7 +93,7 @@ func handleGetCommand(cmd *cobra.Command, args []string) error {
func runDisplayM365JSON( func runDisplayM365JSON(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
) error { ) error {
var ( var (
get exchange.GraphRetrievalFunc get exchange.GraphRetrievalFunc

View File

@ -150,7 +150,7 @@ func purgeOneDriveFolders(
boundary time.Time, boundary time.Time,
uid string, uid string,
) error { ) error {
getter := func(gs graph.Service, uid, prefix string) ([]purgable, error) { getter := func(gs graph.Servicer, uid, prefix string) ([]purgable, error) {
cfs, err := onedrive.GetAllFolders(ctx, gs, uid, prefix) cfs, err := onedrive.GetAllFolders(ctx, gs, uid, prefix)
if err != nil { if err != nil {
return nil, err return nil, err
@ -165,7 +165,7 @@ func purgeOneDriveFolders(
return purgables, nil return purgables, nil
} }
deleter := func(gs graph.Service, uid string, f purgable) error { deleter := func(gs graph.Servicer, uid string, f purgable) error {
driveFolder, ok := f.(*onedrive.Displayable) driveFolder, ok := f.(*onedrive.Displayable)
if !ok { if !ok {
return errors.New("non-OneDrive item") return errors.New("non-OneDrive item")
@ -189,8 +189,8 @@ func purgeFolders(
gc *connector.GraphConnector, gc *connector.GraphConnector,
boundary time.Time, boundary time.Time,
data, uid string, data, uid string,
getter func(graph.Service, string, string) ([]purgable, error), getter func(graph.Servicer, string, string) ([]purgable, error),
deleter func(graph.Service, string, purgable) error, deleter func(graph.Servicer, string, purgable) error,
) error { ) error {
Infof(ctx, "Container: %s", data) Infof(ctx, "Container: %s", data)

View File

@ -18,7 +18,7 @@ const (
userSelectDisplayName = "displayName" userSelectDisplayName = "displayName"
) )
func Users(ctx context.Context, gs graph.Service, tenantID string) ([]models.Userable, error) { func Users(ctx context.Context, gs graph.Servicer, tenantID string) ([]models.Userable, error) {
users := make([]models.Userable, 0) users := make([]models.Userable, 0)
options := &msuser.UsersRequestBuilderGetRequestConfiguration{ options := &msuser.UsersRequestBuilderGetRequestConfiguration{

View File

@ -29,7 +29,7 @@ type mailAttachmentUploader struct {
userID string userID string
folderID string folderID string
itemID string itemID string
service graph.Service service graph.Servicer
} }
func (mau *mailAttachmentUploader) getItemID() string { func (mau *mailAttachmentUploader) getItemID() string {
@ -77,7 +77,7 @@ type eventAttachmentUploader struct {
userID string userID string
calendarID string calendarID string
itemID string itemID string
service graph.Service service graph.Servicer
} }
func (eau *eventAttachmentUploader) getItemID() string { func (eau *eventAttachmentUploader) getItemID() string {

View File

@ -15,7 +15,7 @@ var _ graph.ContainerResolver = &contactFolderCache{}
type contactFolderCache struct { type contactFolderCache struct {
*containerResolver *containerResolver
gs graph.Service gs graph.Servicer
userID string userID string
} }

View File

@ -15,7 +15,7 @@ var _ graph.ContainerResolver = &eventCalendarCache{}
type eventCalendarCache struct { type eventCalendarCache struct {
*containerResolver *containerResolver
gs graph.Service gs graph.Servicer
userID string userID string
} }

View File

@ -53,7 +53,7 @@ type Collection struct {
// is desired to be sent through the data channel for eventual storage // is desired to be sent through the data channel for eventual storage
jobs []string jobs []string
// service - client/adapter pair used to access M365 back store // service - client/adapter pair used to access M365 back store
service graph.Service service graph.Servicer
collectionType optionIdentifier collectionType optionIdentifier
statusUpdater support.StatusUpdater statusUpdater support.StatusUpdater
@ -67,7 +67,7 @@ func NewCollection(
user string, user string,
fullPath path.Path, fullPath path.Path,
collectionType optionIdentifier, collectionType optionIdentifier,
service graph.Service, service graph.Servicer,
statusUpdater support.StatusUpdater, statusUpdater support.StatusUpdater,
) Collection { ) Collection {
collection := Collection{ collection := Collection{

View File

@ -324,7 +324,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
name string name string
bytes []byte bytes []byte
category path.CategoryType category path.CategoryType
cleanupFunc func(context.Context, graph.Service, string, string) error cleanupFunc func(context.Context, graph.Servicer, string, string) error
destination func(context.Context) string destination func(context.Context) string
}{ }{
{ {

View File

@ -13,7 +13,7 @@ import (
type CacheResolverSuite struct { type CacheResolverSuite struct {
suite.Suite suite.Suite
gs graph.Service gs graph.Servicer
} }
func TestCacheResolverIntegrationSuite(t *testing.T) { func TestCacheResolverIntegrationSuite(t *testing.T) {

View File

@ -19,7 +19,7 @@ var _ graph.ContainerResolver = &mailFolderCache{}
// nameLookup map: Key: DisplayName Value: ID // nameLookup map: Key: DisplayName Value: ID
type mailFolderCache struct { type mailFolderCache struct {
*containerResolver *containerResolver
gs graph.Service gs graph.Servicer
userID string userID string
} }

View File

@ -26,7 +26,7 @@ const (
type MailFolderCacheIntegrationSuite struct { type MailFolderCacheIntegrationSuite struct {
suite.Suite suite.Suite
gs graph.Service gs graph.Servicer
} }
func (suite *MailFolderCacheIntegrationSuite) SetupSuite() { func (suite *MailFolderCacheIntegrationSuite) SetupSuite() {

View File

@ -24,7 +24,7 @@ type exchangeService struct {
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
// Functions to comply with graph.Service Interface // Functions to comply with graph.Servicer Interface
// ------------------------------------------------------------ // ------------------------------------------------------------
func (es *exchangeService) Client() *msgraphsdk.GraphServiceClient { func (es *exchangeService) Client() *msgraphsdk.GraphServiceClient {
@ -64,7 +64,7 @@ func createService(credentials account.M365Config, shouldFailFast bool) (*exchan
// CreateMailFolder makes a mail folder iff a folder of the same name does not exist // CreateMailFolder makes a mail folder iff a folder of the same name does not exist
// Reference: https://docs.microsoft.com/en-us/graph/api/user-post-mailfolders?view=graph-rest-1.0&tabs=http // Reference: https://docs.microsoft.com/en-us/graph/api/user-post-mailfolders?view=graph-rest-1.0&tabs=http
func CreateMailFolder(ctx context.Context, gs graph.Service, user, folder string) (models.MailFolderable, error) { func CreateMailFolder(ctx context.Context, gs graph.Servicer, user, folder string) (models.MailFolderable, error) {
isHidden := false isHidden := false
requestBody := models.NewMailFolder() requestBody := models.NewMailFolder()
requestBody.SetDisplayName(&folder) requestBody.SetDisplayName(&folder)
@ -75,7 +75,7 @@ func CreateMailFolder(ctx context.Context, gs graph.Service, user, folder string
func CreateMailFolderWithParent( func CreateMailFolderWithParent(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
user, folder, parentID string, user, folder, parentID string,
) (models.MailFolderable, error) { ) (models.MailFolderable, error) {
isHidden := false isHidden := false
@ -92,13 +92,13 @@ func CreateMailFolderWithParent(
// DeleteMailFolder removes a mail folder with the corresponding M365 ID from the user's M365 Exchange account // DeleteMailFolder removes a mail folder with the corresponding M365 ID from the user's M365 Exchange account
// Reference: https://docs.microsoft.com/en-us/graph/api/mailfolder-delete?view=graph-rest-1.0&tabs=http // Reference: https://docs.microsoft.com/en-us/graph/api/mailfolder-delete?view=graph-rest-1.0&tabs=http
func DeleteMailFolder(ctx context.Context, gs graph.Service, user, folderID string) error { func DeleteMailFolder(ctx context.Context, gs graph.Servicer, user, folderID string) error {
return gs.Client().UsersById(user).MailFoldersById(folderID).Delete(ctx, nil) return gs.Client().UsersById(user).MailFoldersById(folderID).Delete(ctx, nil)
} }
// CreateCalendar makes an event Calendar with the name in the user's M365 exchange account // CreateCalendar makes an event Calendar with the name in the user's M365 exchange account
// Reference: https://docs.microsoft.com/en-us/graph/api/user-post-calendars?view=graph-rest-1.0&tabs=go // Reference: https://docs.microsoft.com/en-us/graph/api/user-post-calendars?view=graph-rest-1.0&tabs=go
func CreateCalendar(ctx context.Context, gs graph.Service, user, calendarName string) (models.Calendarable, error) { func CreateCalendar(ctx context.Context, gs graph.Servicer, user, calendarName string) (models.Calendarable, error) {
requestbody := models.NewCalendar() requestbody := models.NewCalendar()
requestbody.SetName(&calendarName) requestbody.SetName(&calendarName)
@ -107,7 +107,7 @@ func CreateCalendar(ctx context.Context, gs graph.Service, user, calendarName st
// DeleteCalendar removes calendar from user's M365 account // DeleteCalendar removes calendar from user's M365 account
// Reference: https://docs.microsoft.com/en-us/graph/api/calendar-delete?view=graph-rest-1.0&tabs=go // Reference: https://docs.microsoft.com/en-us/graph/api/calendar-delete?view=graph-rest-1.0&tabs=go
func DeleteCalendar(ctx context.Context, gs graph.Service, user, calendarID string) error { func DeleteCalendar(ctx context.Context, gs graph.Servicer, user, calendarID string) error {
return gs.Client().UsersById(user).CalendarsById(calendarID).Delete(ctx, nil) return gs.Client().UsersById(user).CalendarsById(calendarID).Delete(ctx, nil)
} }
@ -115,7 +115,7 @@ func DeleteCalendar(ctx context.Context, gs graph.Service, user, calendarID stri
// If successful, returns the created folder object. // If successful, returns the created folder object.
func CreateContactFolder( func CreateContactFolder(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
user, folderName string, user, folderName string,
) (models.ContactFolderable, error) { ) (models.ContactFolderable, error) {
requestBody := models.NewContactFolder() requestBody := models.NewContactFolder()
@ -127,7 +127,7 @@ func CreateContactFolder(
// DeleteContactFolder deletes the ContactFolder associated with the M365 ID if permissions are valid. // DeleteContactFolder deletes the ContactFolder associated with the M365 ID if permissions are valid.
// Errors returned if the function call was not successful. // Errors returned if the function call was not successful.
func DeleteContactFolder(ctx context.Context, gs graph.Service, user, folderID string) error { func DeleteContactFolder(ctx context.Context, gs graph.Servicer, user, folderID string) error {
return gs.Client().UsersById(user).ContactFoldersById(folderID).Delete(ctx, nil) return gs.Client().UsersById(user).ContactFoldersById(folderID).Delete(ctx, nil)
} }

View File

@ -213,7 +213,7 @@ func IterativeCollectCalendarContainers(
// container supports fetching delta records. // container supports fetching delta records.
type FetchIDFunc func( type FetchIDFunc func(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
user, containerID string, user, containerID string,
) ([]string, string, error) ) ([]string, string, error)
@ -233,7 +233,7 @@ func getFetchIDFunc(category path.CategoryType) (FetchIDFunc, error) {
// FetchEventIDsFromCalendar returns a list of all M365IDs of events of the targeted Calendar. // FetchEventIDsFromCalendar returns a list of all M365IDs of events of the targeted Calendar.
func FetchEventIDsFromCalendar( func FetchEventIDsFromCalendar(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
user, calendarID string, user, calendarID string,
) ([]string, string, error) { ) ([]string, string, error) {
var ( var (
@ -287,7 +287,7 @@ func FetchEventIDsFromCalendar(
// of the targeted directory // of the targeted directory
func FetchContactIDsFromDirectory( func FetchContactIDsFromDirectory(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
user, directoryID string, user, directoryID string,
) ([]string, string, error) { ) ([]string, string, error) {
var ( var (
@ -347,7 +347,7 @@ func FetchContactIDsFromDirectory(
// of the targeted directory // of the targeted directory
func FetchMessageIDsFromDirectory( func FetchMessageIDsFromDirectory(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
user, directoryID string, user, directoryID string,
) ([]string, string, error) { ) ([]string, string, error) {
var ( var (

View File

@ -12,10 +12,10 @@ import (
// into M365 backstore. Responses -> returned items will only contain the information // into M365 backstore. Responses -> returned items will only contain the information
// that is included in the options // that is included in the options
// TODO: use selector or path for granularity into specific folders or specific date ranges // TODO: use selector or path for granularity into specific folders or specific date ranges
type GraphQuery func(ctx context.Context, gs graph.Service, userID string) (absser.Parsable, error) type GraphQuery func(ctx context.Context, gs graph.Servicer, userID string) (absser.Parsable, error)
// GetAllContactsForUser is a GraphQuery function for querying all the contacts in a user's account // GetAllContactsForUser is a GraphQuery function for querying all the contacts in a user's account
func GetAllContactsForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) { func GetAllContactsForUser(ctx context.Context, gs graph.Servicer, user string) (absser.Parsable, error) {
selecting := []string{"parentFolderId"} selecting := []string{"parentFolderId"}
options, err := optionsForContacts(selecting) options, err := optionsForContacts(selecting)
@ -28,7 +28,7 @@ func GetAllContactsForUser(ctx context.Context, gs graph.Service, user string) (
// GetAllFolderDisplayNamesForUser is a GraphQuery function for getting FolderId and display // GetAllFolderDisplayNamesForUser is a GraphQuery function for getting FolderId and display
// names for Mail Folder. All other information for the MailFolder object is omitted. // names for Mail Folder. All other information for the MailFolder object is omitted.
func GetAllFolderNamesForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) { func GetAllFolderNamesForUser(ctx context.Context, gs graph.Servicer, user string) (absser.Parsable, error) {
options, err := optionsForMailFolders([]string{"displayName"}) options, err := optionsForMailFolders([]string{"displayName"})
if err != nil { if err != nil {
return nil, err return nil, err
@ -37,7 +37,7 @@ func GetAllFolderNamesForUser(ctx context.Context, gs graph.Service, user string
return gs.Client().UsersById(user).MailFolders().Get(ctx, options) return gs.Client().UsersById(user).MailFolders().Get(ctx, options)
} }
func GetAllCalendarNamesForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) { func GetAllCalendarNamesForUser(ctx context.Context, gs graph.Servicer, user string) (absser.Parsable, error) {
options, err := optionsForCalendars([]string{"name", "owner"}) options, err := optionsForCalendars([]string{"name", "owner"})
if err != nil { if err != nil {
return nil, err return nil, err
@ -49,7 +49,7 @@ func GetAllCalendarNamesForUser(ctx context.Context, gs graph.Service, user stri
// GetDefaultContactFolderForUser is a GraphQuery function for getting the ContactFolderId // GetDefaultContactFolderForUser is a GraphQuery function for getting the ContactFolderId
// and display names for the default "Contacts" folder. // and display names for the default "Contacts" folder.
// Only returns the default Contact Folder // Only returns the default Contact Folder
func GetDefaultContactFolderForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) { func GetDefaultContactFolderForUser(ctx context.Context, gs graph.Servicer, user string) (absser.Parsable, error) {
options, err := optionsForContactChildFolders([]string{"displayName", "parentFolderId"}) options, err := optionsForContactChildFolders([]string{"displayName", "parentFolderId"})
if err != nil { if err != nil {
return nil, err return nil, err
@ -65,7 +65,7 @@ func GetDefaultContactFolderForUser(ctx context.Context, gs graph.Service, user
// GetAllContactFolderNamesForUser is a GraphQuery function for getting ContactFolderId // GetAllContactFolderNamesForUser is a GraphQuery function for getting ContactFolderId
// and display names for contacts. All other information is omitted. // and display names for contacts. All other information is omitted.
// Does not return the default Contact Folder // Does not return the default Contact Folder
func GetAllContactFolderNamesForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) { func GetAllContactFolderNamesForUser(ctx context.Context, gs graph.Servicer, user string) (absser.Parsable, error) {
options, err := optionsForContactFolders([]string{"displayName", "parentFolderId"}) options, err := optionsForContactFolders([]string{"displayName", "parentFolderId"})
if err != nil { if err != nil {
return nil, err return nil, err
@ -77,7 +77,7 @@ func GetAllContactFolderNamesForUser(ctx context.Context, gs graph.Service, user
// GetAllEvents for User. Default returns EventResponseCollection for future events. // GetAllEvents for User. Default returns EventResponseCollection for future events.
// of the time that the call was made. 'calendar' option must be present to gain // of the time that the call was made. 'calendar' option must be present to gain
// access to additional data map in future calls. // access to additional data map in future calls.
func GetAllEventsForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) { func GetAllEventsForUser(ctx context.Context, gs graph.Servicer, user string) (absser.Parsable, error) {
options, err := optionsForEvents([]string{"id", "calendar"}) options, err := optionsForEvents([]string{"id", "calendar"})
if err != nil { if err != nil {
return nil, err return nil, err
@ -89,21 +89,21 @@ func GetAllEventsForUser(ctx context.Context, gs graph.Service, user string) (ab
// GraphRetrievalFunctions are functions from the Microsoft Graph API that retrieve // GraphRetrievalFunctions are functions from the Microsoft Graph API that retrieve
// the default associated data of a M365 object. This varies by object. Additional // the default associated data of a M365 object. This varies by object. Additional
// Queries must be run to obtain the omitted fields. // Queries must be run to obtain the omitted fields.
type GraphRetrievalFunc func(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error) type GraphRetrievalFunc func(ctx context.Context, gs graph.Servicer, user, m365ID string) (absser.Parsable, error)
// RetrieveContactDataForUser is a GraphRetrievalFun that returns all associated fields. // RetrieveContactDataForUser is a GraphRetrievalFun that returns all associated fields.
func RetrieveContactDataForUser(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error) { func RetrieveContactDataForUser(ctx context.Context, gs graph.Servicer, user, m365ID string) (absser.Parsable, error) {
return gs.Client().UsersById(user).ContactsById(m365ID).Get(ctx, nil) return gs.Client().UsersById(user).ContactsById(m365ID).Get(ctx, nil)
} }
// RetrieveEventDataForUser is a GraphRetrievalFunc that returns event data. // RetrieveEventDataForUser is a GraphRetrievalFunc that returns event data.
// Calendarable and attachment fields are omitted due to size // Calendarable and attachment fields are omitted due to size
func RetrieveEventDataForUser(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error) { func RetrieveEventDataForUser(ctx context.Context, gs graph.Servicer, user, m365ID string) (absser.Parsable, error) {
return gs.Client().UsersById(user).EventsById(m365ID).Get(ctx, nil) return gs.Client().UsersById(user).EventsById(m365ID).Get(ctx, nil)
} }
// RetrieveMessageDataForUser is a GraphRetrievalFunc that returns message data. // RetrieveMessageDataForUser is a GraphRetrievalFunc that returns message data.
// Attachment field is omitted due to size. // Attachment field is omitted due to size.
func RetrieveMessageDataForUser(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error) { func RetrieveMessageDataForUser(ctx context.Context, gs graph.Servicer, user, m365ID string) (absser.Parsable, error) {
return gs.Client().UsersById(user).MessagesById(m365ID).Get(ctx, nil) return gs.Client().UsersById(user).MessagesById(m365ID).Get(ctx, nil)
} }

View File

@ -30,7 +30,7 @@ func RestoreExchangeObject(
bits []byte, bits []byte,
category path.CategoryType, category path.CategoryType,
policy control.CollisionPolicy, policy control.CollisionPolicy,
service graph.Service, service graph.Servicer,
destination, user string, destination, user string,
) (*details.ExchangeInfo, error) { ) (*details.ExchangeInfo, error) {
if policy != control.Copy { if policy != control.Copy {
@ -60,7 +60,7 @@ func RestoreExchangeObject(
func RestoreExchangeContact( func RestoreExchangeContact(
ctx context.Context, ctx context.Context,
bits []byte, bits []byte,
service graph.Service, service graph.Servicer,
cp control.CollisionPolicy, cp control.CollisionPolicy,
destination, user string, destination, user string,
) (*details.ExchangeInfo, error) { ) (*details.ExchangeInfo, error) {
@ -96,7 +96,7 @@ func RestoreExchangeContact(
func RestoreExchangeEvent( func RestoreExchangeEvent(
ctx context.Context, ctx context.Context,
bits []byte, bits []byte,
service graph.Service, service graph.Servicer,
cp control.CollisionPolicy, cp control.CollisionPolicy,
destination, user string, destination, user string,
) (*details.ExchangeInfo, error) { ) (*details.ExchangeInfo, error) {
@ -165,7 +165,7 @@ func RestoreExchangeEvent(
func RestoreMailMessage( func RestoreMailMessage(
ctx context.Context, ctx context.Context,
bits []byte, bits []byte,
service graph.Service, service graph.Servicer,
cp control.CollisionPolicy, cp control.CollisionPolicy,
destination, user string, destination, user string,
) (*details.ExchangeInfo, error) { ) (*details.ExchangeInfo, error) {
@ -230,7 +230,7 @@ func attachmentBytes(attachment models.Attachmentable) []byte {
// @param message is a models.Messageable interface from "github.com/microsoftgraph/msgraph-sdk-go/models" // @param message is a models.Messageable interface from "github.com/microsoftgraph/msgraph-sdk-go/models"
func SendMailToBackStore( func SendMailToBackStore(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
user, destination string, user, destination string,
message models.Messageable, message models.Messageable,
) error { ) error {
@ -285,7 +285,7 @@ func SendMailToBackStore(
// @param dest: container destination to M365 // @param dest: container destination to M365
func RestoreExchangeDataCollections( func RestoreExchangeDataCollections(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
dest control.RestoreDestination, dest control.RestoreDestination,
dcs []data.Collection, dcs []data.Collection,
deets *details.Details, deets *details.Details,
@ -345,7 +345,7 @@ func RestoreExchangeDataCollections(
// restoreCollection handles restoration of an individual collection. // restoreCollection handles restoration of an individual collection.
func restoreCollection( func restoreCollection(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
dc data.Collection, dc data.Collection,
folderID string, folderID string,
policy control.CollisionPolicy, policy control.CollisionPolicy,
@ -429,7 +429,7 @@ func restoreCollection(
// Assumption: collisionPolicy == COPY // Assumption: collisionPolicy == COPY
func GetContainerIDFromCache( func GetContainerIDFromCache(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
directory path.Path, directory path.Path,
destination string, destination string,
caches map[path.CategoryType]graph.ContainerResolver, caches map[path.CategoryType]graph.ContainerResolver,
@ -514,7 +514,7 @@ func establishMailRestoreLocation(
folders []string, folders []string,
mfc graph.ContainerResolver, mfc graph.ContainerResolver,
user string, user string,
service graph.Service, service graph.Servicer,
isNewCache bool, isNewCache bool,
) (string, error) { ) (string, error) {
// Process starts with the root folder in order to recreate // Process starts with the root folder in order to recreate
@ -571,7 +571,7 @@ func establishContactsRestoreLocation(
folders []string, folders []string,
cfc graph.ContainerResolver, cfc graph.ContainerResolver,
user string, user string,
gs graph.Service, gs graph.Servicer,
isNewCache bool, isNewCache bool,
) (string, error) { ) (string, error) {
cached, ok := cfc.PathInCache(folders[0]) cached, ok := cfc.PathInCache(folders[0])
@ -604,7 +604,7 @@ func establishEventsRestoreLocation(
folders []string, folders []string,
ecc graph.ContainerResolver, // eventCalendarCache ecc graph.ContainerResolver, // eventCalendarCache
user string, user string,
gs graph.Service, gs graph.Servicer,
isNewCache bool, isNewCache bool,
) (string, error) { ) (string, error) {
cached, ok := ecc.PathInCache(folders[0]) cached, ok := ecc.PathInCache(folders[0])

View File

@ -26,7 +26,7 @@ type QueryParams struct {
FailFast bool FailFast bool
} }
type Service interface { type Servicer interface {
// Client() returns msgraph Service client that can be used to process and execute // Client() returns msgraph Service client that can be used to process and execute
// the majority of the queries to the M365 Backstore // the majority of the queries to the M365 Backstore
Client() *msgraphsdk.GraphServiceClient Client() *msgraphsdk.GraphServiceClient

View File

@ -52,12 +52,12 @@ type GraphConnector struct {
status support.ConnectorOperationStatus // contains the status of the last run status status support.ConnectorOperationStatus // contains the status of the last run status
} }
// Service returns the GC's embedded graph.Service // Service returns the GC's embedded graph.Servicer
func (gc *GraphConnector) Service() graph.Service { func (gc *GraphConnector) Service() graph.Servicer {
return gc.graphService return gc.graphService
} }
var _ graph.Service = &graphService{} var _ graph.Servicer = &graphService{}
type graphService struct { type graphService struct {
client msgraphsdk.GraphServiceClient client msgraphsdk.GraphServiceClient
@ -380,9 +380,9 @@ func (gc *GraphConnector) incrementAwaitingMessages() {
func getResources( func getResources(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
tenantID string, tenantID string,
query func(context.Context, graph.Service) (serialization.Parsable, error), query func(context.Context, graph.Servicer) (serialization.Parsable, error),
parser func(parseNode serialization.ParseNode) (serialization.Parsable, error), parser func(parseNode serialization.ParseNode) (serialization.Parsable, error),
identify func(any) (string, string, error), identify func(any) (string, string, error),
) (map[string]string, error) { ) (map[string]string, error) {

View File

@ -284,7 +284,7 @@ func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() {
func mustGetDefaultDriveID( func mustGetDefaultDriveID(
t *testing.T, t *testing.T,
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
userID string, userID string,
) string { ) string {
//revive:enable:context-as-argument //revive:enable:context-as-argument

View File

@ -51,7 +51,7 @@ type Collection struct {
// M365 ID of the drive this collection was created from // M365 ID of the drive this collection was created from
driveID string driveID string
source driveSource source driveSource
service graph.Service service graph.Servicer
statusUpdater support.StatusUpdater statusUpdater support.StatusUpdater
itemReader itemReaderFunc itemReader itemReaderFunc
} }
@ -59,7 +59,7 @@ type Collection struct {
// itemReadFunc returns a reader for the specified item // itemReadFunc returns a reader for the specified item
type itemReaderFunc func( type itemReaderFunc func(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID, itemID string, driveID, itemID string,
) (itemInfo details.ItemInfo, itemData io.ReadCloser, err error) ) (itemInfo details.ItemInfo, itemData io.ReadCloser, err error)
@ -67,7 +67,7 @@ type itemReaderFunc func(
func NewCollection( func NewCollection(
folderPath path.Path, folderPath path.Path,
driveID string, driveID string,
service graph.Service, service graph.Servicer,
statusUpdater support.StatusUpdater, statusUpdater support.StatusUpdater,
source driveSource, source driveSource,
) *Collection { ) *Collection {

View File

@ -23,7 +23,7 @@ type CollectionUnitTestSuite struct {
suite.Suite suite.Suite
} }
// Allows `*CollectionUnitTestSuite` to be used as a graph.Service // Allows `*CollectionUnitTestSuite` to be used as a graph.Servicer
// TODO: Implement these methods // TODO: Implement these methods
func (suite *CollectionUnitTestSuite) Client() *msgraphsdk.GraphServiceClient { func (suite *CollectionUnitTestSuite) Client() *msgraphsdk.GraphServiceClient {
@ -71,7 +71,7 @@ func (suite *CollectionUnitTestSuite) TestCollection() {
{ {
name: "oneDrive", name: "oneDrive",
source: OneDriveSource, source: OneDriveSource,
itemReader: func(context.Context, graph.Service, string, string) (details.ItemInfo, io.ReadCloser, error) { itemReader: func(context.Context, graph.Servicer, string, string) (details.ItemInfo, io.ReadCloser, error) {
return details.ItemInfo{OneDrive: &details.OneDriveInfo{ItemName: testItemName}}, return details.ItemInfo{OneDrive: &details.OneDriveInfo{ItemName: testItemName}},
io.NopCloser(bytes.NewReader(testItemData)), io.NopCloser(bytes.NewReader(testItemData)),
nil nil
@ -84,7 +84,7 @@ func (suite *CollectionUnitTestSuite) TestCollection() {
{ {
name: "sharePoint", name: "sharePoint",
source: SharePointSource, source: SharePointSource,
itemReader: func(context.Context, graph.Service, string, string) (details.ItemInfo, io.ReadCloser, error) { itemReader: func(context.Context, graph.Servicer, string, string) (details.ItemInfo, io.ReadCloser, error) {
return details.ItemInfo{SharePoint: &details.SharePointInfo{ItemName: testItemName}}, return details.ItemInfo{SharePoint: &details.SharePointInfo{ItemName: testItemName}},
io.NopCloser(bytes.NewReader(testItemData)), io.NopCloser(bytes.NewReader(testItemData)),
nil nil
@ -178,7 +178,7 @@ func (suite *CollectionUnitTestSuite) TestCollectionReadError() {
readError := errors.New("Test error") readError := errors.New("Test error")
coll.itemReader = func(context.Context, graph.Service, string, string) (details.ItemInfo, io.ReadCloser, error) { coll.itemReader = func(context.Context, graph.Servicer, string, string) (details.ItemInfo, io.ReadCloser, error) {
return details.ItemInfo{}, nil, readError return details.ItemInfo{}, nil, readError
} }

View File

@ -36,7 +36,7 @@ type Collections struct {
resourceOwner string resourceOwner string
source driveSource source driveSource
matcher folderMatcher matcher folderMatcher
service graph.Service service graph.Servicer
statusUpdater support.StatusUpdater statusUpdater support.StatusUpdater
// collectionMap allows lookup of the data.Collection // collectionMap allows lookup of the data.Collection
@ -54,7 +54,7 @@ func NewCollections(
resourceOwner string, resourceOwner string,
source driveSource, source driveSource,
matcher folderMatcher, matcher folderMatcher,
service graph.Service, service graph.Servicer,
statusUpdater support.StatusUpdater, statusUpdater support.StatusUpdater,
) *Collections { ) *Collections {
return &Collections{ return &Collections{

View File

@ -69,7 +69,7 @@ const (
// Enumerates the drives for the specified user // Enumerates the drives for the specified user
func drives( func drives(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
resourceOwner string, resourceOwner string,
source driveSource, source driveSource,
) ([]models.Driveable, error) { ) ([]models.Driveable, error) {
@ -83,7 +83,7 @@ func drives(
} }
} }
func siteDrives(ctx context.Context, service graph.Service, site string) ([]models.Driveable, error) { func siteDrives(ctx context.Context, service graph.Servicer, site string) ([]models.Driveable, error) {
options := &sites.SitesItemDrivesRequestBuilderGetRequestConfiguration{ options := &sites.SitesItemDrivesRequestBuilderGetRequestConfiguration{
QueryParameters: &sites.SitesItemDrivesRequestBuilderGetQueryParameters{ QueryParameters: &sites.SitesItemDrivesRequestBuilderGetQueryParameters{
Select: []string{"id", "name", "weburl", "system"}, Select: []string{"id", "name", "weburl", "system"},
@ -99,7 +99,7 @@ func siteDrives(ctx context.Context, service graph.Service, site string) ([]mode
return r.GetValue(), nil return r.GetValue(), nil
} }
func userDrives(ctx context.Context, service graph.Service, user string) ([]models.Driveable, error) { func userDrives(ctx context.Context, service graph.Servicer, user string) ([]models.Driveable, error) {
var hasDrive bool var hasDrive bool
hasDrive, err := hasDriveLicense(ctx, service, user) hasDrive, err := hasDriveLicense(ctx, service, user)
@ -135,7 +135,7 @@ type itemCollector func(ctx context.Context, driveID string, driveItems []models
// provided `collector` method // provided `collector` method
func collectItems( func collectItems(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID string, driveID string,
collector itemCollector, collector itemCollector,
) error { ) error {
@ -175,7 +175,7 @@ func collectItems(
// getFolder will lookup the specified folder name under `parentFolderID` // getFolder will lookup the specified folder name under `parentFolderID`
func getFolder( func getFolder(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID, parentFolderID, folderName string, driveID, parentFolderID, folderName string,
) (models.DriveItemable, error) { ) (models.DriveItemable, error) {
// The `Children().Get()` API doesn't yet support $filter, so using that to find a folder // The `Children().Get()` API doesn't yet support $filter, so using that to find a folder
@ -215,7 +215,7 @@ func getFolder(
// Create a new item in the specified folder // Create a new item in the specified folder
func createItem( func createItem(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID, parentFolderID string, driveID, parentFolderID string,
newItem models.DriveItemable, newItem models.DriveItemable,
) (models.DriveItemable, error) { ) (models.DriveItemable, error) {
@ -264,7 +264,7 @@ func (op *Displayable) GetDisplayName() *string {
// are a subfolder or top-level folder in the hierarchy. // are a subfolder or top-level folder in the hierarchy.
func GetAllFolders( func GetAllFolders(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
userID string, userID string,
prefix string, prefix string,
) ([]*Displayable, error) { ) ([]*Displayable, error) {
@ -325,7 +325,7 @@ func GetAllFolders(
func DeleteItem( func DeleteItem(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
driveID string, driveID string,
itemID string, itemID string,
) error { ) error {
@ -341,7 +341,7 @@ func DeleteItem(
// to investigate the user's includes access to OneDrive. // to investigate the user's includes access to OneDrive.
func hasDriveLicense( func hasDriveLicense(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
user string, user string,
) (bool, error) { ) (bool, error) {
var hasDrive bool var hasDrive bool

View File

@ -26,7 +26,7 @@ const (
// and using a http client to initialize a reader // and using a http client to initialize a reader
func sharePointItemReader( func sharePointItemReader(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID, itemID string, driveID, itemID string,
) (details.ItemInfo, io.ReadCloser, error) { ) (details.ItemInfo, io.ReadCloser, error) {
item, rc, err := driveItemReader(ctx, service, driveID, itemID) item, rc, err := driveItemReader(ctx, service, driveID, itemID)
@ -46,7 +46,7 @@ func sharePointItemReader(
// and using a http client to initialize a reader // and using a http client to initialize a reader
func oneDriveItemReader( func oneDriveItemReader(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID, itemID string, driveID, itemID string,
) (details.ItemInfo, io.ReadCloser, error) { ) (details.ItemInfo, io.ReadCloser, error) {
item, rc, err := driveItemReader(ctx, service, driveID, itemID) item, rc, err := driveItemReader(ctx, service, driveID, itemID)
@ -66,7 +66,7 @@ func oneDriveItemReader(
// and using a http client to initialize a reader // and using a http client to initialize a reader
func driveItemReader( func driveItemReader(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID, itemID string, driveID, itemID string,
) (models.DriveItemable, io.ReadCloser, error) { ) (models.DriveItemable, io.ReadCloser, error) {
logger.Ctx(ctx).Debugw("Reading Item", "id", itemID, "time", time.Now()) logger.Ctx(ctx).Debugw("Reading Item", "id", itemID, "time", time.Now())
@ -161,7 +161,7 @@ func sharePointItemInfo(di models.DriveItemable, itemSize int64) *details.ShareP
// TODO: @vkamra verify if var session is the desired input // TODO: @vkamra verify if var session is the desired input
func driveItemWriter( func driveItemWriter(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
driveID, itemID string, driveID, itemID string,
itemSize int64, itemSize int64,
) (io.Writer, error) { ) (io.Writer, error) {

View File

@ -50,7 +50,7 @@ func toOneDrivePath(p path.Path) (*drivePath, error) {
// RestoreCollections will restore the specified data collections into OneDrive // RestoreCollections will restore the specified data collections into OneDrive
func RestoreCollections( func RestoreCollections(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
dest control.RestoreDestination, dest control.RestoreDestination,
dcs []data.Collection, dcs []data.Collection,
deets *details.Details, deets *details.Details,
@ -91,7 +91,7 @@ func RestoreCollections(
// - the context cancellation state (true if the context is cancelled) // - the context cancellation state (true if the context is cancelled)
func RestoreCollection( func RestoreCollection(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
dc data.Collection, dc data.Collection,
source driveSource, source driveSource,
restoreContainerName string, restoreContainerName string,
@ -180,7 +180,7 @@ func RestoreCollection(
// createRestoreFolders creates the restore folder hieararchy in the specified drive and returns the folder ID // createRestoreFolders creates the restore folder hieararchy in the specified drive and returns the folder ID
// of the last folder entry in the hiearchy // of the last folder entry in the hiearchy
func createRestoreFolders(ctx context.Context, service graph.Service, driveID string, restoreFolders []string, func createRestoreFolders(ctx context.Context, service graph.Servicer, driveID string, restoreFolders []string,
) (string, error) { ) (string, error) {
driveRoot, err := service.Client().DrivesById(driveID).Root().Get(ctx, nil) driveRoot, err := service.Client().DrivesById(driveID).Root().Get(ctx, nil)
if err != nil { if err != nil {
@ -226,7 +226,7 @@ func createRestoreFolders(ctx context.Context, service graph.Service, driveID st
// restoreItem will create a new item in the specified `parentFolderID` and upload the data.Stream // restoreItem will create a new item in the specified `parentFolderID` and upload the data.Stream
func restoreItem( func restoreItem(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
itemData data.Stream, itemData data.Stream,
driveID, parentFolderID string, driveID, parentFolderID string,
copyBuffer []byte, copyBuffer []byte,

View File

@ -40,13 +40,13 @@ type Collection struct {
// fullPath indicates the hierarchy within the collection // fullPath indicates the hierarchy within the collection
fullPath path.Path fullPath path.Path
// M365 IDs of the items of this collection // M365 IDs of the items of this collection
service graph.Service service graph.Servicer
statusUpdater support.StatusUpdater statusUpdater support.StatusUpdater
} }
func NewCollection( func NewCollection(
folderPath path.Path, folderPath path.Path,
service graph.Service, service graph.Servicer,
statusUpdater support.StatusUpdater, statusUpdater support.StatusUpdater,
) *Collection { ) *Collection {
c := &Collection{ c := &Collection{

View File

@ -23,7 +23,7 @@ type statusUpdater interface {
type connector interface { type connector interface {
statusUpdater statusUpdater
Service() graph.Service Service() graph.Servicer
} }
// DataCollections returns a set of DataCollection which represents the SharePoint data // DataCollections returns a set of DataCollection which represents the SharePoint data
@ -89,7 +89,7 @@ func DataCollections(
// all the drives associated with the site. // all the drives associated with the site.
func collectLibraries( func collectLibraries(
ctx context.Context, ctx context.Context,
serv graph.Service, serv graph.Servicer,
tenantID, siteID string, tenantID, siteID string,
scope selectors.SharePointScope, scope selectors.SharePointScope,
updater statusUpdater, updater statusUpdater,

View File

@ -26,7 +26,7 @@ import (
// - List Items // - List Items
func loadLists( func loadLists(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
siteID string, siteID string,
) ([]models.Listable, error) { ) ([]models.Listable, error) {
var ( var (
@ -92,7 +92,7 @@ func loadLists(
// * Fields // * Fields
func fetchListItems( func fetchListItems(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
siteID, listID string, siteID, listID string,
) ([]models.ListItemable, error) { ) ([]models.ListItemable, error) {
var ( var (
@ -141,7 +141,7 @@ func fetchListItems(
// TODO: Refactor on if/else (dadams39) // TODO: Refactor on if/else (dadams39)
func fetchColumns( func fetchColumns(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
siteID, listID, cTypeID string, siteID, listID, cTypeID string,
) ([]models.ColumnDefinitionable, error) { ) ([]models.ColumnDefinitionable, error) {
cs := make([]models.ColumnDefinitionable, 0) cs := make([]models.ColumnDefinitionable, 0)
@ -198,7 +198,7 @@ func fetchColumns(
// TODO: Verify functionality after version upgrade or remove (dadams39) Check Stubs // TODO: Verify functionality after version upgrade or remove (dadams39) Check Stubs
func fetchContentTypes( func fetchContentTypes(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
siteID, listID string, siteID, listID string,
) ([]models.ContentTypeable, error) { ) ([]models.ContentTypeable, error) {
var ( var (
@ -252,7 +252,7 @@ func fetchContentTypes(
func fetchColumnLinks( func fetchColumnLinks(
ctx context.Context, ctx context.Context,
gs graph.Service, gs graph.Servicer,
siteID, listID, cTypeID string, siteID, listID, cTypeID string,
) ([]models.ColumnLinkable, error) { ) ([]models.ColumnLinkable, error) {
var ( var (

View File

@ -12,7 +12,7 @@ import (
// GetAllSitesForTenant makes a GraphQuery request retrieving all sites in the tenant. // GetAllSitesForTenant makes a GraphQuery request retrieving all sites in the tenant.
// Due to restrictions in filter capabilities for site queries, the returned iterable // Due to restrictions in filter capabilities for site queries, the returned iterable
// will contain all personal sites for all users in the org. // will contain all personal sites for all users in the org.
func GetAllSitesForTenant(ctx context.Context, gs graph.Service) (absser.Parsable, error) { func GetAllSitesForTenant(ctx context.Context, gs graph.Servicer) (absser.Parsable, error) {
options := &mssite.SitesRequestBuilderGetRequestConfiguration{ options := &mssite.SitesRequestBuilderGetRequestConfiguration{
QueryParameters: &mssite.SitesRequestBuilderGetQueryParameters{ QueryParameters: &mssite.SitesRequestBuilderGetQueryParameters{
Select: []string{"id", "name", "weburl"}, Select: []string{"id", "name", "weburl"},

View File

@ -17,7 +17,7 @@ import (
// RestoreCollections will restore the specified data collections into OneDrive // RestoreCollections will restore the specified data collections into OneDrive
func RestoreCollections( func RestoreCollections(
ctx context.Context, ctx context.Context,
service graph.Service, service graph.Servicer,
dest control.RestoreDestination, dest control.RestoreDestination,
dcs []data.Collection, dcs []data.Collection,
deets *details.Details, deets *details.Details,