1. moves the m365/graph package from internal to pkg/services/api so that options are accessible to sdk users. 2. exposes graph.Options in the api client.Service call. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🌻 Feature
42 lines
967 B
Go
42 lines
967 B
Go
package onedrive
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/alcionai/clues"
|
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
|
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
|
)
|
|
|
|
type getDefaultDriver interface {
|
|
GetDefaultDrive(ctx context.Context, userID string) (models.Driveable, error)
|
|
}
|
|
|
|
func IsServiceEnabled(
|
|
ctx context.Context,
|
|
gdd getDefaultDriver,
|
|
resource string,
|
|
) (bool, error) {
|
|
_, err := gdd.GetDefaultDrive(ctx, resource)
|
|
if err != nil {
|
|
// we consider this a non-error case, since it
|
|
// answers the question the caller is asking.
|
|
if clues.HasLabel(err, graph.LabelsMysiteNotFound) || clues.HasLabel(err, graph.LabelsNoSharePointLicense) {
|
|
return false, nil
|
|
}
|
|
|
|
if graph.IsErrUserNotFound(err) {
|
|
return false, clues.Stack(graph.ErrResourceOwnerNotFound, err)
|
|
}
|
|
|
|
if graph.IsErrResourceLocked(err) {
|
|
return false, clues.Stack(graph.ErrResourceLocked, err)
|
|
}
|
|
|
|
return false, clues.Stack(err)
|
|
}
|
|
|
|
return true, nil
|
|
}
|