-
Notifications
You must be signed in to change notification settings - Fork 26
[CON-3220] feat(GoTo): add ListMetadata #2955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
immdipu
wants to merge
13
commits into
main
Choose a base branch
from
dipu/goto-metadata
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1bc624a
feat(goTo): implement GoTo Webinar connector with metadata handling a…
immdipu 1b1efe7
feat(goTo): add postAuth and modules
immdipu 98e4a6a
fix lint
immdipu fe2a5b1
Merge branch 'goto-postAuth' into dipu/goto-metadata
immdipu 0aa05e5
refactor(goTo): rename package to gotoconn and update connector struc…
immdipu a246e12
feat(gotoconn): implement GoTo core API functionality and restructure…
immdipu ff4db39
feat(gotoconn): enhance metadata request handling and improve error r…
immdipu 3dea1c1
feat(gotoconn): implement GoToConnect adapter
immdipu f30d6e8
refactor(gotoconn): remove SetAccountKey method and clean up account …
immdipu ee00f1b
refactor(gotoconn): remove gotoConnect adapter and update module hand…
immdipu 62cc3b7
refactor(gotoconn): remove companies object from objectRegistry
immdipu 014b9de
refactor(gotoconn): rename serviceAssist to serviceRemoteSupport
immdipu 5b54786
refactor(gotoconn): update pagination handling for Admin API and add …
immdipu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,78 @@ | ||
| package gotoconn | ||
|
|
||
| import ( | ||
| "context" | ||
| "strconv" | ||
|
|
||
| "github.com/amp-labs/connectors/common" | ||
| "github.com/amp-labs/connectors/common/urlbuilder" | ||
| "github.com/amp-labs/connectors/providers" | ||
| ) | ||
|
|
||
| func (c *Connector) GetPostAuthInfo(ctx context.Context) (*common.PostAuthInfo, error) { | ||
| accountKey, err := c.retrieveAccountKey(ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if accountKey == "" { | ||
| return nil, common.ErrMissingExpectedValues | ||
| } | ||
|
|
||
| c.accountKey = accountKey | ||
| if c.gotoCore != nil { | ||
| c.gotoCore.SetAccountKey(accountKey) | ||
| } | ||
|
|
||
| catalogVars := map[string]string{ | ||
| "accountKey": accountKey, | ||
| } | ||
|
|
||
| return &common.PostAuthInfo{ | ||
| CatalogVars: &catalogVars, | ||
| }, nil | ||
| } | ||
|
|
||
| func (c *Connector) retrieveAccountKey(ctx context.Context) (string, error) { | ||
| url, err := c.getMeURL() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| resp, err := c.JSONHTTPClient().Get(ctx, url.String()) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| data, err := common.UnmarshalJSON[map[string]any](resp) | ||
| if err != nil { | ||
| return "", common.ErrFailedToUnmarshalBody | ||
| } | ||
|
|
||
| if data == nil { | ||
| return "", common.ErrMissingExpectedValues | ||
| } | ||
|
|
||
| rawAccountKey, ok := (*data)["accountKey"] | ||
| if !ok { | ||
| return "", common.ErrMissingExpectedValues | ||
| } | ||
|
|
||
| switch v := rawAccountKey.(type) { | ||
| case string: | ||
| return v, nil | ||
| case float64: | ||
| return strconv.FormatInt(int64(v), 10), nil | ||
| default: | ||
| return "", common.ErrMissingExpectedValues | ||
| } | ||
| } | ||
|
|
||
| func (c *Connector) getMeURL() (*urlbuilder.URL, error) { | ||
| // /me lives on the goTo (api.getgo.com) module, so we resolve that | ||
| // module's BaseURL explicitly — even when the connector was created | ||
| // with the goToConnect module selected. | ||
| baseURL := c.ProviderInfo().ReadModuleInfo(providers.ModuleGoTo).BaseURL | ||
|
|
||
| return urlbuilder.New(baseURL, "/admin/rest/v1/me") | ||
| } | ||
This file contains hidden or 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,18 @@ | ||
| package gotoconn | ||
|
|
||
| type AuthMetadataVars struct { | ||
| AccountKey string | ||
| } | ||
|
|
||
| // NewAuthMetadataVars parses map into the model. | ||
| func NewAuthMetadataVars(dictionary map[string]string) *AuthMetadataVars { | ||
| return &AuthMetadataVars{ | ||
| AccountKey: dictionary["accountKey"], | ||
| } | ||
| } | ||
|
|
||
| func (v AuthMetadataVars) AsMap() *map[string]string { | ||
| return &map[string]string{ | ||
| "accountKey": v.AccountKey, | ||
| } | ||
| } |
This file contains hidden or 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,99 @@ | ||
| // Package gotoconn implements the GoTo connector. | ||
| // | ||
| // The package is named "gotoconn" instead of "goto" because "goto" is a | ||
| // reserved keyword in Go and cannot be used as a package identifier. The | ||
| // "conn" suffix is short for "connector". | ||
| package gotoconn | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/amp-labs/connectors" | ||
| "github.com/amp-labs/connectors/common" | ||
| "github.com/amp-labs/connectors/internal/components" | ||
| "github.com/amp-labs/connectors/providers" | ||
| "github.com/amp-labs/connectors/providers/goto/internal/gotocore" | ||
| ) | ||
|
|
||
| type Connector struct { | ||
| // Basic connector | ||
| *components.Connector | ||
|
|
||
| // Require authenticated client & account | ||
| common.RequireAuthenticatedClient | ||
| common.PostAuthInfo | ||
|
|
||
| // gotoCore handles api.getgo.com endpoints (Webinar, etc). | ||
| gotoCore *gotocore.Adapter | ||
| gotoConnect *gotocore.Adapter | ||
|
|
||
| accountKey string | ||
| } | ||
|
|
||
| func NewConnector(params common.ConnectorParams) (*Connector, error) { | ||
| if params.Module == "" { | ||
| params.Module = providers.ModuleGoTo | ||
| } | ||
|
|
||
| conn, err := components.Initialize(providers.GoTo, params, | ||
| func(base *components.Connector) (*Connector, error) { | ||
| return &Connector{Connector: base}, nil | ||
| }, | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| authMetadata := NewAuthMetadataVars(params.Metadata) | ||
| conn.accountKey = authMetadata.AccountKey | ||
|
|
||
| if err := initModuleAdapters(conn, params); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return conn, nil | ||
| } | ||
|
|
||
| func initModuleAdapters(conn *Connector, params common.ConnectorParams) error { | ||
| switch conn.Module() { //nolint:exhaustive | ||
| case providers.ModuleGoTo: | ||
| adapter, err := gotocore.NewAdapter(params, conn.accountKey) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| conn.gotoCore = adapter | ||
| case providers.ModuleGoToConnect: | ||
| adapter, err := gotocore.NewAdapter(params, conn.accountKey) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| conn.gotoConnect = adapter | ||
| default: | ||
| return common.ErrUnsupportedModule | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // SetBaseURL fans the override out to any active module adapter so that | ||
| // unit tests pointing at a mock server reach the same host the top-level | ||
| // connector now uses. | ||
| func (c *Connector) SetBaseURL(newURL string) { | ||
| c.Connector.SetBaseURL(newURL) | ||
|
|
||
| if c.gotoCore != nil { | ||
| c.gotoCore.SetBaseURL(newURL) | ||
| } | ||
|
immdipu marked this conversation as resolved.
|
||
| } | ||
|
|
||
| func (c *Connector) ListObjectMetadata( | ||
| ctx context.Context, objectNames []string, | ||
| ) (*connectors.ListObjectMetadataResult, error) { | ||
| if c.gotoCore != nil { | ||
| return c.gotoCore.ListObjectMetadata(ctx, objectNames) | ||
|
immdipu marked this conversation as resolved.
|
||
| } | ||
|
|
||
| return nil, common.ErrNotImplemented | ||
| } | ||
This file contains hidden or 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,50 @@ | ||
| // Package gotocore handles GoTo's core API functionality. | ||
| // This includes endpoints for managing webinars and other products. | ||
| // The package name "gotocore" is internal shorthand — | ||
| // it does not imply core-only access. | ||
| package gotocore | ||
|
|
||
| import ( | ||
| "github.com/amp-labs/connectors/common" | ||
| "github.com/amp-labs/connectors/internal/components" | ||
| "github.com/amp-labs/connectors/internal/components/operations" | ||
| "github.com/amp-labs/connectors/internal/components/schema" | ||
| "github.com/amp-labs/connectors/providers" | ||
| ) | ||
|
|
||
| type Adapter struct { | ||
| *components.Connector | ||
| components.SchemaProvider | ||
|
|
||
| accountKey string | ||
| } | ||
|
|
||
| func NewAdapter(params common.ConnectorParams, accountKey string) (*Adapter, error) { | ||
| adapter, err := components.Initialize(providers.GoTo, params, constructor) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| adapter.accountKey = accountKey | ||
|
|
||
| return adapter, nil | ||
| } | ||
|
|
||
| func (a *Adapter) SetAccountKey(accountKey string) { | ||
| a.accountKey = accountKey | ||
| } | ||
|
|
||
| func constructor(base *components.Connector) (*Adapter, error) { | ||
| adapter := &Adapter{Connector: base} | ||
|
|
||
| adapter.SchemaProvider = schema.NewObjectSchemaProvider( | ||
| adapter.HTTPClient().Client, | ||
| schema.FetchModeParallel, | ||
| operations.SingleObjectMetadataHandlers{ | ||
| BuildRequest: adapter.buildSingleObjectMetadataRequest, | ||
| ParseResponse: adapter.parseSingleObjectMetadataResponse, | ||
| }, | ||
| ) | ||
|
|
||
| return adapter, nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.