This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description To add needed features, Kiota-Generated Beta Connector created <!-- Insert PR description--> ## Does this PR need a docs update or release note? - [x] ✅ Yes, it's included ## Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * closes #2086<issue> * closes #2174 * closes #2223 ## Test Plan Compilation and current CI tests will fail if the package does not align with current operational standards. - [x] ⚡ Unit test - [x] 💚 E2E
- Loading branch information
Danny
authored
Jan 31, 2023
1 parent
14be75e
commit 3a52115
Showing
105 changed files
with
9,803 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package betasdk | ||
|
||
import ( | ||
i1a3c1a5501c5e41b7fd169f2d4c768dce9b096ac28fb5431bf02afcc57295411 "github.com/alcionai/corso/src/internal/connector/graph/betasdk/sites" | ||
absser "github.com/microsoft/kiota-abstractions-go" | ||
kioser "github.com/microsoft/kiota-abstractions-go/serialization" | ||
kform "github.com/microsoft/kiota-serialization-form-go" | ||
kw "github.com/microsoft/kiota-serialization-json-go" | ||
ktext "github.com/microsoft/kiota-serialization-text-go" | ||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" | ||
) | ||
|
||
// BetaClient the main entry point of the SDK, exposes the configuration and the fluent API. | ||
// Minimal Beta Connector: | ||
// Details on how the Code was generated is present in `kioter-lock.json`. | ||
// NOTE: kiota gen file is altered to indicate what files are included in the created | ||
// | ||
// Changes to Sites Directory: | ||
// Access files send requests with an adapter's with ASync() support. | ||
// This feature is not enabled in v1.0. Manually changed in remaining files. | ||
// Additionally, only calls that begin as client.SitesBy(siteID).Pages() have an endpoint. | ||
// | ||
// The use case specific to Pages(). All other requests should be routed to the /internal/connector/graph.Servicer | ||
// Specifics on `betaClient.SitesById(siteID).Pages` are located: sites/site_item_request_builder.go | ||
// | ||
// Required model files are identified as `modelFiles` in kiota-lock.json. Directory -> betasdk/models | ||
// Required access files are identified as `sitesFiles` in kiota-lock.json. Directory -> betasdk/sites | ||
// | ||
// BetaClient minimal msgraph-beta-sdk-go for connecting to msgraph-beta-sdk-go | ||
// for retrieving `SharePoint.Pages`. Code is generated from kiota.dev. | ||
// requestAdapter is registered with the following the serializers: | ||
// -- "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory", | ||
// -- "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory", | ||
// -- "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory" | ||
type BetaClient struct { | ||
// Path parameters for the request | ||
pathParameters map[string]string | ||
// The request adapter to use to execute the requests. | ||
requestAdapter *msgraphsdk.GraphRequestAdapter | ||
// Url template to use to build the URL for the current request builder | ||
urlTemplate string | ||
} | ||
|
||
// NewBetaClient instantiates a new BetaClient and sets the default values. | ||
// func NewBetaClient(requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*BetaClient) { | ||
func NewBetaClient(requestAdapter *msgraphsdk.GraphRequestAdapter) *BetaClient { | ||
m := &BetaClient{} | ||
m.pathParameters = make(map[string]string) | ||
m.urlTemplate = "{+baseurl}" | ||
m.requestAdapter = requestAdapter | ||
absser.RegisterDefaultSerializer(func() kioser.SerializationWriterFactory { | ||
return kw.NewJsonSerializationWriterFactory() | ||
}) | ||
absser.RegisterDefaultSerializer(func() kioser.SerializationWriterFactory { | ||
return ktext.NewTextSerializationWriterFactory() | ||
}) | ||
absser.RegisterDefaultSerializer(func() kioser.SerializationWriterFactory { | ||
return kform.NewFormSerializationWriterFactory() | ||
}) | ||
absser.RegisterDefaultDeserializer(func() kioser.ParseNodeFactory { | ||
return kw.NewJsonParseNodeFactory() | ||
}) | ||
absser.RegisterDefaultDeserializer(func() kioser.ParseNodeFactory { | ||
return ktext.NewTextParseNodeFactory() | ||
}) | ||
absser.RegisterDefaultDeserializer(func() kioser.ParseNodeFactory { | ||
return kform.NewFormParseNodeFactory() | ||
}) | ||
|
||
if m.requestAdapter.GetBaseUrl() == "" { | ||
m.requestAdapter.SetBaseUrl("https://graph.microsoft.com/beta") | ||
} | ||
return m | ||
} | ||
|
||
// SitesById provides operations to manage the collection of site entities. | ||
func (m *BetaClient) SitesById(id string) *i1a3c1a5501c5e41b7fd169f2d4c768dce9b096ac28fb5431bf02afcc57295411.SiteItemRequestBuilder { | ||
urlTplParams := make(map[string]string) | ||
for idx, item := range m.pathParameters { | ||
urlTplParams[idx] = item | ||
} | ||
if id != "" { | ||
urlTplParams["site%2Did"] = id | ||
} | ||
return i1a3c1a5501c5e41b7fd169f2d4c768dce9b096ac28fb5431bf02afcc57295411.NewSiteItemRequestBuilderInternal(urlTplParams, m.requestAdapter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package betasdk | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/alcionai/corso/src/internal/connector/graph" | ||
"github.com/alcionai/corso/src/internal/tester" | ||
"github.com/alcionai/corso/src/pkg/account" | ||
) | ||
|
||
type BetaClientSuite struct { | ||
suite.Suite | ||
credentials account.M365Config | ||
} | ||
|
||
func TestBetaClientSuite(t *testing.T) { | ||
suite.Run(t, new(BetaClientSuite)) | ||
} | ||
|
||
func (suite *BetaClientSuite) SetupSuite() { | ||
t := suite.T() | ||
a := tester.NewM365Account(t) | ||
m365, err := a.M365Config() | ||
require.NoError(t, err) | ||
|
||
suite.credentials = m365 | ||
} | ||
|
||
func (suite *BetaClientSuite) TestCreateBetaClient() { | ||
t := suite.T() | ||
adpt, err := graph.CreateAdapter( | ||
suite.credentials.AzureTenantID, | ||
suite.credentials.AzureClientID, | ||
suite.credentials.AzureClientSecret, | ||
) | ||
|
||
require.NoError(t, err) | ||
|
||
client := NewBetaClient(adpt) | ||
assert.NotNil(t, client) | ||
} | ||
|
||
// TestBasicClientGetFunctionality. Tests that adapter is able | ||
// to parse retrieved Site Page. Additional tests should | ||
// be handled within the /internal/connector/sharepoint when | ||
// additional features are added. | ||
func (suite *BetaClientSuite) TestBasicClientGetFunctionality() { | ||
ctx, flush := tester.NewContext() | ||
defer flush() | ||
t := suite.T() | ||
adpt, err := graph.CreateAdapter( | ||
suite.credentials.AzureTenantID, | ||
suite.credentials.AzureClientID, | ||
suite.credentials.AzureClientSecret, | ||
) | ||
|
||
require.NoError(t, err) | ||
client := NewBetaClient(adpt) | ||
require.NotNil(t, client) | ||
|
||
siteID := tester.M365SiteID(t) | ||
// TODO(dadams39) document allowable calls in main | ||
collection, err := client.SitesById(siteID).Pages().Get(ctx, nil) | ||
// Ensures that the client is able to receive data from beta | ||
// Not Registered Error: content type application/json does not have a factory registered to be parsed | ||
require.NoError(t, err) | ||
|
||
for _, page := range collection.GetValue() { | ||
assert.NotNil(t, page, "betasdk call for page does not return value.") | ||
|
||
if page != nil { | ||
t.Logf("Page :%s ", *page.GetName()) | ||
assert.NotNil(t, page.GetId()) | ||
} | ||
} | ||
} |
Oops, something went wrong.