Bump msgraph deps to 1.0.0 (#3345)
Bumps ms graph and all dependent libs to 1.0.0 *Still can't drop betasdk as `models.SitePageable` is still not available.* --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * Closes https://github.com/alcionai/corso/pull/3327 * Closes https://github.com/alcionai/corso/pull/3326 * Closes https://github.com/alcionai/corso/pull/3324 * Closes https://github.com/alcionai/corso/pull/3323 * Closes https://github.com/alcionai/corso/pull/3322 * Closes https://github.com/alcionai/corso/pull/3321 * Closes https://github.com/alcionai/corso/pull/3320 * Closes https://github.com/alcionai/corso/issues/3354 #### Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
6febc3ce5b
commit
67e055360d
@ -233,14 +233,14 @@ func generateAndRestoreDriveItems(
|
||||
|
||||
switch service {
|
||||
case path.SharePointService:
|
||||
d, err := gc.Service.Client().SitesById(resourceOwner).Drive().Get(ctx, nil)
|
||||
d, err := gc.Service.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.Service.Client().UsersById(resourceOwner).Drive().Get(ctx, nil)
|
||||
d, err := gc.Service.Client().Users().ByUserId(resourceOwner).Drive().Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, clues.Wrap(err, "getting user's default drive")
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ func checkEmailRestoration(
|
||||
restoreFolder models.MailFolderable
|
||||
itemCount = make(map[string]int32)
|
||||
restoreItemCount = make(map[string]int32)
|
||||
builder = client.UsersById(testUser).MailFolders()
|
||||
builder = client.Users().ByUserId(testUser).MailFolders()
|
||||
)
|
||||
|
||||
for {
|
||||
@ -152,8 +152,10 @@ func checkEmailRestoration(
|
||||
"restore_folder_name", folderName)
|
||||
|
||||
childFolder, err := client.
|
||||
UsersById(testUser).
|
||||
MailFoldersById(folderID).
|
||||
Users().
|
||||
ByUserId(testUser).
|
||||
MailFolders().
|
||||
ByMailFolderId(folderID).
|
||||
ChildFolders().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -213,8 +215,10 @@ func getAllMailSubFolders(
|
||||
ctx = clues.Add(ctx, "parent_folder_id", folderID)
|
||||
|
||||
childFolder, err := client.
|
||||
UsersById(testUser).
|
||||
MailFoldersById(folderID).
|
||||
Users().
|
||||
ByUserId(testUser).
|
||||
MailFolders().
|
||||
ByMailFolderId(folderID).
|
||||
ChildFolders().
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
@ -263,8 +267,10 @@ func checkAllSubFolder(
|
||||
)
|
||||
|
||||
childFolder, err := client.
|
||||
UsersById(testUser).
|
||||
MailFoldersById(folderID).
|
||||
Users().
|
||||
ByUserId(testUser).
|
||||
MailFolders().
|
||||
ByMailFolderId(folderID).
|
||||
ChildFolders().
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
@ -303,7 +309,8 @@ func checkOneDriveRestoration(
|
||||
startTime time.Time,
|
||||
) {
|
||||
drive, err := client.
|
||||
UsersById(userID).
|
||||
Users().
|
||||
ByUserId(userID).
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -333,7 +340,8 @@ func checkSharePointRestoration(
|
||||
startTime time.Time,
|
||||
) {
|
||||
drive, err := client.
|
||||
SitesById(siteID).
|
||||
Sites().
|
||||
BySiteId(siteID).
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -381,8 +389,10 @@ func checkDriveRestoration(
|
||||
ctx = clues.Add(ctx, "drive_id", driveID, "drive_name", driveName)
|
||||
|
||||
response, err := client.
|
||||
DrivesById(driveID).
|
||||
Root().
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId("root").
|
||||
Children().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -521,7 +531,7 @@ func getOneDriveChildFolder(
|
||||
folderPermission map[string][]permissionInfo,
|
||||
startTime time.Time,
|
||||
) {
|
||||
response, err := client.DrivesById(driveID).ItemsById(itemID).Children().Get(ctx, nil)
|
||||
response, err := client.Drives().ByDriveId(driveID).Items().ByDriveItemId(itemID).Children().Get(ctx, nil)
|
||||
if err != nil {
|
||||
fatal(ctx, "getting child folder", err)
|
||||
}
|
||||
@ -569,8 +579,10 @@ func getRestoredDrive(
|
||||
startTime time.Time,
|
||||
) {
|
||||
restored, err := client.
|
||||
DrivesById(driveID).
|
||||
ItemsById(restoreFolderID).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(restoreFolderID).
|
||||
Children().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -610,8 +622,10 @@ func permissionIn(
|
||||
pi := []permissionInfo{}
|
||||
|
||||
pcr, err := client.
|
||||
DrivesById(driveID).
|
||||
ItemsById(itemID).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Permissions().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
|
||||
26
src/go.mod
26
src/go.mod
@ -14,13 +14,13 @@ require (
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/h2non/gock v1.2.0
|
||||
github.com/kopia/kopia v0.12.2-0.20230327171220-747baeebdab1
|
||||
github.com/microsoft/kiota-abstractions-go v0.18.0
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.6.0
|
||||
github.com/microsoft/kiota-http-go v0.16.1
|
||||
github.com/microsoft/kiota-serialization-form-go v0.8.2
|
||||
github.com/microsoft/kiota-serialization-json-go v0.8.2
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.53.0
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0
|
||||
github.com/microsoft/kiota-abstractions-go v1.0.0
|
||||
github.com/microsoft/kiota-authentication-azure-go v1.0.0
|
||||
github.com/microsoft/kiota-http-go v1.0.0
|
||||
github.com/microsoft/kiota-serialization-form-go v1.0.0
|
||||
github.com/microsoft/kiota-serialization-json-go v1.0.0
|
||||
github.com/microsoftgraph/msgraph-sdk-go v1.1.0
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v1.0.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rudderlabs/analytics-go v3.3.3+incompatible
|
||||
github.com/spatialcurrent/go-lazy v0.0.0-20211115014721-47315cc003d1
|
||||
@ -60,8 +60,8 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
|
||||
@ -71,7 +71,7 @@ require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/edsrzf/mmap-go v1.1.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/logr v1.2.4 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
@ -89,7 +89,7 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/microsoft/kiota-serialization-text-go v0.7.0
|
||||
github.com/microsoft/kiota-serialization-text-go v1.0.0
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/minio/minio-go/v7 v7.0.52 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
@ -112,8 +112,8 @@ require (
|
||||
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
|
||||
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
|
||||
github.com/zeebo/blake3 v0.2.3 // indirect
|
||||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel v1.15.1 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.15.1 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.8.0 // indirect
|
||||
|
||||
30
src/go.sum
30
src/go.sum
@ -38,10 +38,16 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0 h1:VuHAcMq8pU1IWNT/m5yRaGqbK0BiQKHT8X4DTp9CHdI=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0/go.mod h1:tZoQYdDZNOiIjdSn0dVWVfl0NEPGOJqVLzSrcFk4Is0=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.5.0 h1:xGLAFFd9D3iLGxYiUGPdITSzsFmU1K8VtfuUHWAoN7M=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.5.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
@ -126,6 +132,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
@ -275,20 +283,38 @@ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQ
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/microsoft/kiota-abstractions-go v0.18.0 h1:H1kQE5hAq/7Q8gENPJ1Y7DuvG9QqKCpglN8D7TJi9qY=
|
||||
github.com/microsoft/kiota-abstractions-go v0.18.0/go.mod h1:0lbPErVO6Rj3HHpntNYW/OFmHhJJ1ewPdsi1xPxYIMc=
|
||||
github.com/microsoft/kiota-abstractions-go v1.0.0 h1:teQS3yOmcTyps+O48AD17LI8TR1B3wCEwGFcwC6K75c=
|
||||
github.com/microsoft/kiota-abstractions-go v1.0.0/go.mod h1:2yaRQnx2KU7UaenYSApiTT4pf7fFkPV0B71Rm2uYynQ=
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.6.0 h1:Il9bLO34J6D8DY89xYAXoGh9muvlphayqG4eihyT6B8=
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.6.0/go.mod h1:EJCHiLWLXW1/mSgX7lYReAhVO37MzRT5Xi2mcPTwCRQ=
|
||||
github.com/microsoft/kiota-authentication-azure-go v1.0.0 h1:29FNZZ/4nnCOwFcGWlB/sxPvWz487HA2bXH8jR5k2Rk=
|
||||
github.com/microsoft/kiota-authentication-azure-go v1.0.0/go.mod h1:rnx3PRlkGdXDcA/0lZQTbBwyYGmc+3POt7HpE/e4jGw=
|
||||
github.com/microsoft/kiota-http-go v0.16.1 h1:5SZbSwHs14Xve5VMQHHz00lwL/kEg3H9rgESAUrXnvw=
|
||||
github.com/microsoft/kiota-http-go v0.16.1/go.mod h1:pKSaeSaBwh3Zadbnzw3kALEZbCZA1gq7A5PuxwVd/aU=
|
||||
github.com/microsoft/kiota-http-go v1.0.0 h1:F1hd6gMlLeEgH2CkRB7z13ow7LxMKMWEmms/t0VfS+k=
|
||||
github.com/microsoft/kiota-http-go v1.0.0/go.mod h1:eujxJliqodotsYepIc6ihhK+vXMMt5Q8YiSNL7+7M7U=
|
||||
github.com/microsoft/kiota-serialization-form-go v0.8.2 h1:qrkJGBObZo0NjJwwbT3lUySjaLKqjz+r4TQGQTX/C/c=
|
||||
github.com/microsoft/kiota-serialization-form-go v0.8.2/go.mod h1:FQqYzIrGX6KUoDOlg+DhDWoGaZoB8AicBYGOsBq0Dw4=
|
||||
github.com/microsoft/kiota-serialization-form-go v1.0.0 h1:UNdrkMnLFqUCccQZerKjblsyVgifS11b3WCx+eFEsAI=
|
||||
github.com/microsoft/kiota-serialization-form-go v1.0.0/go.mod h1:h4mQOO6KVTNciMF6azi1J9QB19ujSw3ULKcSNyXXOMA=
|
||||
github.com/microsoft/kiota-serialization-json-go v0.8.2 h1:vLKZAOiMsaUxq36RDo3S/FfQbW2VQCdAIu4DS7+Qhrk=
|
||||
github.com/microsoft/kiota-serialization-json-go v0.8.2/go.mod h1:gGcLNSdIdOZ4la2qztA0vaCq/LtlA53gpP+ur8n/+oA=
|
||||
github.com/microsoft/kiota-serialization-json-go v1.0.0 h1:snT+SwS/R4CMjkmj7mjCHrmib2nKWqGvUWaedgliMbI=
|
||||
github.com/microsoft/kiota-serialization-json-go v1.0.0/go.mod h1:psfgIfqWm/9P1JAdl2cxHHIg9SdEtYHOetfDLIQ5/dw=
|
||||
github.com/microsoft/kiota-serialization-text-go v0.7.0 h1:uayeq8fpDcZgL0zDyLkYZsH6zNnEXKgp+bRWfR5LcxA=
|
||||
github.com/microsoft/kiota-serialization-text-go v0.7.0/go.mod h1:2su1PTllHCMNkHugmvpYad+AKBXUUGoiNP3xOAJUL7w=
|
||||
github.com/microsoft/kiota-serialization-text-go v1.0.0 h1:XOaRhAXy+g8ZVpcq7x7a0jlETWnWrEum0RhmbYrTFnA=
|
||||
github.com/microsoft/kiota-serialization-text-go v1.0.0/go.mod h1:sM1/C6ecnQ7IquQOGUrUldaO5wj+9+v7G2W3sQ3fy6M=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.53.0 h1:HpQd1Nvr8yQNeqhDuiVSbqn1fkHsFbRFDmnuhhXJXOQ=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.53.0/go.mod h1:BZLyon4n4T4EuLIAlX+kJ5JgneFTXVQDah1AJuq3FRY=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v1.0.0 h1:dGh406Loi5CoQ1VsoBkbi+mlozu58eT65YzoYsWX3Sk=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v1.0.0/go.mod h1:GvurB1XYl22Ralx3wlQZUTOwPnZ55RoTfbRNIStgj94=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v1.1.0 h1:NtFsFVIt8lpXcTlRbLG1WuCOTzltzS5j+U8Fecqdnr4=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v1.1.0/go.mod h1:NIk9kSn7lQ5Hnhhn3FM4NrJWz54JfDHD0JvhJZky27g=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0 h1:cDL3ov/IZ2ZarUJdGGPsdR+46ALdd3CRAiDBIylLCoA=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.33.0/go.mod h1:d0mU3PQAWnN/C4CwPJEZz2QhesrnR5UDnqRu2ODWPkI=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v1.0.0 h1:7NWTfyXvOjoizW7PmxNp3+8wCKPgpODs/D1cUZ3fkAY=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v1.0.0/go.mod h1:tQb4q3YMIj2dWhhXhQSJ4ELpol931ANKzHSYK5kX1qE=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.52 h1:8XhG36F6oKQUDDSuz6dY3rioMzovKjW40W6ANuN0Dps=
|
||||
@ -433,8 +459,12 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
|
||||
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
|
||||
go.opentelemetry.io/otel v1.15.1 h1:3Iwq3lfRByPaws0f6bU3naAqOR1n5IeDWd9390kWHa8=
|
||||
go.opentelemetry.io/otel v1.15.1/go.mod h1:mHHGEHVDLal6YrKMmk9LqC4a3sF5g+fHfrttQIB1NTc=
|
||||
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
|
||||
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
|
||||
go.opentelemetry.io/otel/trace v1.15.1 h1:uXLo6iHJEzDfrNC0L0mNjItIp06SyaBQxu5t3xMlngY=
|
||||
go.opentelemetry.io/otel/trace v1.15.1/go.mod h1:IWdQG/5N1x7f6YUlmdLeJvH9yxtuJAfc4VW5Agv9r/8=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
|
||||
@ -45,7 +45,7 @@ func (c Contacts) CreateContactFolder(
|
||||
temp := folderName
|
||||
requestBody.SetDisplayName(&temp)
|
||||
|
||||
mdl, err := c.Stable.Client().UsersById(user).ContactFolders().Post(ctx, requestBody, nil)
|
||||
mdl, err := c.Stable.Client().Users().ByUserId(user).ContactFolders().Post(ctx, requestBody, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating contact folder")
|
||||
}
|
||||
@ -65,7 +65,7 @@ func (c Contacts) DeleteContainer(
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.Client().UsersById(user).ContactFoldersById(folderID).Delete(ctx, nil)
|
||||
err = srv.Client().Users().ByUserId(user).ContactFolders().ByContactFolderId(folderID).Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
@ -84,7 +84,7 @@ func (c Contacts) GetItem(
|
||||
Headers: buildPreferHeaders(false, immutableIDs),
|
||||
}
|
||||
|
||||
cont, err := c.Stable.Client().UsersById(user).ContactsById(itemID).Get(ctx, options)
|
||||
cont, err := c.Stable.Client().Users().ByUserId(user).Contacts().ByContactId(itemID).Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
}
|
||||
@ -101,7 +101,7 @@ func (c Contacts) GetContainerByID(
|
||||
return nil, graph.Wrap(ctx, err, "setting contact folder options")
|
||||
}
|
||||
|
||||
resp, err := c.Stable.Client().UsersById(userID).ContactFoldersById(dirID).Get(ctx, ofcf)
|
||||
resp, err := c.Stable.Client().Users().ByUserId(userID).ContactFolders().ByContactFolderId(dirID).Get(ctx, ofcf)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
@ -134,8 +134,10 @@ func (c Contacts) EnumerateContainers(
|
||||
|
||||
el := errs.Local()
|
||||
builder := service.Client().
|
||||
UsersById(userID).
|
||||
ContactFoldersById(baseDirID).
|
||||
Users().
|
||||
ByUserId(userID).
|
||||
ContactFolders().
|
||||
ByContactFolderId(baseDirID).
|
||||
ChildFolders()
|
||||
|
||||
for {
|
||||
@ -217,7 +219,7 @@ func NewContactPager(
|
||||
return &contactPager{}, err
|
||||
}
|
||||
|
||||
builder := gs.Client().UsersById(user).ContactFoldersById(directoryID).Contacts()
|
||||
builder := gs.Client().Users().ByUserId(user).ContactFolders().ByContactFolderId(directoryID).Contacts()
|
||||
|
||||
return &contactPager{gs, builder, options}, nil
|
||||
}
|
||||
@ -263,7 +265,7 @@ func getContactDeltaBuilder(
|
||||
directoryID string,
|
||||
options *users.ItemContactFoldersItemContactsDeltaRequestBuilderGetRequestConfiguration,
|
||||
) *users.ItemContactFoldersItemContactsDeltaRequestBuilder {
|
||||
builder := gs.Client().UsersById(user).ContactFoldersById(directoryID).Contacts().Delta()
|
||||
builder := gs.Client().Users().ByUserId(user).ContactFolders().ByContactFolderId(directoryID).Contacts().Delta()
|
||||
return builder
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ func (c Events) CreateCalendar(
|
||||
requestbody := models.NewCalendar()
|
||||
requestbody.SetName(&calendarName)
|
||||
|
||||
mdl, err := c.Stable.Client().UsersById(user).Calendars().Post(ctx, requestbody, nil)
|
||||
mdl, err := c.Stable.Client().Users().ByUserId(user).Calendars().Post(ctx, requestbody, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating calendar")
|
||||
}
|
||||
@ -67,7 +67,7 @@ func (c Events) DeleteContainer(
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.Client().UsersById(user).CalendarsById(calendarID).Delete(ctx, nil)
|
||||
err = srv.Client().Users().ByUserId(user).Calendars().ByCalendarId(calendarID).Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
@ -89,7 +89,7 @@ func (c Events) GetContainerByID(
|
||||
return nil, graph.Wrap(ctx, err, "setting event calendar options")
|
||||
}
|
||||
|
||||
cal, err := service.Client().UsersById(userID).CalendarsById(containerID).Get(ctx, ofc)
|
||||
cal, err := service.Client().Users().ByUserId(userID).Calendars().ByCalendarId(containerID).Get(ctx, ofc)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err).WithClues(ctx)
|
||||
}
|
||||
@ -111,7 +111,7 @@ func (c Events) GetContainerByName(
|
||||
|
||||
ctx = clues.Add(ctx, "calendar_name", name)
|
||||
|
||||
resp, err := c.Stable.Client().UsersById(userID).Calendars().Get(ctx, options)
|
||||
resp, err := c.Stable.Client().Users().ByUserId(userID).Calendars().Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err).WithClues(ctx)
|
||||
}
|
||||
@ -152,7 +152,7 @@ func (c Events) GetItem(
|
||||
}
|
||||
)
|
||||
|
||||
event, err = c.Stable.Client().UsersById(user).EventsById(itemID).Get(ctx, itemOpts)
|
||||
event, err = c.Stable.Client().Users().ByUserId(user).Events().ByEventId(itemID).Get(ctx, itemOpts)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
}
|
||||
@ -167,8 +167,10 @@ func (c Events) GetItem(
|
||||
|
||||
attached, err := c.LargeItem.
|
||||
Client().
|
||||
UsersById(user).
|
||||
EventsById(itemID).
|
||||
Users().
|
||||
ByUserId(user).
|
||||
Events().
|
||||
ByEventId(itemID).
|
||||
Attachments().
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
@ -203,7 +205,7 @@ func (c Events) EnumerateContainers(
|
||||
}
|
||||
|
||||
el := errs.Local()
|
||||
builder := service.Client().UsersById(userID).Calendars()
|
||||
builder := service.Client().Users().ByUserId(userID).Calendars()
|
||||
|
||||
for {
|
||||
if el.Failure() != nil {
|
||||
@ -278,7 +280,7 @@ func NewEventPager(
|
||||
Headers: buildPreferHeaders(true, immutableIDs),
|
||||
}
|
||||
|
||||
builder := gs.Client().UsersById(user).CalendarsById(calendarID).Events()
|
||||
builder := gs.Client().Users().ByUserId(user).Calendars().ByCalendarId(calendarID).Events()
|
||||
|
||||
return &eventPager{gs, builder, options}, nil
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ func (c Mail) CreateMailFolder(
|
||||
requestBody.SetDisplayName(&folder)
|
||||
requestBody.SetIsHidden(&isHidden)
|
||||
|
||||
mdl, err := c.Stable.Client().UsersById(user).MailFolders().Post(ctx, requestBody, nil)
|
||||
mdl, err := c.Stable.Client().Users().ByUserId(user).MailFolders().Post(ctx, requestBody, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "creating mail folder")
|
||||
}
|
||||
@ -75,8 +75,10 @@ func (c Mail) CreateMailFolderWithParent(
|
||||
|
||||
mdl, err := service.
|
||||
Client().
|
||||
UsersById(user).
|
||||
MailFoldersById(parentID).
|
||||
Users().
|
||||
ByUserId(user).
|
||||
MailFolders().
|
||||
ByMailFolderId(parentID).
|
||||
ChildFolders().
|
||||
Post(ctx, requestBody, nil)
|
||||
if err != nil {
|
||||
@ -99,7 +101,12 @@ func (c Mail) DeleteContainer(
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
|
||||
err = srv.Client().UsersById(user).MailFoldersById(folderID).Delete(ctx, nil)
|
||||
err = srv.Client().
|
||||
Users().
|
||||
ByUserId(user).
|
||||
MailFolders().
|
||||
ByMailFolderId(folderID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Stack(ctx, err)
|
||||
}
|
||||
@ -121,7 +128,12 @@ func (c Mail) GetContainerByID(
|
||||
return nil, graph.Wrap(ctx, err, "setting mail folder options")
|
||||
}
|
||||
|
||||
resp, err := service.Client().UsersById(userID).MailFoldersById(dirID).Get(ctx, ofmf)
|
||||
resp, err := service.Client().
|
||||
Users().
|
||||
ByUserId(userID).
|
||||
MailFolders().
|
||||
ByMailFolderId(dirID).
|
||||
Get(ctx, ofmf)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
@ -147,7 +159,7 @@ func (c Mail) GetItem(
|
||||
Headers: headers,
|
||||
}
|
||||
|
||||
mail, err := c.Stable.Client().UsersById(user).MessagesById(itemID).Get(ctx, itemOpts)
|
||||
mail, err := c.Stable.Client().Users().ByUserId(user).Messages().ByMessageId(itemID).Get(ctx, itemOpts)
|
||||
if err != nil {
|
||||
return nil, nil, graph.Stack(ctx, err)
|
||||
}
|
||||
@ -173,8 +185,10 @@ func (c Mail) GetItem(
|
||||
|
||||
attached, err := c.LargeItem.
|
||||
Client().
|
||||
UsersById(user).
|
||||
MessagesById(itemID).
|
||||
Users().
|
||||
ByUserId(user).
|
||||
Messages().
|
||||
ByMessageId(itemID).
|
||||
Attachments().
|
||||
Get(ctx, options)
|
||||
if err == nil {
|
||||
@ -204,8 +218,10 @@ func (c Mail) GetItem(
|
||||
|
||||
attachments, err := c.LargeItem.
|
||||
Client().
|
||||
UsersById(user).
|
||||
MessagesById(itemID).
|
||||
Users().
|
||||
ByUserId(user).
|
||||
Messages().
|
||||
ByMessageId(itemID).
|
||||
Attachments().
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
@ -224,9 +240,12 @@ func (c Mail) GetItem(
|
||||
|
||||
att, err := c.Stable.
|
||||
Client().
|
||||
UsersById(user).
|
||||
MessagesById(itemID).
|
||||
AttachmentsById(ptr.Val(a.GetId())).
|
||||
Users().
|
||||
ByUserId(user).
|
||||
Messages().
|
||||
ByMessageId(itemID).
|
||||
Attachments().
|
||||
ByAttachmentId(ptr.Val(a.GetId())).
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, nil,
|
||||
@ -380,7 +399,12 @@ func NewMailPager(
|
||||
return &mailPager{}, err
|
||||
}
|
||||
|
||||
builder := gs.Client().UsersById(user).MailFoldersById(directoryID).Messages()
|
||||
builder := gs.Client().
|
||||
Users().
|
||||
ByUserId(user).
|
||||
MailFolders().
|
||||
ByMailFolderId(directoryID).
|
||||
Messages()
|
||||
|
||||
return &mailPager{gs, builder, options}, nil
|
||||
}
|
||||
@ -426,7 +450,14 @@ func getMailDeltaBuilder(
|
||||
directoryID string,
|
||||
options *users.ItemMailFoldersItemMessagesDeltaRequestBuilderGetRequestConfiguration,
|
||||
) *users.ItemMailFoldersItemMessagesDeltaRequestBuilder {
|
||||
builder := gs.Client().UsersById(user).MailFoldersById(directoryID).Messages().Delta()
|
||||
builder := gs.Client().
|
||||
Users().
|
||||
ByUserId(user).
|
||||
MailFolders().
|
||||
ByMailFolderId(directoryID).
|
||||
Messages().
|
||||
Delta()
|
||||
|
||||
return builder
|
||||
}
|
||||
|
||||
@ -479,7 +510,13 @@ func (p *mailDeltaPager) setNext(nextLink string) {
|
||||
}
|
||||
|
||||
func (p *mailDeltaPager) reset(ctx context.Context) {
|
||||
p.builder = p.gs.Client().UsersById(p.user).MailFoldersById(p.directoryID).Messages().Delta()
|
||||
p.builder = p.gs.Client().
|
||||
Users().
|
||||
ByUserId(p.user).
|
||||
MailFolders().
|
||||
ByMailFolderId(p.directoryID).
|
||||
Messages().
|
||||
Delta()
|
||||
}
|
||||
|
||||
func (p *mailDeltaPager) valuesIn(pl api.PageLinker) ([]getIDAndAddtler, error) {
|
||||
|
||||
@ -93,10 +93,12 @@ func uploadLargeAttachment(
|
||||
uploader attachmentUploadable,
|
||||
attachment models.Attachmentable,
|
||||
) error {
|
||||
var (
|
||||
bs = attachmentBytes(attachment)
|
||||
size = int64(len(bs))
|
||||
)
|
||||
bs, err := GetAttachmentBytes(attachment)
|
||||
if err != nil {
|
||||
return clues.Stack(err).WithClues(ctx)
|
||||
}
|
||||
|
||||
size := int64(len(bs))
|
||||
|
||||
session, err := uploader.uploadSession(ctx, ptr.Val(attachment.GetName()), size)
|
||||
if err != nil {
|
||||
|
||||
@ -37,9 +37,12 @@ func (mau *mailAttachmentUploader) getItemID() string {
|
||||
|
||||
func (mau *mailAttachmentUploader) uploadSmallAttachment(ctx context.Context, attach models.Attachmentable) error {
|
||||
_, err := mau.service.Client().
|
||||
UsersById(mau.userID).
|
||||
MailFoldersById(mau.folderID).
|
||||
MessagesById(mau.itemID).
|
||||
Users().
|
||||
ByUserId(mau.userID).
|
||||
MailFolders().
|
||||
ByMailFolderId(mau.folderID).
|
||||
Messages().
|
||||
ByMessageId(mau.itemID).
|
||||
Attachments().
|
||||
Post(ctx, attach, nil)
|
||||
if err != nil {
|
||||
@ -60,9 +63,12 @@ func (mau *mailAttachmentUploader) uploadSession(
|
||||
r, err := mau.
|
||||
service.
|
||||
Client().
|
||||
UsersById(mau.userID).
|
||||
MailFoldersById(mau.folderID).
|
||||
MessagesById(mau.itemID).
|
||||
Users().
|
||||
ByUserId(mau.userID).
|
||||
MailFolders().
|
||||
ByMailFolderId(mau.folderID).
|
||||
Messages().
|
||||
ByMessageId(mau.itemID).
|
||||
Attachments().
|
||||
CreateUploadSession().
|
||||
Post(ctx, session, nil)
|
||||
@ -87,9 +93,12 @@ func (eau *eventAttachmentUploader) getItemID() string {
|
||||
|
||||
func (eau *eventAttachmentUploader) uploadSmallAttachment(ctx context.Context, attach models.Attachmentable) error {
|
||||
_, err := eau.service.Client().
|
||||
UsersById(eau.userID).
|
||||
CalendarsById(eau.calendarID).
|
||||
EventsById(eau.itemID).
|
||||
Users().
|
||||
ByUserId(eau.userID).
|
||||
Calendars().
|
||||
ByCalendarId(eau.calendarID).
|
||||
Events().
|
||||
ByEventId(eau.itemID).
|
||||
Attachments().
|
||||
Post(ctx, attach, nil)
|
||||
if err != nil {
|
||||
@ -108,9 +117,12 @@ func (eau *eventAttachmentUploader) uploadSession(
|
||||
session.SetAttachmentItem(makeSessionAttachment(attachmentName, attachmentSize))
|
||||
|
||||
r, err := eau.service.Client().
|
||||
UsersById(eau.userID).
|
||||
CalendarsById(eau.calendarID).
|
||||
EventsById(eau.itemID).
|
||||
Users().
|
||||
ByUserId(eau.userID).
|
||||
Calendars().
|
||||
ByCalendarId(eau.calendarID).
|
||||
Events().
|
||||
ByEventId(eau.itemID).
|
||||
Attachments().
|
||||
CreateUploadSession().
|
||||
Post(ctx, session, nil)
|
||||
|
||||
@ -67,9 +67,9 @@ func (suite *MockSuite) TestMockExchangeCollection_NewExchangeCollectionMail_Hyd
|
||||
|
||||
t := suite.T()
|
||||
mdc := NewCollection(nil, nil, 3)
|
||||
buf := &bytes.Buffer{}
|
||||
|
||||
for stream := range mdc.Items(ctx, fault.New(true)) {
|
||||
buf := &bytes.Buffer{}
|
||||
_, err := buf.ReadFrom(stream.ToReader())
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime/trace"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
@ -74,7 +73,13 @@ func RestoreExchangeContact(
|
||||
|
||||
ctx = clues.Add(ctx, "item_id", ptr.Val(contact.GetId()))
|
||||
|
||||
response, err := service.Client().UsersById(user).ContactFoldersById(destination).Contacts().Post(ctx, contact, nil)
|
||||
response, err := service.Client().
|
||||
Users().
|
||||
ByUserId(user).
|
||||
ContactFolders().
|
||||
ByContactFolderId(destination).
|
||||
Contacts().
|
||||
Post(ctx, contact, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "uploading Contact")
|
||||
}
|
||||
@ -122,7 +127,13 @@ func RestoreExchangeEvent(
|
||||
transformedEvent.SetAttachments([]models.Attachmentable{})
|
||||
}
|
||||
|
||||
response, err := service.Client().UsersById(user).CalendarsById(destination).Events().Post(ctx, transformedEvent, nil)
|
||||
response, err := service.Client().
|
||||
Users().
|
||||
ByUserId(user).
|
||||
Calendars().
|
||||
ByCalendarId(destination).
|
||||
Events().
|
||||
Post(ctx, transformedEvent, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "uploading event")
|
||||
}
|
||||
@ -223,10 +234,19 @@ func RestoreMailMessage(
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// attachmentBytes is a helper to retrieve the attachment content from a models.Attachmentable
|
||||
// TODO: Revisit how we retrieve/persist attachment content during backup so this is not needed
|
||||
func attachmentBytes(attachment models.Attachmentable) []byte {
|
||||
return reflect.Indirect(reflect.ValueOf(attachment)).FieldByName("contentBytes").Bytes()
|
||||
// GetAttachmentBytes is a helper to retrieve the attachment content from a models.Attachmentable
|
||||
func GetAttachmentBytes(attachment models.Attachmentable) ([]byte, error) {
|
||||
bi, err := attachment.GetBackingStore().Get("contentBytes")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bts, ok := bi.([]byte)
|
||||
if !ok {
|
||||
return nil, clues.New(fmt.Sprintf("unexpected type for attachment content: %T", bi))
|
||||
}
|
||||
|
||||
return bts, nil
|
||||
}
|
||||
|
||||
// SendMailToBackStore function for transporting in-memory messageable item to M365 backstore
|
||||
@ -245,7 +265,13 @@ func SendMailToBackStore(
|
||||
// Item.Attachments --> HasAttachments doesn't always have a value populated when deserialized
|
||||
message.SetAttachments([]models.Attachmentable{})
|
||||
|
||||
response, err := service.Client().UsersById(user).MailFoldersById(destination).Messages().Post(ctx, message, nil)
|
||||
response, err := service.Client().
|
||||
Users().
|
||||
ByUserId(user).
|
||||
MailFolders().
|
||||
ByMailFolderId(destination).
|
||||
Messages().
|
||||
Post(ctx, message, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "restoring mail")
|
||||
}
|
||||
|
||||
@ -25,10 +25,10 @@ func TestGraphErrorsUnitSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func odErr(code string) *odataerrors.ODataError {
|
||||
odErr := &odataerrors.ODataError{}
|
||||
merr := odataerrors.MainError{}
|
||||
odErr := odataerrors.NewODataError()
|
||||
merr := odataerrors.NewMainError()
|
||||
merr.SetCode(&code)
|
||||
odErr.SetError(&merr)
|
||||
odErr.SetError(merr)
|
||||
|
||||
return odErr
|
||||
}
|
||||
@ -300,33 +300,33 @@ func (suite *GraphErrorsUnitSuite) TestIsErrUnauthorized() {
|
||||
|
||||
func (suite *GraphErrorsUnitSuite) TestMalwareInfo() {
|
||||
var (
|
||||
i = models.DriveItem{}
|
||||
cb = models.User{}
|
||||
i = models.NewDriveItem()
|
||||
cb = models.NewUser()
|
||||
cbID = "created-by"
|
||||
lm = models.User{}
|
||||
lm = models.NewUser()
|
||||
lmID = "last-mod-by"
|
||||
ref = models.ItemReference{}
|
||||
ref = models.NewItemReference()
|
||||
refCID = "container-id"
|
||||
refCN = "container-name"
|
||||
refCP = "/drives/b!vF-sdsdsds-sdsdsa-sdsd/root:/Folder/container-name"
|
||||
refCPexp = "/Folder/container-name"
|
||||
mal = models.Malware{}
|
||||
mal = models.NewMalware()
|
||||
malDesc = "malware-description"
|
||||
)
|
||||
|
||||
cb.SetId(&cbID)
|
||||
i.SetCreatedByUser(&cb)
|
||||
i.SetCreatedByUser(cb)
|
||||
|
||||
lm.SetId(&lmID)
|
||||
i.SetLastModifiedByUser(&lm)
|
||||
i.SetLastModifiedByUser(lm)
|
||||
|
||||
ref.SetId(&refCID)
|
||||
ref.SetName(&refCN)
|
||||
ref.SetPath(&refCP)
|
||||
i.SetParentReference(&ref)
|
||||
i.SetParentReference(ref)
|
||||
|
||||
mal.SetDescription(&malDesc)
|
||||
i.SetMalware(&mal)
|
||||
i.SetMalware(mal)
|
||||
|
||||
expect := map[string]any{
|
||||
fault.AddtlCreatedBy: cbID,
|
||||
@ -337,7 +337,7 @@ func (suite *GraphErrorsUnitSuite) TestMalwareInfo() {
|
||||
fault.AddtlMalwareDesc: malDesc,
|
||||
}
|
||||
|
||||
assert.Equal(suite.T(), expect, ItemInfo(&i))
|
||||
assert.Equal(suite.T(), expect, ItemInfo(i))
|
||||
}
|
||||
|
||||
func (suite *GraphErrorsUnitSuite) TestIsErrFolderExists() {
|
||||
|
||||
@ -227,7 +227,8 @@ func (suite *RetryMWIntgSuite) TestRetryMiddleware_RetryRequest_resetBodyAfter50
|
||||
|
||||
_, err = NewService(adpt).
|
||||
Client().
|
||||
UsersById("user").
|
||||
Users().
|
||||
ByUserId("user").
|
||||
MailFolders().
|
||||
Post(ctx, body, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -16,6 +16,7 @@ import (
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/connector/exchange"
|
||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||
"github.com/alcionai/corso/src/internal/connector/onedrive/metadata"
|
||||
"github.com/alcionai/corso/src/internal/connector/support"
|
||||
@ -117,11 +118,15 @@ func attachmentEqual(
|
||||
expected models.Attachmentable,
|
||||
got models.Attachmentable,
|
||||
) bool {
|
||||
// This is super hacky, but seems like it would be good to have a comparison
|
||||
// of the actual content. I think the only other way to really get it is to
|
||||
// serialize both structs to JSON and pull it from there or something though.
|
||||
expectedData := reflect.Indirect(reflect.ValueOf(expected)).FieldByName("contentBytes").Bytes()
|
||||
gotData := reflect.Indirect(reflect.ValueOf(got)).FieldByName("contentBytes").Bytes()
|
||||
expectedData, err := exchange.GetAttachmentBytes(expected)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
gotData, err := exchange.GetAttachmentBytes(got)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(expectedData, gotData) {
|
||||
return false
|
||||
|
||||
@ -54,9 +54,9 @@ func mustGetDefaultDriveID(
|
||||
|
||||
switch backupService {
|
||||
case path.OneDriveService:
|
||||
d, err = service.Client().UsersById(resourceOwner).Drive().Get(ctx, nil)
|
||||
d, err = service.Client().Users().ByUserId(resourceOwner).Drive().Get(ctx, nil)
|
||||
case path.SharePointService:
|
||||
d, err = service.Client().SitesById(resourceOwner).Drive().Get(ctx, nil)
|
||||
d, err = service.Client().Sites().BySiteId(resourceOwner).Drive().Get(ctx, nil)
|
||||
default:
|
||||
assert.FailNowf(t, "unknown service type %s", backupService.String())
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
abstractions "github.com/microsoft/kiota-abstractions-go"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drive"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drives"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/sites"
|
||||
@ -17,6 +16,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||
"github.com/alcionai/corso/src/internal/connector/graph/api"
|
||||
onedrive "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
)
|
||||
|
||||
@ -35,8 +35,8 @@ const pageSize = int32(999)
|
||||
type driveItemPager struct {
|
||||
gs graph.Servicer
|
||||
driveID string
|
||||
builder *drives.ItemRootDeltaRequestBuilder
|
||||
options *drives.ItemRootDeltaRequestBuilderGetRequestConfiguration
|
||||
builder *drives.ItemItemsItemDeltaRequestBuilder
|
||||
options *drives.ItemItemsItemDeltaRequestBuilderGetRequestConfiguration
|
||||
}
|
||||
|
||||
func NewItemPager(
|
||||
@ -55,9 +55,9 @@ func NewItemPager(
|
||||
}
|
||||
headers.Add("Prefer", strings.Join(preferHeaderItems, ","))
|
||||
|
||||
requestConfig := &drives.ItemRootDeltaRequestBuilderGetRequestConfiguration{
|
||||
requestConfig := &drives.ItemItemsItemDeltaRequestBuilderGetRequestConfiguration{
|
||||
Headers: headers,
|
||||
QueryParameters: &drives.ItemRootDeltaRequestBuilderGetQueryParameters{
|
||||
QueryParameters: &drives.ItemItemsItemDeltaRequestBuilderGetQueryParameters{
|
||||
Top: &pageCount,
|
||||
Select: fields,
|
||||
},
|
||||
@ -67,11 +67,14 @@ func NewItemPager(
|
||||
gs: gs,
|
||||
driveID: driveID,
|
||||
options: requestConfig,
|
||||
builder: gs.Client().DrivesById(driveID).Root().Delta(),
|
||||
builder: gs.Client().
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().ByDriveItemId(onedrive.RootID).Delta(),
|
||||
}
|
||||
|
||||
if len(link) > 0 {
|
||||
res.builder = drives.NewItemRootDeltaRequestBuilder(link, gs.Adapter())
|
||||
res.builder = drives.NewItemItemsItemDeltaRequestBuilder(link, gs.Adapter())
|
||||
}
|
||||
|
||||
return res
|
||||
@ -92,11 +95,16 @@ func (p *driveItemPager) GetPage(ctx context.Context) (api.DeltaPageLinker, erro
|
||||
}
|
||||
|
||||
func (p *driveItemPager) SetNext(link string) {
|
||||
p.builder = drives.NewItemRootDeltaRequestBuilder(link, p.gs.Adapter())
|
||||
p.builder = drives.NewItemItemsItemDeltaRequestBuilder(link, p.gs.Adapter())
|
||||
}
|
||||
|
||||
func (p *driveItemPager) Reset() {
|
||||
p.builder = p.gs.Client().DrivesById(p.driveID).Root().Delta()
|
||||
p.builder = p.gs.Client().
|
||||
Drives().
|
||||
ByDriveId(p.driveID).
|
||||
Items().
|
||||
ByDriveItemId(onedrive.RootID).
|
||||
Delta()
|
||||
}
|
||||
|
||||
func (p *driveItemPager) ValuesIn(l api.DeltaPageLinker) ([]models.DriveItemable, error) {
|
||||
@ -125,7 +133,7 @@ func NewUserDrivePager(
|
||||
userID: userID,
|
||||
gs: gs,
|
||||
options: requestConfig,
|
||||
builder: gs.Client().UsersById(userID).Drives(),
|
||||
builder: gs.Client().Users().ByUserId(userID).Drives(),
|
||||
}
|
||||
|
||||
return res
|
||||
@ -143,7 +151,7 @@ func (p *userDrivePager) GetPage(ctx context.Context) (api.PageLinker, error) {
|
||||
err error
|
||||
)
|
||||
|
||||
d, err := p.gs.Client().UsersById(p.userID).Drive().Get(ctx, nil)
|
||||
d, err := p.gs.Client().Users().ByUserId(p.userID).Drive().Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Stack(ctx, err)
|
||||
}
|
||||
@ -204,7 +212,7 @@ func NewSiteDrivePager(
|
||||
res := &siteDrivePager{
|
||||
gs: gs,
|
||||
options: requestConfig,
|
||||
builder: gs.Client().SitesById(siteID).Drives(),
|
||||
builder: gs.Client().Sites().BySiteId(siteID).Drives(),
|
||||
}
|
||||
|
||||
return res
|
||||
@ -308,8 +316,10 @@ func GetDriveItem(
|
||||
driveID, itemID string,
|
||||
) (models.DriveItemable, error) {
|
||||
di, err := srv.Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(itemID).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting item")
|
||||
@ -325,8 +335,10 @@ func GetItemPermission(
|
||||
) (models.PermissionCollectionResponseable, error) {
|
||||
perm, err := service.
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(itemID).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Permissions().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -342,7 +354,8 @@ func GetUsersDrive(
|
||||
user string,
|
||||
) (models.Driveable, error) {
|
||||
d, err := srv.Client().
|
||||
UsersById(user).
|
||||
Users().
|
||||
ByUserId(user).
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -358,7 +371,8 @@ func GetSitesDefaultDrive(
|
||||
site string,
|
||||
) (models.Driveable, error) {
|
||||
d, err := srv.Client().
|
||||
SitesById(site).
|
||||
Sites().
|
||||
BySiteId(site).
|
||||
Drive().
|
||||
Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -373,10 +387,7 @@ func GetDriveRoot(
|
||||
srv graph.Servicer,
|
||||
driveID string,
|
||||
) (models.DriveItemable, error) {
|
||||
root, err := srv.Client().
|
||||
DrivesById(driveID).
|
||||
Root().
|
||||
Get(ctx, nil)
|
||||
root, err := srv.Client().Drives().ByDriveId(driveID).Root().Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting drive root")
|
||||
}
|
||||
@ -400,7 +411,7 @@ func GetFolderByName(
|
||||
// https://learn.microsoft.com/en-us/graph/onedrive-addressing-driveitems#path-based-addressing
|
||||
// - which allows us to lookup an item by its path relative to the parent ID
|
||||
rawURL := fmt.Sprintf(itemByPathRawURLFmt, driveID, parentFolderID, folder)
|
||||
builder := drive.NewItemsDriveItemItemRequestBuilder(rawURL, service.Adapter())
|
||||
builder := drives.NewItemItemsDriveItemItemRequestBuilder(rawURL, service.Adapter())
|
||||
|
||||
foundItem, err := builder.Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -423,13 +434,15 @@ func PostItemPermissionUpdate(
|
||||
ctx context.Context,
|
||||
service graph.Servicer,
|
||||
driveID, itemID string,
|
||||
body *drive.ItemsItemInvitePostRequestBody,
|
||||
body *drives.ItemItemsItemInvitePostRequestBody,
|
||||
) (drives.ItemItemsItemInviteResponseable, error) {
|
||||
ctx = graph.ConsumeNTokens(ctx, graph.PermissionsLC)
|
||||
|
||||
itm, err := service.Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(itemID).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Invite().
|
||||
Post(ctx, body, nil)
|
||||
if err != nil {
|
||||
|
||||
@ -734,8 +734,8 @@ func (suite *GetDriveItemUnitTestSuite) TestDownloadContent() {
|
||||
gr graph.Requester
|
||||
driveID string
|
||||
iorc = io.NopCloser(bytes.NewReader([]byte("fnords")))
|
||||
item = &models.DriveItem{}
|
||||
itemWID = &models.DriveItem{}
|
||||
item = models.NewDriveItem()
|
||||
itemWID = models.NewDriveItem()
|
||||
)
|
||||
|
||||
itemWID.SetId(ptr.To("brainhooldy"))
|
||||
|
||||
@ -2426,7 +2426,7 @@ func coreItem(
|
||||
case isFolder:
|
||||
item.SetFolder(models.NewFolder())
|
||||
case isPackage:
|
||||
item.SetPackage(models.NewPackage_escaped())
|
||||
item.SetPackage(models.NewPackageEscaped())
|
||||
}
|
||||
|
||||
return item
|
||||
@ -2493,7 +2493,7 @@ func delItem(
|
||||
case isFolder:
|
||||
item.SetFolder(models.NewFolder())
|
||||
case isPackage:
|
||||
item.SetPackage(models.NewPackage_escaped())
|
||||
item.SetPackage(models.NewPackageEscaped())
|
||||
}
|
||||
|
||||
return item
|
||||
|
||||
@ -7,4 +7,6 @@ const (
|
||||
// const used as the root-of-drive dir for the drive portion of a path prefix.
|
||||
// eg: tid/onedrive/ro/files/drives/driveid/root:/...
|
||||
RootPathDir = "root:"
|
||||
// root id for drive items
|
||||
RootID = "root"
|
||||
)
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drive"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drives"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
@ -224,7 +224,7 @@ func CreateItem(
|
||||
// Graph SDK doesn't yet provide a POST method for `/children` so we set the `rawUrl` ourselves as recommended
|
||||
// here: https://github.com/microsoftgraph/msgraph-sdk-go/issues/155#issuecomment-1136254310
|
||||
rawURL := fmt.Sprintf(itemChildrenRawURLFmt, driveID, parentFolderID)
|
||||
builder := drive.NewItemsRequestBuilder(rawURL, service.Adapter())
|
||||
builder := drives.NewItemItemsRequestBuilder(rawURL, service.Adapter())
|
||||
|
||||
newItem, err := builder.Post(ctx, newItem, nil)
|
||||
if err != nil {
|
||||
@ -266,7 +266,7 @@ func GetAllFolders(
|
||||
prefix string,
|
||||
errs *fault.Bus,
|
||||
) ([]*Displayable, error) {
|
||||
drives, err := api.GetAllDrives(ctx, pager, true, maxDrivesRetries)
|
||||
drvs, err := api.GetAllDrives(ctx, pager, true, maxDrivesRetries)
|
||||
if err != nil {
|
||||
return nil, clues.Wrap(err, "getting OneDrive folders")
|
||||
}
|
||||
@ -276,7 +276,7 @@ func GetAllFolders(
|
||||
el = errs.Local()
|
||||
)
|
||||
|
||||
for _, d := range drives {
|
||||
for _, d := range drvs {
|
||||
if el.Failure() != nil {
|
||||
break
|
||||
}
|
||||
@ -358,7 +358,12 @@ func DeleteItem(
|
||||
driveID string,
|
||||
itemID string,
|
||||
) error {
|
||||
err := gs.Client().DrivesById(driveID).ItemsById(itemID).Delete(ctx, nil)
|
||||
err := gs.Client().
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting item").With("item_id", itemID)
|
||||
}
|
||||
|
||||
@ -43,10 +43,10 @@ const (
|
||||
)
|
||||
|
||||
func odErr(code string) *odataerrors.ODataError {
|
||||
odErr := &odataerrors.ODataError{}
|
||||
merr := odataerrors.MainError{}
|
||||
odErr := odataerrors.NewODataError()
|
||||
merr := odataerrors.NewMainError()
|
||||
merr.SetCode(&code)
|
||||
odErr.SetError(&merr)
|
||||
odErr.SetError(merr)
|
||||
|
||||
return odErr
|
||||
}
|
||||
|
||||
@ -346,8 +346,10 @@ func driveItemWriter(
|
||||
ctx = clues.Add(ctx, "upload_item_id", itemID)
|
||||
|
||||
r, err := service.Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(itemID).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
CreateUploadSession().
|
||||
Post(ctx, session, nil)
|
||||
if err != nil {
|
||||
|
||||
@ -151,7 +151,7 @@ func (suite *ItemIntegrationSuite) TestItemWriter() {
|
||||
t := suite.T()
|
||||
srv := suite.service
|
||||
|
||||
root, err := srv.Client().DrivesById(test.driveID).Root().Get(ctx, nil)
|
||||
root, err := srv.Client().Drives().ByDriveId(test.driveID).Root().Get(ctx, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
newFolderName := tester.DefaultTestRestoreDestination("folder").ContainerName
|
||||
@ -229,7 +229,7 @@ func (suite *ItemIntegrationSuite) TestDriveGetFolder() {
|
||||
t := suite.T()
|
||||
srv := suite.service
|
||||
|
||||
root, err := srv.Client().DrivesById(test.driveID).Root().Get(ctx, nil)
|
||||
root, err := srv.Client().Drives().ByDriveId(test.driveID).Root().Get(ctx, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// Lookup a folder that doesn't exist
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drive"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drives"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
@ -170,9 +170,12 @@ func UpdatePermissions(
|
||||
|
||||
err = graph.NewService(a).
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(itemID).
|
||||
PermissionsById(pid).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(itemID).
|
||||
Permissions().
|
||||
ByPermissionId(pid).
|
||||
Delete(graph.ConsumeNTokens(ictx, graph.PermissionsLC), nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ictx, err, "removing permissions")
|
||||
@ -201,7 +204,7 @@ func UpdatePermissions(
|
||||
continue
|
||||
}
|
||||
|
||||
pbody := drive.NewItemsItemInvitePostRequestBody()
|
||||
pbody := drives.NewItemItemsItemInvitePostRequestBody()
|
||||
pbody.SetRoles(roles)
|
||||
|
||||
if p.Expiration != nil {
|
||||
|
||||
@ -91,7 +91,7 @@ func GetSite(ctx context.Context, gs graph.Servicer, siteID string) (models.Site
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := gs.Client().SitesById(siteID).Get(ctx, options)
|
||||
resp, err := gs.Client().Sites().BySiteId(siteID).Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -174,11 +174,13 @@ func (suite *SharePointCollectionSuite) TestCollection_Items() {
|
||||
|
||||
// TestRestoreListCollection verifies Graph Restore API for the List Collection
|
||||
func (suite *SharePointCollectionSuite) TestListCollection_Restore() {
|
||||
t := suite.T()
|
||||
// https://github.com/microsoftgraph/msgraph-sdk-go/issues/490
|
||||
t.Skip("disabled until upstream issue with list restore is fixed.")
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
t := suite.T()
|
||||
|
||||
service := createTestService(t, suite.creds)
|
||||
listing := spMock.ListDefault("Mock List")
|
||||
testName := "MockListing"
|
||||
@ -200,7 +202,7 @@ func (suite *SharePointCollectionSuite) TestListCollection_Restore() {
|
||||
|
||||
// Clean-Up
|
||||
var (
|
||||
builder = service.Client().SitesById(suite.siteID).Lists()
|
||||
builder = service.Client().Sites().BySiteId(suite.siteID).Lists()
|
||||
isFound bool
|
||||
deleteID string
|
||||
)
|
||||
|
||||
@ -36,7 +36,7 @@ func preFetchLists(
|
||||
siteID string,
|
||||
) ([]listTuple, error) {
|
||||
var (
|
||||
builder = gs.Client().SitesById(siteID).Lists()
|
||||
builder = gs.Client().Sites().BySiteId(siteID).Lists()
|
||||
options = preFetchListOptions()
|
||||
listTuples = make([]listTuple, 0)
|
||||
)
|
||||
@ -128,7 +128,7 @@ func loadSiteLists(
|
||||
err error
|
||||
)
|
||||
|
||||
entry, err = gs.Client().SitesById(siteID).ListsById(id).Get(ctx, nil)
|
||||
entry, err = gs.Client().Sites().BySiteId(siteID).Lists().ByListId(id).Get(ctx, nil)
|
||||
if err != nil {
|
||||
el.AddRecoverable(graph.Wrap(ctx, err, "getting site list"))
|
||||
return
|
||||
@ -195,7 +195,7 @@ func fetchListItems(
|
||||
errs *fault.Bus,
|
||||
) ([]models.ListItemable, error) {
|
||||
var (
|
||||
prefix = gs.Client().SitesById(siteID).ListsById(listID)
|
||||
prefix = gs.Client().Sites().BySiteId(siteID).Lists().ByListId(listID)
|
||||
builder = prefix.Items()
|
||||
itms = make([]models.ListItemable, 0)
|
||||
el = errs.Local()
|
||||
@ -216,7 +216,7 @@ func fetchListItems(
|
||||
break
|
||||
}
|
||||
|
||||
newPrefix := prefix.ItemsById(ptr.Val(itm.GetId()))
|
||||
newPrefix := prefix.Items().ByListItemId(ptr.Val(itm.GetId()))
|
||||
|
||||
fields, err := newPrefix.Fields().Get(ctx, nil)
|
||||
if err != nil {
|
||||
@ -252,7 +252,7 @@ func fetchColumns(
|
||||
cs := make([]models.ColumnDefinitionable, 0)
|
||||
|
||||
if len(cTypeID) == 0 {
|
||||
builder := gs.Client().SitesById(siteID).ListsById(listID).Columns()
|
||||
builder := gs.Client().Sites().BySiteId(siteID).Lists().ByListId(listID).Columns()
|
||||
|
||||
for {
|
||||
resp, err := builder.Get(ctx, nil)
|
||||
@ -270,7 +270,14 @@ func fetchColumns(
|
||||
builder = sites.NewItemListsItemColumnsRequestBuilder(link, gs.Adapter())
|
||||
}
|
||||
} else {
|
||||
builder := gs.Client().SitesById(siteID).ListsById(listID).ContentTypesById(cTypeID).Columns()
|
||||
builder := gs.Client().
|
||||
Sites().
|
||||
BySiteId(siteID).
|
||||
Lists().
|
||||
ByListId(listID).
|
||||
ContentTypes().
|
||||
ByContentTypeId(cTypeID).
|
||||
Columns()
|
||||
|
||||
for {
|
||||
resp, err := builder.Get(ctx, nil)
|
||||
@ -307,7 +314,7 @@ func fetchContentTypes(
|
||||
var (
|
||||
el = errs.Local()
|
||||
cTypes = make([]models.ContentTypeable, 0)
|
||||
builder = gs.Client().SitesById(siteID).ListsById(listID).ContentTypes()
|
||||
builder = gs.Client().Sites().BySiteId(siteID).Lists().ByListId(listID).ContentTypes()
|
||||
)
|
||||
|
||||
for {
|
||||
@ -363,8 +370,15 @@ func fetchColumnLinks(
|
||||
siteID, listID, cTypeID string,
|
||||
) ([]models.ColumnLinkable, error) {
|
||||
var (
|
||||
builder = gs.Client().SitesById(siteID).ListsById(listID).ContentTypesById(cTypeID).ColumnLinks()
|
||||
links = make([]models.ColumnLinkable, 0)
|
||||
builder = gs.Client().
|
||||
Sites().
|
||||
BySiteId(siteID).
|
||||
Lists().
|
||||
ByListId(listID).
|
||||
ContentTypes().
|
||||
ByContentTypeId(cTypeID).
|
||||
ColumnLinks()
|
||||
links = make([]models.ColumnLinkable, 0)
|
||||
)
|
||||
|
||||
for {
|
||||
@ -396,7 +410,7 @@ func DeleteList(
|
||||
gs graph.Servicer,
|
||||
siteID, listID string,
|
||||
) error {
|
||||
err := gs.Client().SitesById(siteID).ListsById(listID).Delete(ctx, nil)
|
||||
err := gs.Client().Sites().BySiteId(siteID).Lists().ByListId(listID).Delete(ctx, nil)
|
||||
if err != nil {
|
||||
return graph.Wrap(ctx, err, "deleting list")
|
||||
}
|
||||
|
||||
@ -184,11 +184,7 @@ func restoreListItem(
|
||||
newList.SetItems(contents)
|
||||
|
||||
// Restore to List base to M365 back store
|
||||
restoredList, err := service.
|
||||
Client().
|
||||
SitesById(siteID).
|
||||
Lists().
|
||||
Post(ctx, newList, nil)
|
||||
restoredList, err := service.Client().Sites().BySiteId(siteID).Lists().Post(ctx, newList, nil)
|
||||
if err != nil {
|
||||
return dii, graph.Wrap(ctx, err, "restoring list")
|
||||
}
|
||||
@ -198,8 +194,10 @@ func restoreListItem(
|
||||
if len(contents) > 0 {
|
||||
for _, lItem := range contents {
|
||||
_, err := service.Client().
|
||||
SitesById(siteID).
|
||||
ListsById(ptr.Val(restoredList.GetId())).
|
||||
Sites().
|
||||
BySiteId(siteID).
|
||||
Lists().
|
||||
ByListId(ptr.Val(restoredList.GetId())).
|
||||
Items().
|
||||
Post(ctx, lItem, nil)
|
||||
if err != nil {
|
||||
|
||||
@ -213,7 +213,7 @@ func (suite *DataSupportSuite) TestCreatePageFromBytes() {
|
||||
pg.SetWebUrl(&title)
|
||||
|
||||
writer := kioser.NewJsonSerializationWriter()
|
||||
err := pg.Serialize(writer)
|
||||
err := writer.WriteObjectValue("", pg)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
byteArray, err := writer.GetSerializedContent()
|
||||
@ -231,6 +231,11 @@ func (suite *DataSupportSuite) TestCreatePageFromBytes() {
|
||||
result, err := CreatePageFromBytes(test.getBytes(t))
|
||||
test.checkError(t, err)
|
||||
test.isNil(t, result)
|
||||
if result != nil {
|
||||
assert.Equal(t, "Tested", *result.GetName(), "name")
|
||||
assert.Equal(t, "Tested", *result.GetTitle(), "title")
|
||||
assert.Equal(t, "Tested", *result.GetWebUrl(), "webURL")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/google/uuid"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drive"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/drives"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -982,8 +982,10 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
|
||||
_, err := gc.Service.
|
||||
Client().
|
||||
UsersById(uidn.ID()).
|
||||
MailFoldersById(from.containerID).
|
||||
Users().
|
||||
ByUserId(uidn.ID()).
|
||||
MailFolders().
|
||||
ByMailFolderId(from.containerID).
|
||||
Move().
|
||||
Post(ctx, body, nil)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
@ -1078,7 +1080,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
name: "rename a folder",
|
||||
updateUserData: func(t *testing.T) {
|
||||
for category, d := range dataset {
|
||||
cli := gc.Service.Client().UsersById(uidn.ID())
|
||||
cli := gc.Service.Client().Users().ByUserId(uidn.ID())
|
||||
containerID := d.dests[container3].containerID
|
||||
newLoc := containerRename
|
||||
|
||||
@ -1098,7 +1100,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
|
||||
switch category {
|
||||
case path.EmailCategory:
|
||||
cmf := cli.MailFoldersById(containerID)
|
||||
cmf := cli.MailFolders().ByMailFolderId(containerID)
|
||||
|
||||
body, err := cmf.Get(ctx, nil)
|
||||
require.NoError(t, err, "getting mail folder", clues.ToCore(err))
|
||||
@ -1108,7 +1110,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
require.NoError(t, err, "updating mail folder name", clues.ToCore(err))
|
||||
|
||||
case path.ContactsCategory:
|
||||
ccf := cli.ContactFoldersById(containerID)
|
||||
ccf := cli.ContactFolders().ByContactFolderId(containerID)
|
||||
|
||||
body, err := ccf.Get(ctx, nil)
|
||||
require.NoError(t, err, "getting contact folder", clues.ToCore(err))
|
||||
@ -1118,7 +1120,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
require.NoError(t, err, "updating contact folder name", clues.ToCore(err))
|
||||
|
||||
case path.EventsCategory:
|
||||
cbi := cli.CalendarsById(containerID)
|
||||
cbi := cli.Calendars().ByCalendarId(containerID)
|
||||
|
||||
body, err := cbi.Get(ctx, nil)
|
||||
require.NoError(t, err, "getting calendar", clues.ToCore(err))
|
||||
@ -1141,7 +1143,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
updateUserData: func(t *testing.T) {
|
||||
for category, d := range dataset {
|
||||
containerID := d.dests[container1].containerID
|
||||
cli := gc.Service.Client().UsersById(uidn.ID())
|
||||
cli := gc.Service.Client().Users().ByUserId(uidn.ID())
|
||||
|
||||
switch category {
|
||||
case path.EmailCategory:
|
||||
@ -1149,7 +1151,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
body, err := support.CreateMessageFromBytes(itemData)
|
||||
require.NoError(t, err, "transforming mail bytes to messageable", clues.ToCore(err))
|
||||
|
||||
itm, err := cli.MailFoldersById(containerID).Messages().Post(ctx, body, nil)
|
||||
itm, err := cli.MailFolders().ByMailFolderId(containerID).Messages().Post(ctx, body, nil)
|
||||
require.NoError(t, err, "posting email item", clues.ToCore(err))
|
||||
|
||||
expectDeets.AddItem(
|
||||
@ -1162,7 +1164,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
body, err := support.CreateContactFromBytes(itemData)
|
||||
require.NoError(t, err, "transforming contact bytes to contactable", clues.ToCore(err))
|
||||
|
||||
itm, err := cli.ContactFoldersById(containerID).Contacts().Post(ctx, body, nil)
|
||||
itm, err := cli.ContactFolders().ByContactFolderId(containerID).Contacts().Post(ctx, body, nil)
|
||||
require.NoError(t, err, "posting contact item", clues.ToCore(err))
|
||||
|
||||
expectDeets.AddItem(
|
||||
@ -1175,7 +1177,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
body, err := support.CreateEventFromBytes(itemData)
|
||||
require.NoError(t, err, "transforming event bytes to eventable", clues.ToCore(err))
|
||||
|
||||
itm, err := cli.CalendarsById(containerID).Events().Post(ctx, body, nil)
|
||||
itm, err := cli.Calendars().ByCalendarId(containerID).Events().Post(ctx, body, nil)
|
||||
require.NoError(t, err, "posting events item", clues.ToCore(err))
|
||||
|
||||
expectDeets.AddItem(
|
||||
@ -1195,7 +1197,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
updateUserData: func(t *testing.T) {
|
||||
for category, d := range dataset {
|
||||
containerID := d.dests[container1].containerID
|
||||
cli := gc.Service.Client().UsersById(uidn.ID())
|
||||
cli := gc.Service.Client().Users().ByUserId(uidn.ID())
|
||||
|
||||
switch category {
|
||||
case path.EmailCategory:
|
||||
@ -1203,7 +1205,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
require.NoError(t, err, "getting message ids", clues.ToCore(err))
|
||||
require.NotEmpty(t, ids, "message ids in folder")
|
||||
|
||||
err = cli.MessagesById(ids[0]).Delete(ctx, nil)
|
||||
err = cli.Messages().ByMessageId(ids[0]).Delete(ctx, nil)
|
||||
require.NoError(t, err, "deleting email item", clues.ToCore(err))
|
||||
|
||||
expectDeets.RemoveItem(
|
||||
@ -1216,7 +1218,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
require.NoError(t, err, "getting contact ids", clues.ToCore(err))
|
||||
require.NotEmpty(t, ids, "contact ids in folder")
|
||||
|
||||
err = cli.ContactsById(ids[0]).Delete(ctx, nil)
|
||||
err = cli.Contacts().ByContactId(ids[0]).Delete(ctx, nil)
|
||||
require.NoError(t, err, "deleting contact item", clues.ToCore(err))
|
||||
|
||||
expectDeets.RemoveItem(
|
||||
@ -1229,7 +1231,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
||||
require.NoError(t, err, "getting event ids", clues.ToCore(err))
|
||||
require.NotEmpty(t, ids, "event ids in folder")
|
||||
|
||||
err = cli.CalendarsById(ids[0]).Delete(ctx, nil)
|
||||
err = cli.Calendars().ByCalendarId(ids[0]).Delete(ctx, nil)
|
||||
require.NoError(t, err, "deleting calendar", clues.ToCore(err))
|
||||
|
||||
expectDeets.RemoveItem(
|
||||
@ -1499,8 +1501,8 @@ func runDriveIncrementalTest(
|
||||
// Use path-based indexing to get the folder's ID. This is sourced from the
|
||||
// onedrive package `getFolder` function.
|
||||
itemURL := fmt.Sprintf("https://graph.microsoft.com/v1.0/drives/%s/root:/%s", driveID, destName)
|
||||
resp, err := drive.
|
||||
NewItemsDriveItemItemRequestBuilder(itemURL, gc.Service.Adapter()).
|
||||
resp, err := drives.
|
||||
NewItemItemsDriveItemItemRequestBuilder(itemURL, gc.Service.Adapter()).
|
||||
Get(ctx, nil)
|
||||
require.NoError(t, err, "getting drive folder ID", "folder name", destName, clues.ToCore(err))
|
||||
|
||||
@ -1659,10 +1661,12 @@ func runDriveIncrementalTest(
|
||||
{
|
||||
name: "update contents of a file",
|
||||
updateFiles: func(t *testing.T) {
|
||||
err := gc.Service.
|
||||
_, err := gc.Service.
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(ptr.Val(newFile.GetId())).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(ptr.Val(newFile.GetId())).
|
||||
Content().
|
||||
Put(ctx, []byte("new content"), nil)
|
||||
require.NoErrorf(t, err, "updating file contents: %v", clues.ToCore(err))
|
||||
@ -1685,8 +1689,10 @@ func runDriveIncrementalTest(
|
||||
|
||||
_, err := gc.Service.
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(ptr.Val(newFile.GetId())).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(ptr.Val(newFile.GetId())).
|
||||
Patch(ctx, driveItem, nil)
|
||||
require.NoError(t, err, "renaming file %v", clues.ToCore(err))
|
||||
},
|
||||
@ -1707,8 +1713,10 @@ func runDriveIncrementalTest(
|
||||
|
||||
_, err := gc.Service.
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(ptr.Val(newFile.GetId())).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(ptr.Val(newFile.GetId())).
|
||||
Patch(ctx, driveItem, nil)
|
||||
require.NoErrorf(t, err, "moving file between folders %v", clues.ToCore(err))
|
||||
|
||||
@ -1728,8 +1736,10 @@ func runDriveIncrementalTest(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
err = newDeleteServicer(t).
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(ptr.Val(newFile.GetId())).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(ptr.Val(newFile.GetId())).
|
||||
Delete(ctx, nil)
|
||||
require.NoErrorf(t, err, "deleting file %v", clues.ToCore(err))
|
||||
|
||||
@ -1752,8 +1762,10 @@ func runDriveIncrementalTest(
|
||||
|
||||
_, err := gc.Service.
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(child).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(child).
|
||||
Patch(ctx, driveItem, nil)
|
||||
require.NoError(t, err, "moving folder", clues.ToCore(err))
|
||||
|
||||
@ -1779,8 +1791,10 @@ func runDriveIncrementalTest(
|
||||
|
||||
_, err := gc.Service.
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(child).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(child).
|
||||
Patch(ctx, driveItem, nil)
|
||||
require.NoError(t, err, "renaming folder", clues.ToCore(err))
|
||||
|
||||
@ -1802,8 +1816,10 @@ func runDriveIncrementalTest(
|
||||
// https://github.com/alcionai/corso/issues/2707
|
||||
err = newDeleteServicer(t).
|
||||
Client().
|
||||
DrivesById(driveID).
|
||||
ItemsById(container).
|
||||
Drives().
|
||||
ByDriveId(driveID).
|
||||
Items().
|
||||
ByDriveItemId(container).
|
||||
Delete(ctx, nil)
|
||||
require.NoError(t, err, "deleting folder", clues.ToCore(err))
|
||||
|
||||
@ -1833,7 +1849,7 @@ func runDriveIncrementalTest(
|
||||
"https://graph.microsoft.com/v1.0/drives/%s/root:/%s",
|
||||
driveID,
|
||||
container3)
|
||||
resp, err := drive.NewItemsDriveItemItemRequestBuilder(itemURL, gc.Service.Adapter()).
|
||||
resp, err := drives.NewItemItemsDriveItemItemRequestBuilder(itemURL, gc.Service.Adapter()).
|
||||
Get(ctx, nil)
|
||||
require.NoError(t, err, "getting drive folder ID", "folder name", container3, clues.ToCore(err))
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable,
|
||||
return nil, graph.Wrap(ctx, err, "getting all sites")
|
||||
}
|
||||
|
||||
iter, err := msgraphgocore.NewPageIterator(
|
||||
iter, err := msgraphgocore.NewPageIterator[models.Siteable](
|
||||
resp,
|
||||
service.Adapter(),
|
||||
models.CreateSiteCollectionResponseFromDiscriminatorValue)
|
||||
@ -60,12 +60,12 @@ func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable,
|
||||
el = errs.Local()
|
||||
)
|
||||
|
||||
iterator := func(item any) bool {
|
||||
iterator := func(item models.Siteable) bool {
|
||||
if el.Failure() != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
s, err := validateSite(item)
|
||||
err := validateSite(item)
|
||||
if errors.Is(err, errKnownSkippableCase) {
|
||||
// safe to no-op
|
||||
return true
|
||||
@ -76,7 +76,7 @@ func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable,
|
||||
return true
|
||||
}
|
||||
|
||||
us = append(us, s)
|
||||
us = append(us, item)
|
||||
|
||||
return true
|
||||
}
|
||||
@ -109,7 +109,7 @@ func (c Sites) GetByID(ctx context.Context, identifier string) (models.Siteable,
|
||||
ctx = clues.Add(ctx, "given_site_id", identifier)
|
||||
|
||||
if siteIDRE.MatchString(identifier) {
|
||||
resp, err = c.stable.Client().SitesById(identifier).Get(ctx, nil)
|
||||
resp, err = c.stable.Client().Sites().BySiteId(identifier).Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting site by id")
|
||||
}
|
||||
@ -168,38 +168,33 @@ const personalSitePath = "sharepoint.com/personal/"
|
||||
// validateSite ensures the item is a Siteable, and contains the necessary
|
||||
// identifiers that we handle with all users.
|
||||
// returns the item as a Siteable model.
|
||||
func validateSite(item any) (models.Siteable, error) {
|
||||
m, ok := item.(models.Siteable)
|
||||
if !ok {
|
||||
return nil, clues.New(fmt.Sprintf("unexpected model: %T", item))
|
||||
}
|
||||
|
||||
id := ptr.Val(m.GetId())
|
||||
func validateSite(item models.Siteable) error {
|
||||
id := ptr.Val(item.GetId())
|
||||
if len(id) == 0 {
|
||||
return nil, clues.New("missing ID")
|
||||
return clues.New("missing ID")
|
||||
}
|
||||
|
||||
wURL := ptr.Val(m.GetWebUrl())
|
||||
wURL := ptr.Val(item.GetWebUrl())
|
||||
if len(wURL) == 0 {
|
||||
return nil, clues.New("missing webURL").With("site_id", id) // TODO: pii
|
||||
return clues.New("missing webURL").With("site_id", id) // TODO: pii
|
||||
}
|
||||
|
||||
// personal (ie: oneDrive) sites have to be filtered out server-side.
|
||||
if strings.Contains(wURL, personalSitePath) {
|
||||
return nil, clues.Stack(errKnownSkippableCase).
|
||||
return clues.Stack(errKnownSkippableCase).
|
||||
With("site_id", id, "site_web_url", wURL) // TODO: pii
|
||||
}
|
||||
|
||||
name := ptr.Val(m.GetDisplayName())
|
||||
name := ptr.Val(item.GetDisplayName())
|
||||
if len(name) == 0 {
|
||||
// the built-in site at "https://{tenant-domain}/search" never has a name.
|
||||
if strings.HasSuffix(wURL, "/search") {
|
||||
return nil, clues.Stack(errKnownSkippableCase).
|
||||
return clues.Stack(errKnownSkippableCase).
|
||||
With("site_id", id, "site_web_url", wURL) // TODO: pii
|
||||
}
|
||||
|
||||
return nil, clues.New("missing site display name").With("site_id", id)
|
||||
return clues.New("missing site display name").With("site_id", id)
|
||||
}
|
||||
|
||||
return m, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -33,16 +33,10 @@ func (suite *SitesUnitSuite) TestValidateSite() {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args any
|
||||
want models.Siteable
|
||||
args models.Siteable
|
||||
errCheck assert.ErrorAssertionFunc
|
||||
errIsSkippable bool
|
||||
}{
|
||||
{
|
||||
name: "Invalid type",
|
||||
args: string("invalid type"),
|
||||
errCheck: assert.Error,
|
||||
},
|
||||
{
|
||||
name: "No ID",
|
||||
args: models.NewSite(),
|
||||
@ -92,7 +86,6 @@ func (suite *SitesUnitSuite) TestValidateSite() {
|
||||
{
|
||||
name: "Valid Site",
|
||||
args: site,
|
||||
want: site,
|
||||
errCheck: assert.NoError,
|
||||
},
|
||||
}
|
||||
@ -100,14 +93,12 @@ func (suite *SitesUnitSuite) TestValidateSite() {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
got, err := validateSite(test.args)
|
||||
err := validateSite(test.args)
|
||||
test.errCheck(t, err, clues.ToCore(err))
|
||||
|
||||
if test.errIsSkippable {
|
||||
assert.ErrorIs(t, err, errKnownSkippableCase)
|
||||
}
|
||||
|
||||
assert.Equal(t, test.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ func (c Users) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Userable,
|
||||
return nil, graph.Wrap(ctx, err, "getting all users")
|
||||
}
|
||||
|
||||
iter, err := msgraphgocore.NewPageIterator(
|
||||
iter, err := msgraphgocore.NewPageIterator[models.Userable](
|
||||
resp,
|
||||
service.Adapter(),
|
||||
models.CreateUserCollectionResponseFromDiscriminatorValue)
|
||||
@ -184,16 +184,16 @@ func (c Users) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Userable,
|
||||
el = errs.Local()
|
||||
)
|
||||
|
||||
iterator := func(item any) bool {
|
||||
iterator := func(item models.Userable) bool {
|
||||
if el.Failure() != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
u, err := validateUser(item)
|
||||
err := validateUser(item)
|
||||
if err != nil {
|
||||
el.AddRecoverable(graph.Wrap(ctx, err, "validating user"))
|
||||
} else {
|
||||
us = append(us, u)
|
||||
us = append(us, item)
|
||||
}
|
||||
|
||||
return true
|
||||
@ -214,7 +214,7 @@ func (c Users) GetByID(ctx context.Context, identifier string) (models.Userable,
|
||||
err error
|
||||
)
|
||||
|
||||
resp, err = c.stable.Client().UsersById(identifier).Get(ctx, nil)
|
||||
resp, err = c.stable.Client().Users().ByUserId(identifier).Get(ctx, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting user")
|
||||
@ -316,8 +316,10 @@ func (c Users) GetInfo(ctx context.Context, userID string) (*UserInfo, error) {
|
||||
},
|
||||
}
|
||||
_, err = c.stable.Client().
|
||||
UsersById(userID).
|
||||
MailFoldersById(ptr.Val(mf.GetId())).
|
||||
Users().
|
||||
ByUserId(userID).
|
||||
MailFolders().
|
||||
ByMailFolderId(ptr.Val(mf.GetId())).
|
||||
Messages().
|
||||
Delta().
|
||||
Get(ctx, options)
|
||||
@ -338,7 +340,7 @@ func (c Users) GetMailFolders(
|
||||
userID string,
|
||||
options users.ItemMailFoldersRequestBuilderGetRequestConfiguration,
|
||||
) (models.MailFolderCollectionResponseable, error) {
|
||||
mailFolders, err := c.stable.Client().UsersById(userID).MailFolders().Get(ctx, &options)
|
||||
mailFolders, err := c.stable.Client().Users().ByUserId(userID).MailFolders().Get(ctx, &options)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting MailFolders")
|
||||
}
|
||||
@ -348,7 +350,7 @@ func (c Users) GetMailFolders(
|
||||
|
||||
// TODO: remove when drive api goes into this package
|
||||
func (c Users) GetDrives(ctx context.Context, userID string) (models.DriveCollectionResponseable, error) {
|
||||
drives, err := c.stable.Client().UsersById(userID).Drives().Get(ctx, nil)
|
||||
drives, err := c.stable.Client().Users().ByUserId(userID).Drives().Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, graph.Wrap(ctx, err, "getting drives")
|
||||
}
|
||||
@ -497,22 +499,16 @@ func appendIfErr(errs []error, err error) []error {
|
||||
|
||||
// validateUser ensures the item is a Userable, and contains the necessary
|
||||
// identifiers that we handle with all users.
|
||||
// returns the item as a Userable model.
|
||||
func validateUser(item any) (models.Userable, error) {
|
||||
m, ok := item.(models.Userable)
|
||||
if !ok {
|
||||
return nil, clues.New(fmt.Sprintf("unexpected model: %T", item))
|
||||
func validateUser(item models.Userable) error {
|
||||
if item.GetId() == nil {
|
||||
return clues.New("missing ID")
|
||||
}
|
||||
|
||||
if m.GetId() == nil {
|
||||
return nil, clues.New("missing ID")
|
||||
if item.GetUserPrincipalName() == nil {
|
||||
return clues.New("missing principalName")
|
||||
}
|
||||
|
||||
if m.GetUserPrincipalName() == nil {
|
||||
return nil, clues.New("missing principalName")
|
||||
}
|
||||
|
||||
return m, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func toString(ctx context.Context, key string, data map[string]any) (string, error) {
|
||||
|
||||
@ -30,15 +30,9 @@ func (suite *UsersUnitSuite) TestValidateUser() {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args interface{}
|
||||
want models.Userable
|
||||
args models.Userable
|
||||
errCheck assert.ErrorAssertionFunc
|
||||
}{
|
||||
{
|
||||
name: "Invalid type",
|
||||
args: string("invalid type"),
|
||||
errCheck: assert.Error,
|
||||
},
|
||||
{
|
||||
name: "No ID",
|
||||
args: models.NewUser(),
|
||||
@ -56,7 +50,6 @@ func (suite *UsersUnitSuite) TestValidateUser() {
|
||||
{
|
||||
name: "Valid User",
|
||||
args: user,
|
||||
want: user,
|
||||
errCheck: assert.NoError,
|
||||
},
|
||||
}
|
||||
@ -64,10 +57,8 @@ func (suite *UsersUnitSuite) TestValidateUser() {
|
||||
suite.Run(tt.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
got, err := validateUser(tt.args)
|
||||
err := validateUser(tt.args)
|
||||
tt.errCheck(t, err, clues.ToCore(err))
|
||||
|
||||
assert.Equal(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user