Skip to content
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

fix: fix ListCredentials client api #1951

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/metadata/http_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ func (h HttpHandler) SampleDataLoaded(echoCtx echo.Context) (bool, error) {

integrations, err := integrationClient.ListIntegrations(ctx, nil)
if err != nil {
h.logger.Error("failed to list integrations", zap.Error(err))
return false, echo.NewHTTPError(http.StatusInternalServerError, "failed to list integrations")
}

Expand All @@ -868,10 +869,11 @@ func (h HttpHandler) SampleDataLoaded(echoCtx echo.Context) (bool, error) {

credentials, err := integrationClient.ListCredentials(ctx)
if err != nil {
h.logger.Error("failed to list credentials", zap.Error(err))
return false, echo.NewHTTPError(http.StatusInternalServerError, "failed to list credentials")
}
credentialsMap := make(map[string]bool)
for _, c := range credentials {
for _, c := range credentials.Credentials {
credentialsMap[c.ID] = true
}

Expand Down
6 changes: 3 additions & 3 deletions services/integration/client/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type IntegrationServiceClient interface {
ListIntegrationsByFilters(ctx *httpclient.Context, req models.ListIntegrationsRequest) (*models.ListIntegrationsResponse, error)
IntegrationHealthcheck(ctx *httpclient.Context, integrationID string) (*models.Integration, error)
GetCredential(ctx *httpclient.Context, credentialID string) (*models.Credential, error)
ListCredentials(ctx *httpclient.Context) ([]models.Credential, error)
ListCredentials(ctx *httpclient.Context) (models.ListCredentialsResponse, error)
GetIntegrationGroup(ctx *httpclient.Context, integrationGroupName string) (*models.IntegrationGroup, error)
ListIntegrationGroups(ctx *httpclient.Context) ([]models.IntegrationGroup, error)
}
Expand Down Expand Up @@ -96,9 +96,9 @@ func (c *integrationClient) GetCredential(ctx *httpclient.Context, credentialID
return response, nil
}

func (c *integrationClient) ListCredentials(ctx *httpclient.Context) ([]models.Credential, error) {
func (c *integrationClient) ListCredentials(ctx *httpclient.Context) (models.ListCredentialsResponse, error) {
url := fmt.Sprintf("%s/api/v1/credentials", c.baseURL)
var response []models.Credential
var response models.ListCredentialsResponse

if statusCode, err := httpclient.DoRequest(ctx.Ctx, http.MethodGet, url, ctx.ToHeaders(), nil, &response); err != nil {
if 400 <= statusCode && statusCode < 500 {
Expand Down