Skip to content

Commit

Permalink
feat: apis to support s3/sftp datasources import
Browse files Browse the repository at this point in the history
  • Loading branch information
nianiaJR committed Mar 7, 2023
1 parent 092b909 commit cb5500d
Show file tree
Hide file tree
Showing 27 changed files with 1,416 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions server/api/studio/internal/handler/routes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions server/api/studio/internal/logic/datasource/datasourceaddlogic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package datasource

import (
"context"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type DatasourceAddLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewDatasourceAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) DatasourceAddLogic {
return DatasourceAddLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *DatasourceAddLogic) DatasourceAdd(req types.DatasourceAddRequest) (resp *types.DatasourceAddData, err error) {
return service.NewDatasourceService(l.ctx, l.svcCtx).Add(req)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package datasource

import (
"context"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type DatasourceListContentsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewDatasourceListContentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) DatasourceListContentsLogic {
return DatasourceListContentsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *DatasourceListContentsLogic) DatasourceListContents(req types.DatasourceListContentsRequest) (resp *types.DatasourceListContentsData, err error) {
return service.NewDatasourceService(l.ctx, l.svcCtx).ListContents(req)
}
29 changes: 29 additions & 0 deletions server/api/studio/internal/logic/datasource/datasourcelistlogic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package datasource

import (
"context"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type DatasourceListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewDatasourceListLogic(ctx context.Context, svcCtx *svc.ServiceContext) DatasourceListLogic {
return DatasourceListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *DatasourceListLogic) DatasourceList() (resp *types.DatasourceData, err error) {
return service.NewDatasourceService(l.ctx, l.svcCtx).List()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package datasource

import (
"context"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type DatasourcePreviewFileLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewDatasourcePreviewFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) DatasourcePreviewFileLogic {
return DatasourcePreviewFileLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *DatasourcePreviewFileLogic) DatasourcePreviewFile(req types.DatasourcePreviewFileRequest) (resp *types.DatasourcePreviewFileData, err error) {
return service.NewDatasourceService(l.ctx, l.svcCtx).PreviewFile(req)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package datasource

import (
"context"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/service"

"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/svc"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type DatasourceRemoveLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewDatasourceRemoveLogic(ctx context.Context, svcCtx *svc.ServiceContext) DatasourceRemoveLogic {
return DatasourceRemoveLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *DatasourceRemoveLogic) DatasourceRemove(req types.DatasourceRemoveRequest) error {
return service.NewDatasourceService(l.ctx, l.svcCtx).Remove(req)
}
14 changes: 14 additions & 0 deletions server/api/studio/internal/model/datasource.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package db

import "time"

type Datasource struct {
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
Name string `json:"name"`
Type string `json:"type"`
Config string `json:"config"`
Secret string `json:"secret"`
Host string `json:"host"`
Username string `json:"username"`
CreateTime time.Time `json:"create_time" gorm:"autoCreateTime"`
}
1 change: 1 addition & 0 deletions server/api/studio/internal/model/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func InitDB(sqlitedbFilePath string) {
zap.L().Fatal(fmt.Sprintf("init db fail: %s", err))
}
err = db.AutoMigrate(
&Datasource{},
&TaskInfo{},
&Sketch{},
&SchemaSnapshot{},
Expand Down
Loading

0 comments on commit cb5500d

Please sign in to comment.