Update /connector/graph package

Change to Beta library.
This commit is contained in:
Danny Adams 2023-01-20 09:20:31 -05:00
parent b82a6349f4
commit 4952b81333
5 changed files with 5 additions and 66 deletions

View File

@ -1,7 +1,7 @@
package graph
import (
"github.com/microsoftgraph/msgraph-sdk-go/models"
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/pkg/path"

View File

@ -5,7 +5,7 @@ import (
"net/url"
"os"
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
"github.com/microsoftgraph/msgraph-beta-sdk-go/models/odataerrors"
"github.com/pkg/errors"
"golang.org/x/exp/slices"

View File

@ -4,8 +4,7 @@ import (
"context"
absser "github.com/microsoft/kiota-abstractions-go/serialization"
beta "github.com/microsoftgraph/msgraph-beta-sdk-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
"github.com/pkg/errors"
"github.com/alcionai/corso/src/pkg/account"
@ -46,28 +45,6 @@ func (s Service) Client() *msgraphsdk.GraphServiceClient {
return s.client
}
// BetaService provides access to API Calls that are present solely in the Beta library.
// Does not fulfill the interface as the base libraries vary.
type BetaService struct {
adapter *beta.GraphRequestAdapter
client *beta.GraphBaseServiceClient
}
func (bs BetaService) Adapter() *beta.GraphRequestAdapter {
return bs.adapter
}
func (bs BetaService) Client() *beta.GraphBaseServiceClient {
return bs.client
}
func NewBetaService(adapter *beta.GraphRequestAdapter) *BetaService {
return &BetaService{
adapter: adapter,
client: beta.NewGraphBaseServiceClient(adapter),
}
}
// Seraialize writes an M365 parsable object into a byte array using the built-in
// application/json writer within the adapter.
func (s Service) Serialize(object absser.Parsable) ([]byte, error) {

View File

@ -10,8 +10,7 @@ import (
az "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
ka "github.com/microsoft/kiota-authentication-azure-go"
khttp "github.com/microsoft/kiota-http-go"
beta "github.com/microsoftgraph/msgraph-beta-sdk-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
"github.com/pkg/errors"
@ -47,28 +46,6 @@ func CreateAdapter(tenant, client, secret string) (*msgraphsdk.GraphRequestAdapt
auth, nil, nil, httpClient)
}
// CreateBetaAdapter uses the provided credentials with the Kiota Azure Libraries.
// Used to access msgraph-beta-sdk-go specific functionality
func CreateBetaAdapter(tenant, client, secret string) (*beta.GraphRequestAdapter, error) {
cred, err := az.NewClientSecretCredential(tenant, client, secret, nil)
if err != nil {
return nil, errors.Wrap(err, "creating beta m365 client credentials")
}
auth, err := ka.NewAzureIdentityAuthenticationProviderWithScopes(
cred,
[]string{"https://graph.microsoft.com/.default"},
)
if err != nil {
return nil, errors.Wrap(err, "creating beta auth token")
}
httpClient := CreateHTTPClient()
return beta.NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(
auth, nil, nil, httpClient)
}
// CreateHTTPClient creates the httpClient with middlewares and timeout configured
func CreateHTTPClient() *http.Client {
clientOptions := msgraphsdk.GetDefaultClientOptions()

View File

@ -3,7 +3,7 @@ package graph_test
import (
"testing"
"github.com/microsoftgraph/msgraph-sdk-go/models"
"github.com/microsoftgraph/msgraph-beta-sdk-go/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
@ -43,21 +43,6 @@ func (suite *GraphUnitSuite) TestCreateAdapter() {
assert.NotNil(t, adpt)
}
func (suite *GraphUnitSuite) TestBetaService() {
t := suite.T()
adpt, err := graph.CreateBetaAdapter(
suite.credentials.AzureTenantID,
suite.credentials.AzureClientID,
suite.credentials.AzureClientSecret,
)
assert.NoError(t, err)
require.NotNil(t, adpt)
serv := graph.NewBetaService(adpt)
assert.NotNil(t, serv)
}
func (suite *GraphUnitSuite) TestSerializationEndPoint() {
t := suite.T()
adpt, err := graph.CreateAdapter(