GC: Go.Mod update (#1479)

## Description
Versioning upgraded for GC
Packages updated:
- [x] github.com/microsoftgraph/msgraph-sdk-go v0.41.0 => v0.48.0
- [x] github.com/microsoft/kiota-abstractions-go v0.14.0
- [x] github.com/microsoft/kiota-authentication-azure-go v0.5.0
- [x] github.com/microsoft/kiota-http-go v0.9.0
- [x] github.com/microsoft/kiota-serialization-json-go v0.7.2
- [x] github.com/microsoftgraph/msgraph-sdk-go-core v0.30.1
- [x] github.com/stretchr/testify v1.8.1
- [x] github.com/cjlapao/common-go v0.0.29 => v0.0.35

<!-- Insert PR description-->

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🐹 Trivial/Minor
- Update library change. AdditionalData no longer contains `nextLink` for iteration.  See commit [e7c75ca](e7c75ca1cc) for full details. 

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
*closes #1478<issue>

## Test Plan

- [x]  Unit test
This commit is contained in:
Danny 2022-12-08 16:54:22 -05:00 committed by GitHub
parent 53195017a1
commit 45e535c9b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 195 additions and 424 deletions

View File

@ -9,12 +9,12 @@ require (
github.com/google/uuid v1.3.0
github.com/hashicorp/go-multierror v1.1.1
github.com/kopia/kopia v0.12.0
github.com/microsoft/kiota-abstractions-go v0.11.0
github.com/microsoft/kiota-authentication-azure-go v0.4.1
github.com/microsoft/kiota-http-go v0.7.2
github.com/microsoft/kiota-serialization-json-go v0.7.1
github.com/microsoftgraph/msgraph-sdk-go v0.40.0
github.com/microsoftgraph/msgraph-sdk-go-core v0.28.1
github.com/microsoft/kiota-abstractions-go v0.14.0
github.com/microsoft/kiota-authentication-azure-go v0.5.0
github.com/microsoft/kiota-http-go v0.9.0
github.com/microsoft/kiota-serialization-json-go v0.7.2
github.com/microsoftgraph/msgraph-sdk-go v0.48.0
github.com/microsoftgraph/msgraph-sdk-go-core v0.30.1
github.com/pkg/errors v0.9.1
github.com/rudderlabs/analytics-go v3.3.3+incompatible
github.com/spf13/cobra v1.6.1
@ -49,14 +49,14 @@ require (
)
require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.3 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1 // 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
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chmduquesne/rollinghash v4.0.0+incompatible // indirect
github.com/cjlapao/common-go v0.0.27 // indirect
github.com/cjlapao/common-go v0.0.35 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.0
github.com/edsrzf/mmap-go v1.1.0 // indirect
@ -103,8 +103,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.10.0 // indirect
go.opentelemetry.io/otel/trace v1.10.0 // indirect
go.opentelemetry.io/otel v1.11.2 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.1.0 // indirect

View File

@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
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.1.3 h1:8LoU8N2lIUzkmstvwXvVfniMZlFbesfT2AmA1aqvRr8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.3/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 h1:sVW/AFBTGyJxDaMYlq0ct3jUXTtj12tQ6zE2GZUgVQw=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1 h1:XUNQ4mw+zJmaA2KXzP9JlQiecy1SI+Eog7xVkPiqIbg=
@ -78,8 +78,8 @@ github.com/chmduquesne/rollinghash v4.0.0+incompatible/go.mod h1:Uc2I36RRfTAf7Dg
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cjlapao/common-go v0.0.27 h1:7k8R1Mz2LAudnPb1kaqQ/l+Ba7uL92FG7Rqp9W67mGM=
github.com/cjlapao/common-go v0.0.27/go.mod h1:OyTAY388jfEj8uaRzx0uYneFghKDLL5KP+ewSydlQ5g=
github.com/cjlapao/common-go v0.0.35 h1:GElDHYC9qAAMDozfDOArl1ayn+W+X90mogcS38Y8d3k=
github.com/cjlapao/common-go v0.0.35/go.mod h1:WkUjw+hVbUDfzcnRymlU5VT/HBzv5xPs9tIJJ1XrQCU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
@ -257,20 +257,20 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2 h1:hAHbPm5IJGijwng3PWk09
github.com/matttproud/golang_protobuf_extensions v1.0.2/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/microsoft/kiota-abstractions-go v0.11.0 h1:JSelh3pj9CQlSYNYIpCUcE60flTR5Ninc+XnF4nC/FI=
github.com/microsoft/kiota-abstractions-go v0.11.0/go.mod h1:wOO+hpReDIJa3BxbLNz4qvtZk2llS555mejkMc203bQ=
github.com/microsoft/kiota-authentication-azure-go v0.4.1 h1:C+n4Vp3oCj8W8LPiKZDyASTNaKyUomQtUiXQ+B2W0TU=
github.com/microsoft/kiota-authentication-azure-go v0.4.1/go.mod h1:jIJAhpPh34bDQWNME65kd/yjqY6+CJZi5jus8H9EH4s=
github.com/microsoft/kiota-http-go v0.7.2 h1:R40vG0EkIFqGvVz5dZtLe4g1sXGVfBO5HxjdBjpwv8k=
github.com/microsoft/kiota-http-go v0.7.2/go.mod h1:QTbXPh25mJsbxE23bFqw64BckCioCGfaE77hF/F3rIQ=
github.com/microsoft/kiota-serialization-json-go v0.7.1 h1:hmO3Jqp6szJKn9Y2sGHwa3zM8a4RqnioyK/X1zFOuWk=
github.com/microsoft/kiota-serialization-json-go v0.7.1/go.mod h1:mqCksNRbL3AAqkt5C1vrw8giqpwG2NYa/+7Kf/Q4ZUw=
github.com/microsoft/kiota-abstractions-go v0.14.0 h1:TCYk1+CoBFNhTefKu8OTky4w4HnOoD72EJOeTsTNml8=
github.com/microsoft/kiota-abstractions-go v0.14.0/go.mod h1:/zQPz5M7868/bbN8D4tZHhnOE23Tcc/JBKSNwljOch4=
github.com/microsoft/kiota-authentication-azure-go v0.5.0 h1:RVA/tTgMnDIN3u4qPZtvYvVRsQDOFkd3yvi6KXjZJko=
github.com/microsoft/kiota-authentication-azure-go v0.5.0/go.mod h1:1Io6h+88FlDRmrajdjSnXPz8oyObUVjNuQZLhrF9kQk=
github.com/microsoft/kiota-http-go v0.9.0 h1:q/JZpWOvHFbxrOjbd8pbODuTx4dlcLahTemM48di/y8=
github.com/microsoft/kiota-http-go v0.9.0/go.mod h1:F652dnY3jVNmwSk46qHXt+HeEbxLkbbn3dUi3lSLHws=
github.com/microsoft/kiota-serialization-json-go v0.7.2 h1:DSb4fNDi5O+DqJwrHo+vRy2kSvfxG5VtN6m1EHzn5Vw=
github.com/microsoft/kiota-serialization-json-go v0.7.2/go.mod h1:Ojum5prlijopyCOZ2XctRcVlE2pU8h+43r3tMdiWoDU=
github.com/microsoft/kiota-serialization-text-go v0.6.0 h1:3N2vftYZlwKdog69AN7ha+FZT0QxPG7xp/hLv0/W2OQ=
github.com/microsoft/kiota-serialization-text-go v0.6.0/go.mod h1:OUA4dNH+f6afiJUs+rQAatJos7QVF5PJkyrqoD89lx4=
github.com/microsoftgraph/msgraph-sdk-go v0.40.0 h1:9AxA3FS+S3c7Him5C+7Lt0I8zaNXoSqXsLDink1Fg40=
github.com/microsoftgraph/msgraph-sdk-go v0.40.0/go.mod h1:B8HORKdf1K05Z93FbkpiqJ25dnytjPEyAby6gHhOLiM=
github.com/microsoftgraph/msgraph-sdk-go-core v0.28.1 h1:gN3pVVvx50KzhQdYwQKVnRSOSOIRaFpXj7pgPfqnNXw=
github.com/microsoftgraph/msgraph-sdk-go-core v0.28.1/go.mod h1:BnumnwWU8xUgX7ncgo68novbS1wMlO66Iny9iVhvHuM=
github.com/microsoftgraph/msgraph-sdk-go v0.48.0 h1:N93MVg4LgM45lK70PNTRaKCk5kw8sdfgHTXS0qc1VFg=
github.com/microsoftgraph/msgraph-sdk-go v0.48.0/go.mod h1:I2iR+gJmKiZZ8ebE8mKQEiKXpePAahAIazx3F1kL6og=
github.com/microsoftgraph/msgraph-sdk-go-core v0.30.1 h1:jBuYexMqKnjsnQpyICfdu0RhZr7RFkEcKWRm3hf/jMM=
github.com/microsoftgraph/msgraph-sdk-go-core v0.30.1/go.mod h1:RyqsMRKmZADSA/feLQMcynQJRENMzKM/Wg4dgQ/lW+s=
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.39 h1:upnbu1jCGOqEvrGSpRauSN9ZG7RCHK7VHxXS8Vmg2zk=
@ -410,10 +410,10 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
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.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4=
go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ=
go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E=
go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM=
go.opentelemetry.io/otel v1.11.2 h1:YBZcQlsVekzFsFbjygXMOXSs6pialIZxcjfO/mBDmR0=
go.opentelemetry.io/otel v1.11.2/go.mod h1:7p4EUV+AqgdlNV9gL97IgUZiVR3yrFXYo53f9BM3tRI=
go.opentelemetry.io/otel/trace v1.11.2 h1:Xf7hWSF2Glv0DE3MH7fBHvtpSBsjcBUe5MYAmZM/+y0=
go.opentelemetry.io/otel/trace v1.11.2/go.mod h1:4N+yC7QEz7TTsG9BSRLNAa63eg5E06ObSbKPmxQ/pKA=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=

View File

@ -4,8 +4,6 @@ import (
"context"
"github.com/microsoftgraph/msgraph-sdk-go/models"
ups "github.com/microsoftgraph/msgraph-sdk-go/users/item/calendars/item/events/item/attachments/createuploadsession"
"github.com/microsoftgraph/msgraph-sdk-go/users/item/messages/item/attachments/createuploadsession"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector/graph"
@ -57,7 +55,7 @@ func (mau *mailAttachmentUploader) uploadSession(
attachmentName string,
attachmentSize int64,
) (models.UploadSessionable, error) {
session := createuploadsession.NewCreateUploadSessionPostRequestBody()
session := models.NewUsersItemMailFoldersItemMessagesItemAttachmentsCreateUploadSessionPostRequestBody()
session.SetAttachmentItem(makeSessionAttachment(attachmentName, attachmentSize))
r, err := mau.service.Client().UsersById(mau.userID).MailFoldersById(mau.folderID).
@ -105,7 +103,7 @@ func (eau *eventAttachmentUploader) uploadSession(
attachmentName string,
attachmentSize int64,
) (models.UploadSessionable, error) {
session := ups.NewCreateUploadSessionPostRequestBody()
session := models.NewUsersItemCalendarEventsItemAttachmentsCreateUploadSessionPostRequestBody()
session.SetAttachmentItem(makeSessionAttachment(attachmentName, attachmentSize))
r, err := eau.service.Client().

View File

@ -3,7 +3,7 @@ package exchange
import (
"context"
cf "github.com/microsoftgraph/msgraph-sdk-go/users/item/contactfolders/item/childfolders"
msuser "github.com/microsoftgraph/msgraph-sdk-go/users"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector/graph"
@ -117,7 +117,7 @@ func (cfc *contactFolderCache) Populate(
break
}
builder = cf.NewChildFoldersRequestBuilder(*resp.GetOdataNextLink(), cfc.gs.Adapter())
builder = msuser.NewUsersItemContactFoldersItemChildFoldersRequestBuilder(*resp.GetOdataNextLink(), cfc.gs.Adapter())
}
if err := cfc.populatePaths(ctx); err != nil {

View File

@ -1,121 +0,0 @@
package exchange
import (
"context"
abs "github.com/microsoft/kiota-abstractions-go"
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
mscontactdelta "github.com/microsoftgraph/msgraph-sdk-go/users/item/contactfolders/item/contacts/delta"
msmaildelta "github.com/microsoftgraph/msgraph-sdk-go/users/item/mailfolders/item/messages/delta"
)
//nolint:lll
const (
mailURLTemplate = "{+baseurl}/users/{user%2Did}/mailFolders/{mailFolder%2Did}/messages/microsoft.graph.delta(){?%24top,%24skip,%24search,%24filter,%24count,%24select,%24orderby}"
contactsURLTemplate = "{+baseurl}/users/{user%2Did}/contactFolders/{contactFolder%2Did}/contacts/microsoft.graph.delta(){?%24top,%24skip,%24search,%24filter,%24count,%24select,%24orderby}"
)
// The following functions are based off the code in v0.41.0 of msgraph-sdk-go
// for sending delta requests with query parameters.
func createGetRequestInformationWithRequestConfiguration(
baseRequestInfoFunc func() (*abs.RequestInformation, error),
requestConfig *DeltaRequestBuilderGetRequestConfiguration,
template string,
) (*abs.RequestInformation, error) {
requestInfo, err := baseRequestInfoFunc()
if err != nil {
return nil, err
}
requestInfo.UrlTemplate = template
if requestConfig != nil {
if requestConfig.QueryParameters != nil {
requestInfo.AddQueryParameters(*(requestConfig.QueryParameters))
}
requestInfo.AddRequestHeaders(requestConfig.Headers)
requestInfo.AddRequestOptions(requestConfig.Options)
}
return requestInfo, nil
}
func sendMessagesDeltaGet(
ctx context.Context,
m *msmaildelta.DeltaRequestBuilder,
requestConfiguration *DeltaRequestBuilderGetRequestConfiguration,
adapter abs.RequestAdapter,
) (msmaildelta.DeltaResponseable, error) {
requestInfo, err := createGetRequestInformationWithRequestConfiguration(
func() (*abs.RequestInformation, error) {
return m.CreateGetRequestInformationWithRequestConfiguration(nil)
},
requestConfiguration,
mailURLTemplate,
)
if err != nil {
return nil, err
}
errorMapping := abs.ErrorMappings{
"4XX": odataerrors.CreateODataErrorFromDiscriminatorValue,
"5XX": odataerrors.CreateODataErrorFromDiscriminatorValue,
}
res, err := adapter.SendAsync(
ctx,
requestInfo,
msmaildelta.CreateDeltaResponseFromDiscriminatorValue,
errorMapping,
)
if err != nil {
return nil, err
}
if res == nil {
return nil, nil
}
return res.(msmaildelta.DeltaResponseable), nil
}
func sendContactsDeltaGet(
ctx context.Context,
m *mscontactdelta.DeltaRequestBuilder,
requestConfiguration *DeltaRequestBuilderGetRequestConfiguration,
adapter abs.RequestAdapter,
) (mscontactdelta.DeltaResponseable, error) {
requestInfo, err := createGetRequestInformationWithRequestConfiguration(
func() (*abs.RequestInformation, error) {
return m.CreateGetRequestInformationWithRequestConfiguration(nil)
},
requestConfiguration,
contactsURLTemplate,
)
if err != nil {
return nil, err
}
errorMapping := abs.ErrorMappings{
"4XX": odataerrors.CreateODataErrorFromDiscriminatorValue,
"5XX": odataerrors.CreateODataErrorFromDiscriminatorValue,
}
res, err := adapter.SendAsync(
ctx,
requestInfo,
mscontactdelta.CreateDeltaResponseFromDiscriminatorValue,
errorMapping,
)
if err != nil {
return nil, err
}
if res == nil {
return nil, nil
}
return res.(mscontactdelta.DeltaResponseable), nil
}

View File

@ -3,7 +3,7 @@ package exchange
import (
"context"
mscal "github.com/microsoftgraph/msgraph-sdk-go/users/item/calendars"
msuser "github.com/microsoftgraph/msgraph-sdk-go/users"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector/graph"
@ -68,7 +68,7 @@ func (ecc *eventCalendarCache) Populate(
break
}
builder = mscal.NewCalendarsRequestBuilder(*resp.GetOdataNextLink(), ecc.gs.Adapter())
builder = msuser.NewUsersItemCalendarsRequestBuilder(*resp.GetOdataNextLink(), ecc.gs.Adapter())
}
for _, container := range directories {

View File

@ -120,42 +120,6 @@ func (suite *ExchangeServiceSuite) TestOptionsForCalendars() {
}
}
// TestOptionsForMessages checks to ensure approved query
// options are added to the type specific RequestBuildConfiguration. Expected
// will be +1 on all select parameters
func (suite *ExchangeServiceSuite) TestOptionsForMessages() {
tests := []struct {
name string
params []string
checkError assert.ErrorAssertionFunc
}{
{
name: "Valid Message Option",
params: []string{"subject"},
checkError: assert.NoError,
},
{
name: "Multiple Message Options: Accepted",
params: []string{"webLink", "parentFolderId"},
checkError: assert.NoError,
},
{
name: "Invalid Message Parameter",
params: []string{"status"},
checkError: assert.Error,
},
}
for _, test := range tests {
suite.T().Run(test.name, func(t *testing.T) {
config, err := optionsForMessages(test.params)
test.checkError(t, err)
if err == nil {
suite.Equal(len(config.QueryParameters.Select), len(test.params)+1)
}
})
}
}
// TestOptionsForFolders ensures that approved query options
// are added to the RequestBuildConfiguration. Expected will always be +1
// on than the input as "id" are always included within the select parameters

View File

@ -38,10 +38,4 @@ const (
rootFolderAlias = "msgfolderroot"
DefaultContactFolder = "Contacts"
DefaultCalendar = "Calendar"
// ----------------------------------
// Paging
// ----------------------------------
// nextDataLink definition https://docs.microsoft.com/en-us/graph/paging
nextDataLink = "@odata.nextLink"
)

View File

@ -4,7 +4,7 @@ import (
"context"
multierror "github.com/hashicorp/go-multierror"
msfolderdelta "github.com/microsoftgraph/msgraph-sdk-go/users/item/mailfolders/item/childfolders/delta"
msfolderdelta "github.com/microsoftgraph/msgraph-sdk-go/users"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector/graph"
@ -23,16 +23,13 @@ type mailFolderCache struct {
userID string
}
// populateMailRoot fetches and populates the "base" directory from user's inbox.
// populateMailRoot manually fetches directories that are not returned during Graph for msgraph-sdk-go v. 40+
// rootFolderAlias is the top-level directory for exchange.Mail.
// DefaultMailFolder is the traditional "Inbox" for exchange.Mail
// Action ensures that cache will stop at appropriate level.
// @param directory: M365 ID of the root all intended inquiries.
// Function should only be used directly when it is known that all
// folder inquiries are going to a specific node. In all other cases
// @error iff the struct is not properly instantiated
func (mc *mailFolderCache) populateMailRoot(
ctx context.Context,
directoryID string,
baseContainerPath []string,
) error {
wantedOpts := []string{"displayName", "parentFolderId"}
@ -41,23 +38,31 @@ func (mc *mailFolderCache) populateMailRoot(
return errors.Wrapf(err, "getting options for mail folders %v", wantedOpts)
}
f, err := mc.
gs.
Client().
UsersById(mc.userID).
MailFoldersById(directoryID).
Get(ctx, opts)
if err != nil {
return errors.Wrap(err, "fetching root folder"+support.ConnectorStackErrorTrace(err))
}
for _, fldr := range []string{rootFolderAlias, DefaultMailFolder} {
var directory string
temp := cacheFolder{
Container: f,
p: path.Builder{}.Append(baseContainerPath...),
}
f, err := mc.
gs.
Client().
UsersById(mc.userID).
MailFoldersById(fldr).
Get(ctx, opts)
if err != nil {
return errors.Wrap(err, "fetching root folder"+support.ConnectorStackErrorTrace(err))
}
if err := mc.addFolder(temp); err != nil {
return errors.Wrap(err, "initializing mail resolver")
if fldr == DefaultMailFolder {
directory = DefaultMailFolder
}
temp := cacheFolder{
Container: f,
p: path.Builder{}.Append(directory),
}
if err := mc.addFolder(temp); err != nil {
return errors.Wrap(err, "initializing mail resolver")
}
}
return nil
@ -73,7 +78,7 @@ func (mc *mailFolderCache) Populate(
baseID string,
baseContainerPath ...string,
) error {
if err := mc.init(ctx, baseID, baseContainerPath); err != nil {
if err := mc.init(ctx); err != nil {
return err
}
@ -81,13 +86,11 @@ func (mc *mailFolderCache) Populate(
gs.
Client().
UsersById(mc.userID).
MailFoldersById(baseID).ChildFolders().
MailFolders().
Delta()
var errs *multierror.Error
// TODO: Cannot use Iterator for delta
// Awaiting resolution: https://github.com/microsoftgraph/msgraph-sdk-go/issues/272
for {
resp, err := query.Get(ctx, nil)
if err != nil {
@ -108,15 +111,12 @@ func (mc *mailFolderCache) Populate(
}
}
r := resp.GetAdditionalData()
n, ok := r[nextDataLink]
if !ok || n == nil {
link := resp.GetOdataNextLink()
if link == nil {
break
}
link := *(n.(*string))
query = msfolderdelta.NewDeltaRequestBuilder(link, mc.gs.Adapter())
query = msfolderdelta.NewUsersItemMailFoldersDeltaRequestBuilder(*link, mc.gs.Adapter())
}
if err := mc.populatePaths(ctx); err != nil {
@ -131,16 +131,10 @@ func (mc *mailFolderCache) Populate(
// [mc.cache]
func (mc *mailFolderCache) init(
ctx context.Context,
baseNode string,
baseContainerPath []string,
) error {
if len(baseNode) == 0 {
return errors.New("m365 folder ID required for base folder")
}
if mc.containerResolver == nil {
mc.containerResolver = newContainerResolver()
}
return mc.populateMailRoot(ctx, baseNode, baseContainerPath)
return mc.populateMailRoot(ctx)
}

View File

@ -3,18 +3,7 @@ package exchange
import (
"fmt"
abs "github.com/microsoft/kiota-abstractions-go"
mscalendars "github.com/microsoftgraph/msgraph-sdk-go/users/item/calendars"
mscevents "github.com/microsoftgraph/msgraph-sdk-go/users/item/calendars/item/events"
mscontactfolder "github.com/microsoftgraph/msgraph-sdk-go/users/item/contactfolders"
mscontactfolderitem "github.com/microsoftgraph/msgraph-sdk-go/users/item/contactfolders/item"
mscontactfolderchild "github.com/microsoftgraph/msgraph-sdk-go/users/item/contactfolders/item/childfolders"
mscontacts "github.com/microsoftgraph/msgraph-sdk-go/users/item/contacts"
msevents "github.com/microsoftgraph/msgraph-sdk-go/users/item/events"
msfolder "github.com/microsoftgraph/msgraph-sdk-go/users/item/mailfolders"
msfolderitem "github.com/microsoftgraph/msgraph-sdk-go/users/item/mailfolders/item"
msmessage "github.com/microsoftgraph/msgraph-sdk-go/users/item/messages"
msitem "github.com/microsoftgraph/msgraph-sdk-go/users/item/messages/item"
msuser "github.com/microsoftgraph/msgraph-sdk-go/users"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/pkg/path"
@ -136,82 +125,40 @@ type DeltaRequestBuilderGetQueryParameters struct {
Top *int32 `uriparametername:"%24top"`
}
type DeltaRequestBuilderGetRequestConfiguration struct {
Headers map[string]string
Options []abs.RequestOption
QueryParameters *DeltaRequestBuilderGetQueryParameters
}
func optionsForFolderMessages(moreOps []string) (*DeltaRequestBuilderGetRequestConfiguration, error) {
func optionsForFolderMessagesDelta(
moreOps []string,
) (*msuser.UsersItemMailFoldersItemMessagesDeltaRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, messages)
if err != nil {
return nil, err
}
requestParameters := &DeltaRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemMailFoldersItemMessagesDeltaRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &DeltaRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemMailFoldersItemMessagesDeltaRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
return options, nil
}
// optionsForMessages - used to select allowable options for exchange.Mail types
// @param moreOps is []string of options(e.g. "parentFolderId, subject")
// @return is first call in Messages().GetWithRequestConfigurationAndResponseHandler
func optionsForMessages(moreOps []string) (*msmessage.MessagesRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, messages)
if err != nil {
return nil, err
}
requestParameters := &msmessage.MessagesRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &msmessage.MessagesRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
return options, nil
}
// optionsForSingleMessage to select allowable option for a singular exchange.Mail object
// @params moreOps is []string of options (e.g. subject, content.Type)
// @return is first call in MessageById().GetWithRequestConfigurationAndResponseHandler
func OptionsForSingleMessage(moreOps []string) (*msitem.MessageItemRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, messages)
if err != nil {
return nil, err
}
requestParams := &msitem.MessageItemRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &msitem.MessageItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParams,
}
return options, nil
}
// optionsForCalendars places allowed options for exchange.Calendar object
// @param moreOps should reflect elements from fieldsForCalendars
// @return is first call in Calendars().GetWithRequestConfigurationAndResponseHandler
func optionsForCalendars(moreOps []string) (
*mscalendars.CalendarsRequestBuilderGetRequestConfiguration,
*msuser.UsersItemCalendarsRequestBuilderGetRequestConfiguration,
error,
) {
selecting, err := buildOptions(moreOps, calendars)
if err != nil {
return nil, err
}
requestParams := &mscalendars.CalendarsRequestBuilderGetQueryParameters{
// should be a CalendarsRequestBuilderGetRequestConfiguration
requestParams := &msuser.UsersItemCalendarsRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &mscalendars.CalendarsRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemCalendarsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParams,
}
@ -221,7 +168,7 @@ func optionsForCalendars(moreOps []string) (
// optionsForContactFolders places allowed options for exchange.ContactFolder object
// @return is first call in ContactFolders().GetWithRequestConfigurationAndResponseHandler
func optionsForContactFolders(moreOps []string) (
*mscontactfolder.ContactFoldersRequestBuilderGetRequestConfiguration,
*msuser.UsersItemContactFoldersRequestBuilderGetRequestConfiguration,
error,
) {
selecting, err := buildOptions(moreOps, folders)
@ -229,10 +176,10 @@ func optionsForContactFolders(moreOps []string) (
return nil, err
}
requestParameters := &mscontactfolder.ContactFoldersRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemContactFoldersRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &mscontactfolder.ContactFoldersRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemContactFoldersRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
@ -240,7 +187,7 @@ func optionsForContactFolders(moreOps []string) (
}
func optionsForContactFolderByID(moreOps []string) (
*mscontactfolderitem.ContactFolderItemRequestBuilderGetRequestConfiguration,
*msuser.UsersItemContactFoldersContactFolderItemRequestBuilderGetRequestConfiguration,
error,
) {
selecting, err := buildOptions(moreOps, folders)
@ -248,10 +195,10 @@ func optionsForContactFolderByID(moreOps []string) (
return nil, err
}
requestParameters := &mscontactfolderitem.ContactFolderItemRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemContactFoldersContactFolderItemRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &mscontactfolderitem.ContactFolderItemRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemContactFoldersContactFolderItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
@ -261,16 +208,18 @@ func optionsForContactFolderByID(moreOps []string) (
// optionsForMailFolders transforms the options into a more dynamic call for MailFolders.
// @param moreOps is a []string of options(e.g. "displayName", "isHidden")
// @return is first call in MailFolders().GetWithRequestConfigurationAndResponseHandler(options, handler)
func optionsForMailFolders(moreOps []string) (*msfolder.MailFoldersRequestBuilderGetRequestConfiguration, error) {
func optionsForMailFolders(
moreOps []string,
) (*msuser.UsersItemMailFoldersRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, folders)
if err != nil {
return nil, err
}
requestParameters := &msfolder.MailFoldersRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemMailFoldersRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &msfolder.MailFoldersRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemMailFoldersRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
@ -282,35 +231,35 @@ func optionsForMailFolders(moreOps []string) (*msfolder.MailFoldersRequestBuilde
// Returns first call in MailFoldersById().GetWithRequestConfigurationAndResponseHandler(options, handler)
func optionsForMailFoldersItem(
moreOps []string,
) (*msfolderitem.MailFolderItemRequestBuilderGetRequestConfiguration, error) {
) (*msuser.UsersItemMailFoldersMailFolderItemRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, folders)
if err != nil {
return nil, err
}
requestParameters := &msfolderitem.MailFolderItemRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemMailFoldersMailFolderItemRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &msfolderitem.MailFolderItemRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemMailFoldersMailFolderItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
return options, nil
}
// optionsForContactFoldersItem is the same as optionsForContacts.
func optionsForContactFoldersItem(
func optionsForContactFoldersItemDelta(
moreOps []string,
) (*DeltaRequestBuilderGetRequestConfiguration, error) {
) (*msuser.UsersItemContactFoldersItemContactsDeltaRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, contacts)
if err != nil {
return nil, err
}
requestParameters := &DeltaRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemContactFoldersItemContactsDeltaRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &DeltaRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemContactFoldersItemContactsDeltaRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
@ -319,34 +268,36 @@ func optionsForContactFoldersItem(
// optionsForEvents ensures valid option inputs for exchange.Events
// @return is first call in Events().GetWithRequestConfigurationAndResponseHandler(options, handler)
func optionsForCalendarEvents(moreOps []string) (*mscevents.EventsRequestBuilderGetRequestConfiguration, error) {
func optionsForEvents(moreOps []string) (*msuser.UsersItemEventsRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, events)
if err != nil {
return nil, err
}
requestParameters := &mscevents.EventsRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemEventsRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &mscevents.EventsRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemEventsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
return options, nil
}
// optionsForEvents ensures valid option inputs for exchange.Events
// @return is first call in Events().GetWithRequestConfigurationAndResponseHandler(options, handler)
func optionsForEvents(moreOps []string) (*msevents.EventsRequestBuilderGetRequestConfiguration, error) {
// optionsForEvents ensures a valid option inputs for `exchange.Events` when selected from within a Calendar
func optionsForEventsByCalendar(
moreOps []string,
) (*msuser.UsersItemCalendarsItemEventsRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, events)
if err != nil {
return nil, err
}
requestParameters := &msevents.EventsRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemCalendarsItemEventsRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &msevents.EventsRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemCalendarsItemEventsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
@ -356,16 +307,16 @@ func optionsForEvents(moreOps []string) (*msevents.EventsRequestBuilderGetReques
// optionsForContactChildFolders builds a contacts child folders request.
func optionsForContactChildFolders(
moreOps []string,
) (*mscontactfolderchild.ChildFoldersRequestBuilderGetRequestConfiguration, error) {
) (*msuser.UsersItemContactFoldersItemChildFoldersRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, contacts)
if err != nil {
return nil, err
}
requestParameters := &mscontactfolderchild.ChildFoldersRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemContactFoldersItemChildFoldersRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &mscontactfolderchild.ChildFoldersRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemContactFoldersItemChildFoldersRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
@ -374,16 +325,16 @@ func optionsForContactChildFolders(
// optionsForContacts transforms options into select query for MailContacts
// @return is the first call in Contacts().GetWithRequestConfigurationAndResponseHandler(options, handler)
func optionsForContacts(moreOps []string) (*mscontacts.ContactsRequestBuilderGetRequestConfiguration, error) {
func optionsForContacts(moreOps []string) (*msuser.UsersItemContactsRequestBuilderGetRequestConfiguration, error) {
selecting, err := buildOptions(moreOps, contacts)
if err != nil {
return nil, err
}
requestParameters := &mscontacts.ContactsRequestBuilderGetQueryParameters{
requestParameters := &msuser.UsersItemContactsRequestBuilderGetQueryParameters{
Select: selecting,
}
options := &mscontacts.ContactsRequestBuilderGetRequestConfiguration{
options := &msuser.UsersItemContactsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}

View File

@ -204,14 +204,11 @@ func pathAndMatch(
category,
false,
)
// Containers without a path (e.g. Root mail folder) always err here.
if err != nil {
return nil, false
}
if dirPath == nil && category == path.EmailCategory {
return nil, false // Only true for root mail folder
}
directory = pb.String()
switch category {

View File

@ -9,9 +9,7 @@ import (
multierror "github.com/hashicorp/go-multierror"
"github.com/microsoftgraph/msgraph-sdk-go/models"
msevents "github.com/microsoftgraph/msgraph-sdk-go/users/item/calendars/item/events"
cdelta "github.com/microsoftgraph/msgraph-sdk-go/users/item/contactfolders/item/contacts/delta"
mdelta "github.com/microsoftgraph/msgraph-sdk-go/users/item/mailfolders/item/messages/delta"
msuser "github.com/microsoftgraph/msgraph-sdk-go/users"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector/graph"
@ -22,31 +20,9 @@ import (
)
const (
nextLinkKey = "@odata.nextLink"
deltaLinkKey = "@odata.deltaLink"
metadataKey = "metadata"
)
// getAdditionalDataString gets a string value from the AdditionalData map. If
// the value is not in the map returns an empty string.
func getAdditionalDataString(
key string,
addtlData map[string]any,
) string {
iface := addtlData[key]
if iface == nil {
return ""
}
value, ok := iface.(*string)
if !ok {
return ""
}
return *value
}
// makeMetadataCollection creates a metadata collection that has a file
// containing all the delta tokens in tokens. Returns nil if the map does not
// have any entries.
@ -265,7 +241,7 @@ func FetchEventIDsFromCalendar(
ids []string
)
options, err := optionsForCalendarEvents([]string{"id"})
options, err := optionsForEventsByCalendar([]string{"id"})
if err != nil {
return nil, "", err
}
@ -300,7 +276,7 @@ func FetchEventIDsFromCalendar(
break
}
builder = msevents.NewEventsRequestBuilder(*nextLink, gs.Adapter())
builder = msuser.NewUsersItemCalendarsItemEventsRequestBuilder(*nextLink, gs.Adapter())
}
// Events don't have a delta endpoint so just return an empty string.
@ -320,7 +296,7 @@ func FetchContactIDsFromDirectory(
deltaToken string
)
options, err := optionsForContactFoldersItem([]string{"parentFolderId"})
options, err := optionsForContactFoldersItemDelta([]string{"parentFolderId"})
if err != nil {
return nil, deltaToken, errors.Wrap(err, "getting query options")
}
@ -332,8 +308,7 @@ func FetchContactIDsFromDirectory(
Delta()
for {
// TODO(ashmrtn): Update to pass options once graph SDK dependency is updated.
resp, err := sendContactsDeltaGet(ctx, builder, options, gs.Adapter())
resp, err := builder.Get(ctx, options)
if err != nil {
return nil, deltaToken, errors.Wrap(err, support.ConnectorStackErrorTrace(err))
}
@ -352,19 +327,17 @@ func FetchContactIDsFromDirectory(
ids = append(ids, *item.GetId())
}
addtlData := resp.GetAdditionalData()
delta := getAdditionalDataString(deltaLinkKey, addtlData)
if len(delta) > 0 {
deltaToken = delta
delta := resp.GetOdataDeltaLink()
if delta != nil && len(*delta) > 0 {
deltaToken = *delta
}
nextLink := getAdditionalDataString(nextLinkKey, addtlData)
if len(nextLink) == 0 {
nextLink := resp.GetOdataNextLink()
if nextLink == nil || len(*nextLink) == 0 {
break
}
builder = cdelta.NewDeltaRequestBuilder(nextLink, gs.Adapter())
builder = msuser.NewUsersItemContactFoldersItemContactsDeltaRequestBuilder(*nextLink, gs.Adapter())
}
return ids, deltaToken, errs.ErrorOrNil()
@ -383,7 +356,7 @@ func FetchMessageIDsFromDirectory(
deltaToken string
)
options, err := optionsForFolderMessages([]string{"id"})
options, err := optionsForFolderMessagesDelta([]string{"id"})
if err != nil {
return nil, deltaToken, errors.Wrap(err, "getting query options")
}
@ -395,8 +368,7 @@ func FetchMessageIDsFromDirectory(
Delta()
for {
// TODO(ashmrtn): Update to pass options once graph SDK dependency is updated.
resp, err := sendMessagesDeltaGet(ctx, builder, options, gs.Adapter())
resp, err := builder.Get(ctx, options)
if err != nil {
return nil, deltaToken, errors.Wrap(err, support.ConnectorStackErrorTrace(err))
}
@ -415,19 +387,17 @@ func FetchMessageIDsFromDirectory(
ids = append(ids, *item.GetId())
}
addtlData := resp.GetAdditionalData()
delta := getAdditionalDataString(deltaLinkKey, addtlData)
if len(delta) > 0 {
deltaToken = delta
delta := resp.GetOdataDeltaLink()
if delta != nil && len(*delta) > 0 {
deltaToken = *delta
}
nextLink := getAdditionalDataString(nextLinkKey, addtlData)
if len(nextLink) == 0 {
nextLink := resp.GetOdataNextLink()
if nextLink == nil || len(*nextLink) == 0 {
break
}
builder = mdelta.NewDeltaRequestBuilder(nextLink, gs.Adapter())
builder = msuser.NewUsersItemMailFoldersItemMessagesDeltaRequestBuilder(*nextLink, gs.Adapter())
}
return ids, deltaToken, errs.ErrorOrNil()

View File

@ -524,8 +524,8 @@ func establishMailRestoreLocation(
for _, folder := range folders {
pb = *pb.Append(folder)
cached, ok := mfc.PathInCache(pb.String())
cached, ok := mfc.PathInCache(pb.String())
if ok {
folderID = cached
continue
@ -544,7 +544,7 @@ func establishMailRestoreLocation(
// newCache to false in this we'll only try to populate it once per function
// call even if we make a new cache.
if isNewCache {
if err := mfc.Populate(ctx, folderID, folder); err != nil {
if err := mfc.Populate(ctx, rootFolderAlias); err != nil {
return "", errors.Wrap(err, "populating folder cache")
}

View File

@ -244,10 +244,9 @@ func checkMessage(
// Skip CreatedDateTime as it's tied to this specific instance of the item.
assert.Equal(t, expected.GetFlag(), got.GetFlag(), "Flag")
assert.Equal(t, expected.GetFrom(), got.GetFrom(), "From")
checkFlags(t, expected.GetFlag(), got.GetFlag())
checkRecipentables(t, expected.GetFrom(), got.GetFrom())
testEmptyOrEqual(t, expected.GetHasAttachments(), got.GetHasAttachments(), "HasAttachments")
// Skip Id as it's tied to this specific instance of the item.
@ -281,7 +280,7 @@ func checkMessage(
assert.Equal(t, expected.GetReplyTo(), got.GetReplyTo(), "ReplyTo")
assert.Equal(t, expected.GetSender(), got.GetSender(), "Sender")
checkRecipentables(t, expected.GetSender(), got.GetSender())
testEmptyOrEqual(t, expected.GetSentDateTime(), got.GetSentDateTime(), "SentDateTime")
@ -294,6 +293,39 @@ func checkMessage(
assert.Equal(t, expected.GetUniqueBody(), got.GetUniqueBody(), "UniqueBody")
}
// checkFlags is a helper function to check equality of models.FollowupFlabables
// OdataTypes are omitted as these do change between msgraph-sdk-go versions
func checkFlags(
t *testing.T,
expected, got models.FollowupFlagable,
) {
assert.Equal(t, expected.GetCompletedDateTime(), got.GetCompletedDateTime())
assert.Equal(t, expected.GetDueDateTime(), got.GetDueDateTime())
assert.Equal(t, expected.GetFlagStatus(), got.GetFlagStatus())
assert.Equal(t, expected.GetStartDateTime(), got.GetStartDateTime())
assert.Equal(t, expected.GetAdditionalData(), got.GetAdditionalData())
}
// checkRecipentables is a helper function to check equality between
// models.Recipientables. OdataTypes omitted.
func checkRecipentables(
t *testing.T,
expected, got models.Recipientable,
) {
checkEmailAddressables(t, expected.GetEmailAddress(), got.GetEmailAddress())
assert.Equal(t, expected.GetAdditionalData(), got.GetAdditionalData())
}
// checkEmailAddressables inspects EmailAddressables for equality
func checkEmailAddressables(
t *testing.T,
expected, got models.EmailAddressable,
) {
assert.Equal(t, expected.GetAdditionalData(), got.GetAdditionalData())
assert.Equal(t, *expected.GetAddress(), *got.GetAddress())
assert.Equal(t, expected.GetName(), got.GetName())
}
func checkContact(
t *testing.T,
expected models.Contactable,

View File

@ -6,12 +6,11 @@ import (
"strings"
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
"github.com/microsoftgraph/msgraph-sdk-go/drives/item/items"
"github.com/microsoftgraph/msgraph-sdk-go/drives/item/items/item"
"github.com/microsoftgraph/msgraph-sdk-go/drives/item/root/delta"
msdrive "github.com/microsoftgraph/msgraph-sdk-go/drive"
msdrives "github.com/microsoftgraph/msgraph-sdk-go/drives"
"github.com/microsoftgraph/msgraph-sdk-go/models"
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
mssitedrives "github.com/microsoftgraph/msgraph-sdk-go/sites/item/drives"
"github.com/microsoftgraph/msgraph-sdk-go/sites"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector/graph"
@ -85,8 +84,8 @@ func drives(
}
func siteDrives(ctx context.Context, service graph.Service, site string) ([]models.Driveable, error) {
options := &mssitedrives.DrivesRequestBuilderGetRequestConfiguration{
QueryParameters: &mssitedrives.DrivesRequestBuilderGetQueryParameters{
options := &sites.SitesItemDrivesRequestBuilderGetRequestConfiguration{
QueryParameters: &sites.SitesItemDrivesRequestBuilderGetQueryParameters{
Select: []string{"id", "name", "weburl", "system"},
},
}
@ -161,13 +160,13 @@ func collectItems(
}
// Check if there are more items
if _, found := r.GetAdditionalData()[nextLinkKey]; !found {
nextLink := r.GetOdataNextLink()
if nextLink == nil {
break
}
nextLink := r.GetAdditionalData()[nextLinkKey].(*string)
logger.Ctx(ctx).Debugf("Found %s nextLink", *nextLink)
builder = delta.NewDeltaRequestBuilder(*nextLink, service.Adapter())
builder = msdrives.NewDrivesItemRootDeltaRequestBuilder(*nextLink, service.Adapter())
}
return nil
@ -185,8 +184,7 @@ func getFolder(
// 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, folderName)
builder := item.NewDriveItemItemRequestBuilder(rawURL, service.Adapter())
builder := msdrive.NewDriveItemsDriveItemItemRequestBuilder(rawURL, service.Adapter())
foundItem, err := builder.Get(ctx, nil)
if err != nil {
@ -225,7 +223,7 @@ func createItem(
// here: https://github.com/microsoftgraph/msgraph-sdk-go/issues/155#issuecomment-1136254310
rawURL := fmt.Sprintf(itemChildrenRawURLFmt, driveID, parentFolderID)
builder := items.NewItemsRequestBuilder(rawURL, service.Adapter())
builder := msdrive.NewDriveItemsRequestBuilder(rawURL, service.Adapter())
newItem, err := builder.Post(ctx, newItem, nil)
if err != nil {

View File

@ -89,10 +89,6 @@ func (suite *OneDriveSuite) TestCreateGetDeleteFolder() {
for _, test := range table {
suite.T().Run(test.name, func(t *testing.T) {
if test.name == "NoPrefix" {
// TODO: Issue #1688
t.Skipf("Inconsistent test. Skipping until test is refactored")
}
allFolders, err := GetAllFolders(ctx, gs, suite.userID, test.prefix)
require.NoError(t, err)

View File

@ -7,7 +7,6 @@ import (
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
msup "github.com/microsoftgraph/msgraph-sdk-go/drives/item/items/item/createuploadsession"
"github.com/microsoftgraph/msgraph-sdk-go/models"
"github.com/pkg/errors"
@ -161,14 +160,14 @@ func sharePointItemInfo(di models.DriveItemable, itemSize int64) *details.ShareP
// driveItemWriter is used to initialize and return an io.Writer to upload data for the specified item
// It does so by creating an upload session and using that URL to initialize an `itemWriter`
// TODO: @vkamra verify if var session is the desired input
func driveItemWriter(
ctx context.Context,
service graph.Service,
driveID, itemID string,
itemSize int64,
) (io.Writer, error) {
// TODO: @vkamra verify if var session is the desired input
session := msup.NewCreateUploadSessionPostRequestBody()
session := models.NewUsersItemDrivesItemItemsItemCreateUploadSessionPostRequestBody()
r, err := service.Client().DrivesById(driveID).ItemsById(itemID).CreateUploadSession().Post(ctx, session, nil)
if err != nil {

View File

@ -4,12 +4,7 @@ import (
"context"
"github.com/microsoftgraph/msgraph-sdk-go/models"
"github.com/microsoftgraph/msgraph-sdk-go/sites/item/lists"
"github.com/microsoftgraph/msgraph-sdk-go/sites/item/lists/item/columns"
"github.com/microsoftgraph/msgraph-sdk-go/sites/item/lists/item/contenttypes"
"github.com/microsoftgraph/msgraph-sdk-go/sites/item/lists/item/contenttypes/item/columnlinks"
tc "github.com/microsoftgraph/msgraph-sdk-go/sites/item/lists/item/contenttypes/item/columns"
"github.com/microsoftgraph/msgraph-sdk-go/sites/item/lists/item/items"
mssite "github.com/microsoftgraph/msgraph-sdk-go/sites"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector/graph"
@ -81,7 +76,7 @@ func loadLists(
break
}
builder = lists.NewListsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
builder = mssite.NewSitesItemListsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
}
if errs != nil {
@ -130,7 +125,7 @@ func fetchListItems(
break
}
builder = items.NewItemsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
builder = mssite.NewSitesItemListsItemItemsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
}
if errs != nil {
@ -166,7 +161,7 @@ func fetchColumns(
break
}
builder = columns.NewColumnsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
builder = mssite.NewSitesItemListsItemColumnsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
}
} else {
builder := gs.Client().SitesById(siteID).ListsById(listID).ContentTypesById(cTypeID).Columns()
@ -183,7 +178,7 @@ func fetchColumns(
break
}
builder = tc.NewColumnsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
builder = mssite.NewSitesItemListsItemContentTypesItemColumnsRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
}
}
@ -245,7 +240,7 @@ func fetchContentTypes(
break
}
builder = contenttypes.NewContentTypesRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
builder = mssite.NewSitesItemListsItemContentTypesRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
}
if errs != nil {
@ -277,7 +272,11 @@ func fetchColumnLinks(
break
}
builder = columnlinks.NewColumnLinksRequestBuilder(*resp.GetOdataNextLink(), gs.Adapter())
builder = mssite.
NewSitesItemListsItemContentTypesItemColumnLinksRequestBuilder(
*resp.GetOdataNextLink(),
gs.Adapter(),
)
}
return links, nil