From 35099d7bf26d671760499e5f86df328b4120bee1 Mon Sep 17 00:00:00 2001 From: SeanHH86 <154984842+SeanHH86@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:49:19 +0800 Subject: [PATCH] merge dataviewer enhancement (#250) --- .mockery.yaml | 8 + .../dataviewer/mock_DataviewerClient.go | 97 + .../builder/git/gitserver/mock_GitServer.go | 106 + .../builder/parquet/mock_Reader.go | 176 +- .../store/database/mock_DataviewerStore.go | 426 + .../component/mock_InternalComponent.go | 59 + .../component/mock_ModelComponent.go | 59 - .../workflows/mock_DataViewerActivity.go | 742 + api/handler/dataset_viewer.go | 65 - api/handler/internal.go | 59 +- api/router/api.go | 19 + builder/dataviewer/client.go | 38 + builder/git/gitserver/gitaly/branch.go | 58 + builder/git/gitserver/gitea/branch.go | 29 + builder/git/gitserver/interface.go | 2 + builder/git/gitserver/types.go | 16 + builder/parquet/duckdb_reader.go | 120 +- builder/parquet/duckdb_writer.go | 80 + builder/store/database/dataviewer.go | 143 + builder/store/database/dataviewer_test.go | 91 + .../20250115132744_create_table_dataviewer.go | 82 + builder/temporal/temporal.go | 16 + .../cmd/dataviewer/dataviewer.go | 18 + cmd/csghub-server/cmd/dataviewer/launch.go | 73 + cmd/csghub-server/cmd/root.go | 5 + cmd/csghub-server/cmd/root_ce.go | 6 + common/config/config.go | 21 +- common/tests/stores.go | 6 + common/types/dataset.go | 78 + common/types/dataviewer.go | 32 + common/types/git_server_type.go | 1 + common/types/repo.go | 2 + component/code.go | 2 +- component/code_test.go | 2 +- component/dataset.go | 63 +- component/dataset_test.go | 4 +- component/dataset_viewer.go | 104 - component/internal.go | 12 + component/model.go | 18 +- component/model_test.go | 8 +- component/prompt.go | 16 +- component/prompt_test.go | 8 +- component/recom.go | 2 +- component/repo.go | 2 +- component/space.go | 2 +- component/space_ce_test.go | 2 +- component/wire_gen_test.go | 55 - component/wireset.go | 9 - dataviewer/common/types.go | 174 + dataviewer/component/callback.go | 121 + dataviewer/component/callback_test.go | 104 + dataviewer/component/dataset_viewer.go | 582 + dataviewer/component/dataset_viewer_test.go | 267 + dataviewer/component/mocks_test.go | 65 + dataviewer/component/utils_test.go | 79 + dataviewer/handler/callback.go | 60 + dataviewer/handler/dataset_viewer.go | 218 + dataviewer/router/api.go | 105 + dataviewer/workflows/activity.go | 850 + dataviewer/workflows/activity_test.go | 262 + dataviewer/workflows/repo_files.go | 124 + dataviewer/workflows/repo_files_test.go | 28 + dataviewer/workflows/utils.go | 106 + dataviewer/workflows/utils_test.go | 67 + dataviewer/workflows/workflow.go | 234 + dataviewer/workflows/workflow_test.go | 222 + docs/docs.go | 214 + docs/swagger.json | 33493 ++++------------ docs/swagger.yaml | 11791 +++--- go.mod | 8 +- go.sum | 10 + 71 files changed, 21191 insertions(+), 31035 deletions(-) create mode 100644 _mocks/opencsg.com/csghub-server/builder/dataviewer/mock_DataviewerClient.go create mode 100644 _mocks/opencsg.com/csghub-server/builder/store/database/mock_DataviewerStore.go create mode 100644 _mocks/opencsg.com/csghub-server/dataviewer/workflows/mock_DataViewerActivity.go delete mode 100644 api/handler/dataset_viewer.go create mode 100644 builder/dataviewer/client.go create mode 100644 builder/parquet/duckdb_writer.go create mode 100644 builder/store/database/dataviewer.go create mode 100644 builder/store/database/dataviewer_test.go create mode 100644 builder/store/database/migrations/20250115132744_create_table_dataviewer.go create mode 100644 cmd/csghub-server/cmd/dataviewer/dataviewer.go create mode 100644 cmd/csghub-server/cmd/dataviewer/launch.go create mode 100644 cmd/csghub-server/cmd/root_ce.go create mode 100644 common/types/dataviewer.go delete mode 100644 component/dataset_viewer.go create mode 100644 dataviewer/common/types.go create mode 100644 dataviewer/component/callback.go create mode 100644 dataviewer/component/callback_test.go create mode 100644 dataviewer/component/dataset_viewer.go create mode 100644 dataviewer/component/dataset_viewer_test.go create mode 100644 dataviewer/component/mocks_test.go create mode 100644 dataviewer/component/utils_test.go create mode 100644 dataviewer/handler/callback.go create mode 100644 dataviewer/handler/dataset_viewer.go create mode 100644 dataviewer/router/api.go create mode 100644 dataviewer/workflows/activity.go create mode 100644 dataviewer/workflows/activity_test.go create mode 100644 dataviewer/workflows/repo_files.go create mode 100644 dataviewer/workflows/repo_files_test.go create mode 100644 dataviewer/workflows/utils.go create mode 100644 dataviewer/workflows/utils_test.go create mode 100644 dataviewer/workflows/workflow.go create mode 100644 dataviewer/workflows/workflow_test.go diff --git a/.mockery.yaml b/.mockery.yaml index 26009fa1..6c5777ef 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -165,3 +165,11 @@ packages: OperationServiceClient: SmartHTTPServiceClient: RemoteServiceClient: + opencsg.com/csghub-server/builder/dataviewer: + config: + interfaces: + DataviewerClient: + opencsg.com/csghub-server/dataviewer/workflows: + config: + interfaces: + DataViewerActivity: \ No newline at end of file diff --git a/_mocks/opencsg.com/csghub-server/builder/dataviewer/mock_DataviewerClient.go b/_mocks/opencsg.com/csghub-server/builder/dataviewer/mock_DataviewerClient.go new file mode 100644 index 00000000..4b05562d --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/builder/dataviewer/mock_DataviewerClient.go @@ -0,0 +1,97 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package dataviewer + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + + types "opencsg.com/csghub-server/common/types" +) + +// MockDataviewerClient is an autogenerated mock type for the DataviewerClient type +type MockDataviewerClient struct { + mock.Mock +} + +type MockDataviewerClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockDataviewerClient) EXPECT() *MockDataviewerClient_Expecter { + return &MockDataviewerClient_Expecter{mock: &_m.Mock} +} + +// TriggerWorkflow provides a mock function with given fields: ctx, req +func (_m *MockDataviewerClient) TriggerWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for TriggerWorkflow") + } + + var r0 *types.WorkFlowInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) (*types.WorkFlowInfo, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) *types.WorkFlowInfo); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.WorkFlowInfo) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.UpdateViewerReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataviewerClient_TriggerWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TriggerWorkflow' +type MockDataviewerClient_TriggerWorkflow_Call struct { + *mock.Call +} + +// TriggerWorkflow is a helper method to define mock.On call +// - ctx context.Context +// - req types.UpdateViewerReq +func (_e *MockDataviewerClient_Expecter) TriggerWorkflow(ctx interface{}, req interface{}) *MockDataviewerClient_TriggerWorkflow_Call { + return &MockDataviewerClient_TriggerWorkflow_Call{Call: _e.mock.On("TriggerWorkflow", ctx, req)} +} + +func (_c *MockDataviewerClient_TriggerWorkflow_Call) Run(run func(ctx context.Context, req types.UpdateViewerReq)) *MockDataviewerClient_TriggerWorkflow_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.UpdateViewerReq)) + }) + return _c +} + +func (_c *MockDataviewerClient_TriggerWorkflow_Call) Return(_a0 *types.WorkFlowInfo, _a1 error) *MockDataviewerClient_TriggerWorkflow_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataviewerClient_TriggerWorkflow_Call) RunAndReturn(run func(context.Context, types.UpdateViewerReq) (*types.WorkFlowInfo, error)) *MockDataviewerClient_TriggerWorkflow_Call { + _c.Call.Return(run) + return _c +} + +// NewMockDataviewerClient creates a new instance of MockDataviewerClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockDataviewerClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockDataviewerClient { + mock := &MockDataviewerClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/builder/git/gitserver/mock_GitServer.go b/_mocks/opencsg.com/csghub-server/builder/git/gitserver/mock_GitServer.go index 58ec74d1..815c2e1f 100644 --- a/_mocks/opencsg.com/csghub-server/builder/git/gitserver/mock_GitServer.go +++ b/_mocks/opencsg.com/csghub-server/builder/git/gitserver/mock_GitServer.go @@ -516,6 +516,53 @@ func (_c *MockGitServer_DeleteRepo_Call) RunAndReturn(run func(context.Context, return _c } +// DeleteRepoBranch provides a mock function with given fields: ctx, req +func (_m *MockGitServer) DeleteRepoBranch(ctx context.Context, req gitserver.DeleteBranchReq) error { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for DeleteRepoBranch") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, gitserver.DeleteBranchReq) error); ok { + r0 = rf(ctx, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockGitServer_DeleteRepoBranch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRepoBranch' +type MockGitServer_DeleteRepoBranch_Call struct { + *mock.Call +} + +// DeleteRepoBranch is a helper method to define mock.On call +// - ctx context.Context +// - req gitserver.DeleteBranchReq +func (_e *MockGitServer_Expecter) DeleteRepoBranch(ctx interface{}, req interface{}) *MockGitServer_DeleteRepoBranch_Call { + return &MockGitServer_DeleteRepoBranch_Call{Call: _e.mock.On("DeleteRepoBranch", ctx, req)} +} + +func (_c *MockGitServer_DeleteRepoBranch_Call) Run(run func(ctx context.Context, req gitserver.DeleteBranchReq)) *MockGitServer_DeleteRepoBranch_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(gitserver.DeleteBranchReq)) + }) + return _c +} + +func (_c *MockGitServer_DeleteRepoBranch_Call) Return(_a0 error) *MockGitServer_DeleteRepoBranch_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockGitServer_DeleteRepoBranch_Call) RunAndReturn(run func(context.Context, gitserver.DeleteBranchReq) error) *MockGitServer_DeleteRepoBranch_Call { + _c.Call.Return(run) + return _c +} + // DeleteRepoFile provides a mock function with given fields: req func (_m *MockGitServer) DeleteRepoFile(req *types.DeleteFileReq) error { ret := _m.Called(req) @@ -1161,6 +1208,65 @@ func (_c *MockGitServer_GetRepoAllLfsPointers_Call) RunAndReturn(run func(contex return _c } +// GetRepoBranchByName provides a mock function with given fields: ctx, req +func (_m *MockGitServer) GetRepoBranchByName(ctx context.Context, req gitserver.GetBranchReq) (*types.Branch, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetRepoBranchByName") + } + + var r0 *types.Branch + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, gitserver.GetBranchReq) (*types.Branch, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, gitserver.GetBranchReq) *types.Branch); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Branch) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, gitserver.GetBranchReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockGitServer_GetRepoBranchByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRepoBranchByName' +type MockGitServer_GetRepoBranchByName_Call struct { + *mock.Call +} + +// GetRepoBranchByName is a helper method to define mock.On call +// - ctx context.Context +// - req gitserver.GetBranchReq +func (_e *MockGitServer_Expecter) GetRepoBranchByName(ctx interface{}, req interface{}) *MockGitServer_GetRepoBranchByName_Call { + return &MockGitServer_GetRepoBranchByName_Call{Call: _e.mock.On("GetRepoBranchByName", ctx, req)} +} + +func (_c *MockGitServer_GetRepoBranchByName_Call) Run(run func(ctx context.Context, req gitserver.GetBranchReq)) *MockGitServer_GetRepoBranchByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(gitserver.GetBranchReq)) + }) + return _c +} + +func (_c *MockGitServer_GetRepoBranchByName_Call) Return(_a0 *types.Branch, _a1 error) *MockGitServer_GetRepoBranchByName_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockGitServer_GetRepoBranchByName_Call) RunAndReturn(run func(context.Context, gitserver.GetBranchReq) (*types.Branch, error)) *MockGitServer_GetRepoBranchByName_Call { + _c.Call.Return(run) + return _c +} + // GetRepoBranches provides a mock function with given fields: ctx, req func (_m *MockGitServer) GetRepoBranches(ctx context.Context, req gitserver.GetBranchesReq) ([]types.Branch, error) { ret := _m.Called(ctx, req) diff --git a/_mocks/opencsg.com/csghub-server/builder/parquet/mock_Reader.go b/_mocks/opencsg.com/csghub-server/builder/parquet/mock_Reader.go index 6e31702e..4232b006 100644 --- a/_mocks/opencsg.com/csghub-server/builder/parquet/mock_Reader.go +++ b/_mocks/opencsg.com/csghub-server/builder/parquet/mock_Reader.go @@ -2,7 +2,13 @@ package parquet -import mock "github.com/stretchr/testify/mock" +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + + types "opencsg.com/csghub-server/common/types" +) // MockReader is an autogenerated mock type for the Reader type type MockReader struct { @@ -17,9 +23,88 @@ func (_m *MockReader) EXPECT() *MockReader_Expecter { return &MockReader_Expecter{mock: &_m.Mock} } -// RowCount provides a mock function with given fields: objName -func (_m *MockReader) RowCount(objName string) (int, error) { - ret := _m.Called(objName) +// FetchRows provides a mock function with given fields: ctx, objNames, req, lfs +func (_m *MockReader) FetchRows(ctx context.Context, objNames []string, req types.QueryReq, lfs bool) ([]string, []string, [][]interface{}, error) { + ret := _m.Called(ctx, objNames, req, lfs) + + if len(ret) == 0 { + panic("no return value specified for FetchRows") + } + + var r0 []string + var r1 []string + var r2 [][]interface{} + var r3 error + if rf, ok := ret.Get(0).(func(context.Context, []string, types.QueryReq, bool) ([]string, []string, [][]interface{}, error)); ok { + return rf(ctx, objNames, req, lfs) + } + if rf, ok := ret.Get(0).(func(context.Context, []string, types.QueryReq, bool) []string); ok { + r0 = rf(ctx, objNames, req, lfs) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string, types.QueryReq, bool) []string); ok { + r1 = rf(ctx, objNames, req, lfs) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]string) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, []string, types.QueryReq, bool) [][]interface{}); ok { + r2 = rf(ctx, objNames, req, lfs) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).([][]interface{}) + } + } + + if rf, ok := ret.Get(3).(func(context.Context, []string, types.QueryReq, bool) error); ok { + r3 = rf(ctx, objNames, req, lfs) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// MockReader_FetchRows_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchRows' +type MockReader_FetchRows_Call struct { + *mock.Call +} + +// FetchRows is a helper method to define mock.On call +// - ctx context.Context +// - objNames []string +// - req types.QueryReq +// - lfs bool +func (_e *MockReader_Expecter) FetchRows(ctx interface{}, objNames interface{}, req interface{}, lfs interface{}) *MockReader_FetchRows_Call { + return &MockReader_FetchRows_Call{Call: _e.mock.On("FetchRows", ctx, objNames, req, lfs)} +} + +func (_c *MockReader_FetchRows_Call) Run(run func(ctx context.Context, objNames []string, req types.QueryReq, lfs bool)) *MockReader_FetchRows_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]string), args[2].(types.QueryReq), args[3].(bool)) + }) + return _c +} + +func (_c *MockReader_FetchRows_Call) Return(columns []string, columnsType []string, rows [][]interface{}, err error) *MockReader_FetchRows_Call { + _c.Call.Return(columns, columnsType, rows, err) + return _c +} + +func (_c *MockReader_FetchRows_Call) RunAndReturn(run func(context.Context, []string, types.QueryReq, bool) ([]string, []string, [][]interface{}, error)) *MockReader_FetchRows_Call { + _c.Call.Return(run) + return _c +} + +// RowCount provides a mock function with given fields: ctx, objNames, req, lfs +func (_m *MockReader) RowCount(ctx context.Context, objNames []string, req types.QueryReq, lfs bool) (int, error) { + ret := _m.Called(ctx, objNames, req, lfs) if len(ret) == 0 { panic("no return value specified for RowCount") @@ -27,17 +112,17 @@ func (_m *MockReader) RowCount(objName string) (int, error) { var r0 int var r1 error - if rf, ok := ret.Get(0).(func(string) (int, error)); ok { - return rf(objName) + if rf, ok := ret.Get(0).(func(context.Context, []string, types.QueryReq, bool) (int, error)); ok { + return rf(ctx, objNames, req, lfs) } - if rf, ok := ret.Get(0).(func(string) int); ok { - r0 = rf(objName) + if rf, ok := ret.Get(0).(func(context.Context, []string, types.QueryReq, bool) int); ok { + r0 = rf(ctx, objNames, req, lfs) } else { r0 = ret.Get(0).(int) } - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(objName) + if rf, ok := ret.Get(1).(func(context.Context, []string, types.QueryReq, bool) error); ok { + r1 = rf(ctx, objNames, req, lfs) } else { r1 = ret.Error(1) } @@ -51,14 +136,17 @@ type MockReader_RowCount_Call struct { } // RowCount is a helper method to define mock.On call -// - objName string -func (_e *MockReader_Expecter) RowCount(objName interface{}) *MockReader_RowCount_Call { - return &MockReader_RowCount_Call{Call: _e.mock.On("RowCount", objName)} +// - ctx context.Context +// - objNames []string +// - req types.QueryReq +// - lfs bool +func (_e *MockReader_Expecter) RowCount(ctx interface{}, objNames interface{}, req interface{}, lfs interface{}) *MockReader_RowCount_Call { + return &MockReader_RowCount_Call{Call: _e.mock.On("RowCount", ctx, objNames, req, lfs)} } -func (_c *MockReader_RowCount_Call) Run(run func(objName string)) *MockReader_RowCount_Call { +func (_c *MockReader_RowCount_Call) Run(run func(ctx context.Context, objNames []string, req types.QueryReq, lfs bool)) *MockReader_RowCount_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(context.Context), args[1].([]string), args[2].(types.QueryReq), args[3].(bool)) }) return _c } @@ -68,48 +156,57 @@ func (_c *MockReader_RowCount_Call) Return(count int, err error) *MockReader_Row return _c } -func (_c *MockReader_RowCount_Call) RunAndReturn(run func(string) (int, error)) *MockReader_RowCount_Call { +func (_c *MockReader_RowCount_Call) RunAndReturn(run func(context.Context, []string, types.QueryReq, bool) (int, error)) *MockReader_RowCount_Call { _c.Call.Return(run) return _c } -// TopN provides a mock function with given fields: objName, count -func (_m *MockReader) TopN(objName string, count int) ([]string, [][]interface{}, error) { - ret := _m.Called(objName, count) +// TopN provides a mock function with given fields: ctx, objName, count +func (_m *MockReader) TopN(ctx context.Context, objName string, count int) ([]string, []string, [][]interface{}, error) { + ret := _m.Called(ctx, objName, count) if len(ret) == 0 { panic("no return value specified for TopN") } var r0 []string - var r1 [][]interface{} - var r2 error - if rf, ok := ret.Get(0).(func(string, int) ([]string, [][]interface{}, error)); ok { - return rf(objName, count) + var r1 []string + var r2 [][]interface{} + var r3 error + if rf, ok := ret.Get(0).(func(context.Context, string, int) ([]string, []string, [][]interface{}, error)); ok { + return rf(ctx, objName, count) } - if rf, ok := ret.Get(0).(func(string, int) []string); ok { - r0 = rf(objName, count) + if rf, ok := ret.Get(0).(func(context.Context, string, int) []string); ok { + r0 = rf(ctx, objName, count) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) } } - if rf, ok := ret.Get(1).(func(string, int) [][]interface{}); ok { - r1 = rf(objName, count) + if rf, ok := ret.Get(1).(func(context.Context, string, int) []string); ok { + r1 = rf(ctx, objName, count) } else { if ret.Get(1) != nil { - r1 = ret.Get(1).([][]interface{}) + r1 = ret.Get(1).([]string) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, int) [][]interface{}); ok { + r2 = rf(ctx, objName, count) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).([][]interface{}) } } - if rf, ok := ret.Get(2).(func(string, int) error); ok { - r2 = rf(objName, count) + if rf, ok := ret.Get(3).(func(context.Context, string, int) error); ok { + r3 = rf(ctx, objName, count) } else { - r2 = ret.Error(2) + r3 = ret.Error(3) } - return r0, r1, r2 + return r0, r1, r2, r3 } // MockReader_TopN_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TopN' @@ -118,25 +215,26 @@ type MockReader_TopN_Call struct { } // TopN is a helper method to define mock.On call +// - ctx context.Context // - objName string // - count int -func (_e *MockReader_Expecter) TopN(objName interface{}, count interface{}) *MockReader_TopN_Call { - return &MockReader_TopN_Call{Call: _e.mock.On("TopN", objName, count)} +func (_e *MockReader_Expecter) TopN(ctx interface{}, objName interface{}, count interface{}) *MockReader_TopN_Call { + return &MockReader_TopN_Call{Call: _e.mock.On("TopN", ctx, objName, count)} } -func (_c *MockReader_TopN_Call) Run(run func(objName string, count int)) *MockReader_TopN_Call { +func (_c *MockReader_TopN_Call) Run(run func(ctx context.Context, objName string, count int)) *MockReader_TopN_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(int)) + run(args[0].(context.Context), args[1].(string), args[2].(int)) }) return _c } -func (_c *MockReader_TopN_Call) Return(columns []string, rows [][]interface{}, err error) *MockReader_TopN_Call { - _c.Call.Return(columns, rows, err) +func (_c *MockReader_TopN_Call) Return(columns []string, columnsType []string, rows [][]interface{}, err error) *MockReader_TopN_Call { + _c.Call.Return(columns, columnsType, rows, err) return _c } -func (_c *MockReader_TopN_Call) RunAndReturn(run func(string, int) ([]string, [][]interface{}, error)) *MockReader_TopN_Call { +func (_c *MockReader_TopN_Call) RunAndReturn(run func(context.Context, string, int) ([]string, []string, [][]interface{}, error)) *MockReader_TopN_Call { _c.Call.Return(run) return _c } diff --git a/_mocks/opencsg.com/csghub-server/builder/store/database/mock_DataviewerStore.go b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_DataviewerStore.go new file mode 100644 index 00000000..78f9c2fb --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_DataviewerStore.go @@ -0,0 +1,426 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package database + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + database "opencsg.com/csghub-server/builder/store/database" +) + +// MockDataviewerStore is an autogenerated mock type for the DataviewerStore type +type MockDataviewerStore struct { + mock.Mock +} + +type MockDataviewerStore_Expecter struct { + mock *mock.Mock +} + +func (_m *MockDataviewerStore) EXPECT() *MockDataviewerStore_Expecter { + return &MockDataviewerStore_Expecter{mock: &_m.Mock} +} + +// CreateJob provides a mock function with given fields: ctx, job +func (_m *MockDataviewerStore) CreateJob(ctx context.Context, job database.DataviewerJob) error { + ret := _m.Called(ctx, job) + + if len(ret) == 0 { + panic("no return value specified for CreateJob") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, database.DataviewerJob) error); ok { + r0 = rf(ctx, job) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDataviewerStore_CreateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJob' +type MockDataviewerStore_CreateJob_Call struct { + *mock.Call +} + +// CreateJob is a helper method to define mock.On call +// - ctx context.Context +// - job database.DataviewerJob +func (_e *MockDataviewerStore_Expecter) CreateJob(ctx interface{}, job interface{}) *MockDataviewerStore_CreateJob_Call { + return &MockDataviewerStore_CreateJob_Call{Call: _e.mock.On("CreateJob", ctx, job)} +} + +func (_c *MockDataviewerStore_CreateJob_Call) Run(run func(ctx context.Context, job database.DataviewerJob)) *MockDataviewerStore_CreateJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(database.DataviewerJob)) + }) + return _c +} + +func (_c *MockDataviewerStore_CreateJob_Call) Return(_a0 error) *MockDataviewerStore_CreateJob_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDataviewerStore_CreateJob_Call) RunAndReturn(run func(context.Context, database.DataviewerJob) error) *MockDataviewerStore_CreateJob_Call { + _c.Call.Return(run) + return _c +} + +// CreateViewer provides a mock function with given fields: ctx, viewer +func (_m *MockDataviewerStore) CreateViewer(ctx context.Context, viewer database.Dataviewer) error { + ret := _m.Called(ctx, viewer) + + if len(ret) == 0 { + panic("no return value specified for CreateViewer") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, database.Dataviewer) error); ok { + r0 = rf(ctx, viewer) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDataviewerStore_CreateViewer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateViewer' +type MockDataviewerStore_CreateViewer_Call struct { + *mock.Call +} + +// CreateViewer is a helper method to define mock.On call +// - ctx context.Context +// - viewer database.Dataviewer +func (_e *MockDataviewerStore_Expecter) CreateViewer(ctx interface{}, viewer interface{}) *MockDataviewerStore_CreateViewer_Call { + return &MockDataviewerStore_CreateViewer_Call{Call: _e.mock.On("CreateViewer", ctx, viewer)} +} + +func (_c *MockDataviewerStore_CreateViewer_Call) Run(run func(ctx context.Context, viewer database.Dataviewer)) *MockDataviewerStore_CreateViewer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(database.Dataviewer)) + }) + return _c +} + +func (_c *MockDataviewerStore_CreateViewer_Call) Return(_a0 error) *MockDataviewerStore_CreateViewer_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDataviewerStore_CreateViewer_Call) RunAndReturn(run func(context.Context, database.Dataviewer) error) *MockDataviewerStore_CreateViewer_Call { + _c.Call.Return(run) + return _c +} + +// GetJob provides a mock function with given fields: ctx, workflowID +func (_m *MockDataviewerStore) GetJob(ctx context.Context, workflowID string) (*database.DataviewerJob, error) { + ret := _m.Called(ctx, workflowID) + + if len(ret) == 0 { + panic("no return value specified for GetJob") + } + + var r0 *database.DataviewerJob + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*database.DataviewerJob, error)); ok { + return rf(ctx, workflowID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *database.DataviewerJob); ok { + r0 = rf(ctx, workflowID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.DataviewerJob) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, workflowID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataviewerStore_GetJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJob' +type MockDataviewerStore_GetJob_Call struct { + *mock.Call +} + +// GetJob is a helper method to define mock.On call +// - ctx context.Context +// - workflowID string +func (_e *MockDataviewerStore_Expecter) GetJob(ctx interface{}, workflowID interface{}) *MockDataviewerStore_GetJob_Call { + return &MockDataviewerStore_GetJob_Call{Call: _e.mock.On("GetJob", ctx, workflowID)} +} + +func (_c *MockDataviewerStore_GetJob_Call) Run(run func(ctx context.Context, workflowID string)) *MockDataviewerStore_GetJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockDataviewerStore_GetJob_Call) Return(_a0 *database.DataviewerJob, _a1 error) *MockDataviewerStore_GetJob_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataviewerStore_GetJob_Call) RunAndReturn(run func(context.Context, string) (*database.DataviewerJob, error)) *MockDataviewerStore_GetJob_Call { + _c.Call.Return(run) + return _c +} + +// GetRunningJobsByRepoID provides a mock function with given fields: ctx, repoID +func (_m *MockDataviewerStore) GetRunningJobsByRepoID(ctx context.Context, repoID int64) ([]database.DataviewerJob, error) { + ret := _m.Called(ctx, repoID) + + if len(ret) == 0 { + panic("no return value specified for GetRunningJobsByRepoID") + } + + var r0 []database.DataviewerJob + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64) ([]database.DataviewerJob, error)); ok { + return rf(ctx, repoID) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) []database.DataviewerJob); ok { + r0 = rf(ctx, repoID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]database.DataviewerJob) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { + r1 = rf(ctx, repoID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataviewerStore_GetRunningJobsByRepoID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRunningJobsByRepoID' +type MockDataviewerStore_GetRunningJobsByRepoID_Call struct { + *mock.Call +} + +// GetRunningJobsByRepoID is a helper method to define mock.On call +// - ctx context.Context +// - repoID int64 +func (_e *MockDataviewerStore_Expecter) GetRunningJobsByRepoID(ctx interface{}, repoID interface{}) *MockDataviewerStore_GetRunningJobsByRepoID_Call { + return &MockDataviewerStore_GetRunningJobsByRepoID_Call{Call: _e.mock.On("GetRunningJobsByRepoID", ctx, repoID)} +} + +func (_c *MockDataviewerStore_GetRunningJobsByRepoID_Call) Run(run func(ctx context.Context, repoID int64)) *MockDataviewerStore_GetRunningJobsByRepoID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockDataviewerStore_GetRunningJobsByRepoID_Call) Return(_a0 []database.DataviewerJob, _a1 error) *MockDataviewerStore_GetRunningJobsByRepoID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataviewerStore_GetRunningJobsByRepoID_Call) RunAndReturn(run func(context.Context, int64) ([]database.DataviewerJob, error)) *MockDataviewerStore_GetRunningJobsByRepoID_Call { + _c.Call.Return(run) + return _c +} + +// GetViewerByRepoID provides a mock function with given fields: ctx, repoID +func (_m *MockDataviewerStore) GetViewerByRepoID(ctx context.Context, repoID int64) (*database.Dataviewer, error) { + ret := _m.Called(ctx, repoID) + + if len(ret) == 0 { + panic("no return value specified for GetViewerByRepoID") + } + + var r0 *database.Dataviewer + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*database.Dataviewer, error)); ok { + return rf(ctx, repoID) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *database.Dataviewer); ok { + r0 = rf(ctx, repoID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.Dataviewer) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { + r1 = rf(ctx, repoID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataviewerStore_GetViewerByRepoID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetViewerByRepoID' +type MockDataviewerStore_GetViewerByRepoID_Call struct { + *mock.Call +} + +// GetViewerByRepoID is a helper method to define mock.On call +// - ctx context.Context +// - repoID int64 +func (_e *MockDataviewerStore_Expecter) GetViewerByRepoID(ctx interface{}, repoID interface{}) *MockDataviewerStore_GetViewerByRepoID_Call { + return &MockDataviewerStore_GetViewerByRepoID_Call{Call: _e.mock.On("GetViewerByRepoID", ctx, repoID)} +} + +func (_c *MockDataviewerStore_GetViewerByRepoID_Call) Run(run func(ctx context.Context, repoID int64)) *MockDataviewerStore_GetViewerByRepoID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockDataviewerStore_GetViewerByRepoID_Call) Return(_a0 *database.Dataviewer, _a1 error) *MockDataviewerStore_GetViewerByRepoID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataviewerStore_GetViewerByRepoID_Call) RunAndReturn(run func(context.Context, int64) (*database.Dataviewer, error)) *MockDataviewerStore_GetViewerByRepoID_Call { + _c.Call.Return(run) + return _c +} + +// UpdateJob provides a mock function with given fields: ctx, job +func (_m *MockDataviewerStore) UpdateJob(ctx context.Context, job database.DataviewerJob) (*database.DataviewerJob, error) { + ret := _m.Called(ctx, job) + + if len(ret) == 0 { + panic("no return value specified for UpdateJob") + } + + var r0 *database.DataviewerJob + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, database.DataviewerJob) (*database.DataviewerJob, error)); ok { + return rf(ctx, job) + } + if rf, ok := ret.Get(0).(func(context.Context, database.DataviewerJob) *database.DataviewerJob); ok { + r0 = rf(ctx, job) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.DataviewerJob) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, database.DataviewerJob) error); ok { + r1 = rf(ctx, job) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataviewerStore_UpdateJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateJob' +type MockDataviewerStore_UpdateJob_Call struct { + *mock.Call +} + +// UpdateJob is a helper method to define mock.On call +// - ctx context.Context +// - job database.DataviewerJob +func (_e *MockDataviewerStore_Expecter) UpdateJob(ctx interface{}, job interface{}) *MockDataviewerStore_UpdateJob_Call { + return &MockDataviewerStore_UpdateJob_Call{Call: _e.mock.On("UpdateJob", ctx, job)} +} + +func (_c *MockDataviewerStore_UpdateJob_Call) Run(run func(ctx context.Context, job database.DataviewerJob)) *MockDataviewerStore_UpdateJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(database.DataviewerJob)) + }) + return _c +} + +func (_c *MockDataviewerStore_UpdateJob_Call) Return(_a0 *database.DataviewerJob, _a1 error) *MockDataviewerStore_UpdateJob_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataviewerStore_UpdateJob_Call) RunAndReturn(run func(context.Context, database.DataviewerJob) (*database.DataviewerJob, error)) *MockDataviewerStore_UpdateJob_Call { + _c.Call.Return(run) + return _c +} + +// UpdateViewer provides a mock function with given fields: ctx, viewer +func (_m *MockDataviewerStore) UpdateViewer(ctx context.Context, viewer database.Dataviewer) (*database.Dataviewer, error) { + ret := _m.Called(ctx, viewer) + + if len(ret) == 0 { + panic("no return value specified for UpdateViewer") + } + + var r0 *database.Dataviewer + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, database.Dataviewer) (*database.Dataviewer, error)); ok { + return rf(ctx, viewer) + } + if rf, ok := ret.Get(0).(func(context.Context, database.Dataviewer) *database.Dataviewer); ok { + r0 = rf(ctx, viewer) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.Dataviewer) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, database.Dataviewer) error); ok { + r1 = rf(ctx, viewer) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataviewerStore_UpdateViewer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateViewer' +type MockDataviewerStore_UpdateViewer_Call struct { + *mock.Call +} + +// UpdateViewer is a helper method to define mock.On call +// - ctx context.Context +// - viewer database.Dataviewer +func (_e *MockDataviewerStore_Expecter) UpdateViewer(ctx interface{}, viewer interface{}) *MockDataviewerStore_UpdateViewer_Call { + return &MockDataviewerStore_UpdateViewer_Call{Call: _e.mock.On("UpdateViewer", ctx, viewer)} +} + +func (_c *MockDataviewerStore_UpdateViewer_Call) Run(run func(ctx context.Context, viewer database.Dataviewer)) *MockDataviewerStore_UpdateViewer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(database.Dataviewer)) + }) + return _c +} + +func (_c *MockDataviewerStore_UpdateViewer_Call) Return(_a0 *database.Dataviewer, _a1 error) *MockDataviewerStore_UpdateViewer_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataviewerStore_UpdateViewer_Call) RunAndReturn(run func(context.Context, database.Dataviewer) (*database.Dataviewer, error)) *MockDataviewerStore_UpdateViewer_Call { + _c.Call.Return(run) + return _c +} + +// NewMockDataviewerStore creates a new instance of MockDataviewerStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockDataviewerStore(t interface { + mock.TestingT + Cleanup(func()) +}) *MockDataviewerStore { + mock := &MockDataviewerStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_InternalComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_InternalComponent.go index 2b8d5397..f63723ab 100644 --- a/_mocks/opencsg.com/csghub-server/component/mock_InternalComponent.go +++ b/_mocks/opencsg.com/csghub-server/component/mock_InternalComponent.go @@ -316,6 +316,65 @@ func (_c *MockInternalComponent_SSHAllowed_Call) RunAndReturn(run func(context.C return _c } +// TriggerDataviewerWorkflow provides a mock function with given fields: ctx, req +func (_m *MockInternalComponent) TriggerDataviewerWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for TriggerDataviewerWorkflow") + } + + var r0 *types.WorkFlowInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) (*types.WorkFlowInfo, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) *types.WorkFlowInfo); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.WorkFlowInfo) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.UpdateViewerReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockInternalComponent_TriggerDataviewerWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TriggerDataviewerWorkflow' +type MockInternalComponent_TriggerDataviewerWorkflow_Call struct { + *mock.Call +} + +// TriggerDataviewerWorkflow is a helper method to define mock.On call +// - ctx context.Context +// - req types.UpdateViewerReq +func (_e *MockInternalComponent_Expecter) TriggerDataviewerWorkflow(ctx interface{}, req interface{}) *MockInternalComponent_TriggerDataviewerWorkflow_Call { + return &MockInternalComponent_TriggerDataviewerWorkflow_Call{Call: _e.mock.On("TriggerDataviewerWorkflow", ctx, req)} +} + +func (_c *MockInternalComponent_TriggerDataviewerWorkflow_Call) Run(run func(ctx context.Context, req types.UpdateViewerReq)) *MockInternalComponent_TriggerDataviewerWorkflow_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.UpdateViewerReq)) + }) + return _c +} + +func (_c *MockInternalComponent_TriggerDataviewerWorkflow_Call) Return(_a0 *types.WorkFlowInfo, _a1 error) *MockInternalComponent_TriggerDataviewerWorkflow_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockInternalComponent_TriggerDataviewerWorkflow_Call) RunAndReturn(run func(context.Context, types.UpdateViewerReq) (*types.WorkFlowInfo, error)) *MockInternalComponent_TriggerDataviewerWorkflow_Call { + _c.Call.Return(run) + return _c +} + // NewMockInternalComponent creates a new instance of MockInternalComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewMockInternalComponent(t interface { diff --git a/_mocks/opencsg.com/csghub-server/component/mock_ModelComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_ModelComponent.go index d2f9ada8..349eab60 100644 --- a/_mocks/opencsg.com/csghub-server/component/mock_ModelComponent.go +++ b/_mocks/opencsg.com/csghub-server/component/mock_ModelComponent.go @@ -130,65 +130,6 @@ func (_c *MockModelComponent_Create_Call) RunAndReturn(run func(context.Context, return _c } -// CreateRuntimeFramework provides a mock function with given fields: ctx, req -func (_m *MockModelComponent) CreateRuntimeFramework(ctx context.Context, req *types.RuntimeFrameworkReq) (*types.RuntimeFramework, error) { - ret := _m.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for CreateRuntimeFramework") - } - - var r0 *types.RuntimeFramework - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *types.RuntimeFrameworkReq) (*types.RuntimeFramework, error)); ok { - return rf(ctx, req) - } - if rf, ok := ret.Get(0).(func(context.Context, *types.RuntimeFrameworkReq) *types.RuntimeFramework); ok { - r0 = rf(ctx, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*types.RuntimeFramework) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *types.RuntimeFrameworkReq) error); ok { - r1 = rf(ctx, req) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockModelComponent_CreateRuntimeFramework_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRuntimeFramework' -type MockModelComponent_CreateRuntimeFramework_Call struct { - *mock.Call -} - -// CreateRuntimeFramework is a helper method to define mock.On call -// - ctx context.Context -// - req *types.RuntimeFrameworkReq -func (_e *MockModelComponent_Expecter) CreateRuntimeFramework(ctx interface{}, req interface{}) *MockModelComponent_CreateRuntimeFramework_Call { - return &MockModelComponent_CreateRuntimeFramework_Call{Call: _e.mock.On("CreateRuntimeFramework", ctx, req)} -} - -func (_c *MockModelComponent_CreateRuntimeFramework_Call) Run(run func(ctx context.Context, req *types.RuntimeFrameworkReq)) *MockModelComponent_CreateRuntimeFramework_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*types.RuntimeFrameworkReq)) - }) - return _c -} - -func (_c *MockModelComponent_CreateRuntimeFramework_Call) Return(_a0 *types.RuntimeFramework, _a1 error) *MockModelComponent_CreateRuntimeFramework_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockModelComponent_CreateRuntimeFramework_Call) RunAndReturn(run func(context.Context, *types.RuntimeFrameworkReq) (*types.RuntimeFramework, error)) *MockModelComponent_CreateRuntimeFramework_Call { - _c.Call.Return(run) - return _c -} - // DelRelationDataset provides a mock function with given fields: ctx, req func (_m *MockModelComponent) DelRelationDataset(ctx context.Context, req types.RelationDataset) error { ret := _m.Called(ctx, req) diff --git a/_mocks/opencsg.com/csghub-server/dataviewer/workflows/mock_DataViewerActivity.go b/_mocks/opencsg.com/csghub-server/dataviewer/workflows/mock_DataViewerActivity.go new file mode 100644 index 00000000..35fbc0b4 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/dataviewer/workflows/mock_DataViewerActivity.go @@ -0,0 +1,742 @@ +// Code generated by mockery v2.49.1. DO NOT EDIT. + +package workflows + +import ( + context "context" + + common "opencsg.com/csghub-server/dataviewer/common" + + mock "github.com/stretchr/testify/mock" + + types "opencsg.com/csghub-server/common/types" +) + +// MockDataViewerActivity is an autogenerated mock type for the DataViewerActivity type +type MockDataViewerActivity struct { + mock.Mock +} + +type MockDataViewerActivity_Expecter struct { + mock *mock.Mock +} + +func (_m *MockDataViewerActivity) EXPECT() *MockDataViewerActivity_Expecter { + return &MockDataViewerActivity_Expecter{mock: &_m.Mock} +} + +// BeginViewerJob provides a mock function with given fields: ctx +func (_m *MockDataViewerActivity) BeginViewerJob(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for BeginViewerJob") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDataViewerActivity_BeginViewerJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BeginViewerJob' +type MockDataViewerActivity_BeginViewerJob_Call struct { + *mock.Call +} + +// BeginViewerJob is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockDataViewerActivity_Expecter) BeginViewerJob(ctx interface{}) *MockDataViewerActivity_BeginViewerJob_Call { + return &MockDataViewerActivity_BeginViewerJob_Call{Call: _e.mock.On("BeginViewerJob", ctx)} +} + +func (_c *MockDataViewerActivity_BeginViewerJob_Call) Run(run func(ctx context.Context)) *MockDataViewerActivity_BeginViewerJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockDataViewerActivity_BeginViewerJob_Call) Return(_a0 error) *MockDataViewerActivity_BeginViewerJob_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDataViewerActivity_BeginViewerJob_Call) RunAndReturn(run func(context.Context) error) *MockDataViewerActivity_BeginViewerJob_Call { + _c.Call.Return(run) + return _c +} + +// CheckIfNeedRebuild provides a mock function with given fields: ctx, checkParam +func (_m *MockDataViewerActivity) CheckIfNeedRebuild(ctx context.Context, checkParam common.CheckBuildReq) (bool, error) { + ret := _m.Called(ctx, checkParam) + + if len(ret) == 0 { + panic("no return value specified for CheckIfNeedRebuild") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.CheckBuildReq) (bool, error)); ok { + return rf(ctx, checkParam) + } + if rf, ok := ret.Get(0).(func(context.Context, common.CheckBuildReq) bool); ok { + r0 = rf(ctx, checkParam) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, common.CheckBuildReq) error); ok { + r1 = rf(ctx, checkParam) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_CheckIfNeedRebuild_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckIfNeedRebuild' +type MockDataViewerActivity_CheckIfNeedRebuild_Call struct { + *mock.Call +} + +// CheckIfNeedRebuild is a helper method to define mock.On call +// - ctx context.Context +// - checkParam common.CheckBuildReq +func (_e *MockDataViewerActivity_Expecter) CheckIfNeedRebuild(ctx interface{}, checkParam interface{}) *MockDataViewerActivity_CheckIfNeedRebuild_Call { + return &MockDataViewerActivity_CheckIfNeedRebuild_Call{Call: _e.mock.On("CheckIfNeedRebuild", ctx, checkParam)} +} + +func (_c *MockDataViewerActivity_CheckIfNeedRebuild_Call) Run(run func(ctx context.Context, checkParam common.CheckBuildReq)) *MockDataViewerActivity_CheckIfNeedRebuild_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.CheckBuildReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_CheckIfNeedRebuild_Call) Return(_a0 bool, _a1 error) *MockDataViewerActivity_CheckIfNeedRebuild_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_CheckIfNeedRebuild_Call) RunAndReturn(run func(context.Context, common.CheckBuildReq) (bool, error)) *MockDataViewerActivity_CheckIfNeedRebuild_Call { + _c.Call.Return(run) + return _c +} + +// CleanUp provides a mock function with given fields: ctx, req +func (_m *MockDataViewerActivity) CleanUp(ctx context.Context, req types.UpdateViewerReq) error { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for CleanUp") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) error); ok { + r0 = rf(ctx, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDataViewerActivity_CleanUp_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanUp' +type MockDataViewerActivity_CleanUp_Call struct { + *mock.Call +} + +// CleanUp is a helper method to define mock.On call +// - ctx context.Context +// - req types.UpdateViewerReq +func (_e *MockDataViewerActivity_Expecter) CleanUp(ctx interface{}, req interface{}) *MockDataViewerActivity_CleanUp_Call { + return &MockDataViewerActivity_CleanUp_Call{Call: _e.mock.On("CleanUp", ctx, req)} +} + +func (_c *MockDataViewerActivity_CleanUp_Call) Run(run func(ctx context.Context, req types.UpdateViewerReq)) *MockDataViewerActivity_CleanUp_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.UpdateViewerReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_CleanUp_Call) Return(_a0 error) *MockDataViewerActivity_CleanUp_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDataViewerActivity_CleanUp_Call) RunAndReturn(run func(context.Context, types.UpdateViewerReq) error) *MockDataViewerActivity_CleanUp_Call { + _c.Call.Return(run) + return _c +} + +// ConvertToParquetFiles provides a mock function with given fields: ctx, convertReq +func (_m *MockDataViewerActivity) ConvertToParquetFiles(ctx context.Context, convertReq common.ConvertReq) error { + ret := _m.Called(ctx, convertReq) + + if len(ret) == 0 { + panic("no return value specified for ConvertToParquetFiles") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, common.ConvertReq) error); ok { + r0 = rf(ctx, convertReq) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDataViewerActivity_ConvertToParquetFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConvertToParquetFiles' +type MockDataViewerActivity_ConvertToParquetFiles_Call struct { + *mock.Call +} + +// ConvertToParquetFiles is a helper method to define mock.On call +// - ctx context.Context +// - convertReq common.ConvertReq +func (_e *MockDataViewerActivity_Expecter) ConvertToParquetFiles(ctx interface{}, convertReq interface{}) *MockDataViewerActivity_ConvertToParquetFiles_Call { + return &MockDataViewerActivity_ConvertToParquetFiles_Call{Call: _e.mock.On("ConvertToParquetFiles", ctx, convertReq)} +} + +func (_c *MockDataViewerActivity_ConvertToParquetFiles_Call) Run(run func(ctx context.Context, convertReq common.ConvertReq)) *MockDataViewerActivity_ConvertToParquetFiles_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.ConvertReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_ConvertToParquetFiles_Call) Return(_a0 error) *MockDataViewerActivity_ConvertToParquetFiles_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDataViewerActivity_ConvertToParquetFiles_Call) RunAndReturn(run func(context.Context, common.ConvertReq) error) *MockDataViewerActivity_ConvertToParquetFiles_Call { + _c.Call.Return(run) + return _c +} + +// CopyParquetFiles provides a mock function with given fields: ctx, copyReq +func (_m *MockDataViewerActivity) CopyParquetFiles(ctx context.Context, copyReq common.CopyParquetReq) (*common.CardData, error) { + ret := _m.Called(ctx, copyReq) + + if len(ret) == 0 { + panic("no return value specified for CopyParquetFiles") + } + + var r0 *common.CardData + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.CopyParquetReq) (*common.CardData, error)); ok { + return rf(ctx, copyReq) + } + if rf, ok := ret.Get(0).(func(context.Context, common.CopyParquetReq) *common.CardData); ok { + r0 = rf(ctx, copyReq) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.CardData) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.CopyParquetReq) error); ok { + r1 = rf(ctx, copyReq) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_CopyParquetFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CopyParquetFiles' +type MockDataViewerActivity_CopyParquetFiles_Call struct { + *mock.Call +} + +// CopyParquetFiles is a helper method to define mock.On call +// - ctx context.Context +// - copyReq common.CopyParquetReq +func (_e *MockDataViewerActivity_Expecter) CopyParquetFiles(ctx interface{}, copyReq interface{}) *MockDataViewerActivity_CopyParquetFiles_Call { + return &MockDataViewerActivity_CopyParquetFiles_Call{Call: _e.mock.On("CopyParquetFiles", ctx, copyReq)} +} + +func (_c *MockDataViewerActivity_CopyParquetFiles_Call) Run(run func(ctx context.Context, copyReq common.CopyParquetReq)) *MockDataViewerActivity_CopyParquetFiles_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.CopyParquetReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_CopyParquetFiles_Call) Return(_a0 *common.CardData, _a1 error) *MockDataViewerActivity_CopyParquetFiles_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_CopyParquetFiles_Call) RunAndReturn(run func(context.Context, common.CopyParquetReq) (*common.CardData, error)) *MockDataViewerActivity_CopyParquetFiles_Call { + _c.Call.Return(run) + return _c +} + +// CreateParquetBranch provides a mock function with given fields: ctx, req +func (_m *MockDataViewerActivity) CreateParquetBranch(ctx context.Context, req types.UpdateViewerReq) (string, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for CreateParquetBranch") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) (string, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) string); ok { + r0 = rf(ctx, req) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(context.Context, types.UpdateViewerReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_CreateParquetBranch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateParquetBranch' +type MockDataViewerActivity_CreateParquetBranch_Call struct { + *mock.Call +} + +// CreateParquetBranch is a helper method to define mock.On call +// - ctx context.Context +// - req types.UpdateViewerReq +func (_e *MockDataViewerActivity_Expecter) CreateParquetBranch(ctx interface{}, req interface{}) *MockDataViewerActivity_CreateParquetBranch_Call { + return &MockDataViewerActivity_CreateParquetBranch_Call{Call: _e.mock.On("CreateParquetBranch", ctx, req)} +} + +func (_c *MockDataViewerActivity_CreateParquetBranch_Call) Run(run func(ctx context.Context, req types.UpdateViewerReq)) *MockDataViewerActivity_CreateParquetBranch_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.UpdateViewerReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_CreateParquetBranch_Call) Return(_a0 string, _a1 error) *MockDataViewerActivity_CreateParquetBranch_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_CreateParquetBranch_Call) RunAndReturn(run func(context.Context, types.UpdateViewerReq) (string, error)) *MockDataViewerActivity_CreateParquetBranch_Call { + _c.Call.Return(run) + return _c +} + +// DetermineCardData provides a mock function with given fields: ctx, determineParam +func (_m *MockDataViewerActivity) DetermineCardData(ctx context.Context, determineParam common.DetermineCardReq) (*common.CardData, error) { + ret := _m.Called(ctx, determineParam) + + if len(ret) == 0 { + panic("no return value specified for DetermineCardData") + } + + var r0 *common.CardData + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.DetermineCardReq) (*common.CardData, error)); ok { + return rf(ctx, determineParam) + } + if rf, ok := ret.Get(0).(func(context.Context, common.DetermineCardReq) *common.CardData); ok { + r0 = rf(ctx, determineParam) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.CardData) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.DetermineCardReq) error); ok { + r1 = rf(ctx, determineParam) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_DetermineCardData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DetermineCardData' +type MockDataViewerActivity_DetermineCardData_Call struct { + *mock.Call +} + +// DetermineCardData is a helper method to define mock.On call +// - ctx context.Context +// - determineParam common.DetermineCardReq +func (_e *MockDataViewerActivity_Expecter) DetermineCardData(ctx interface{}, determineParam interface{}) *MockDataViewerActivity_DetermineCardData_Call { + return &MockDataViewerActivity_DetermineCardData_Call{Call: _e.mock.On("DetermineCardData", ctx, determineParam)} +} + +func (_c *MockDataViewerActivity_DetermineCardData_Call) Run(run func(ctx context.Context, determineParam common.DetermineCardReq)) *MockDataViewerActivity_DetermineCardData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.DetermineCardReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_DetermineCardData_Call) Return(_a0 *common.CardData, _a1 error) *MockDataViewerActivity_DetermineCardData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_DetermineCardData_Call) RunAndReturn(run func(context.Context, common.DetermineCardReq) (*common.CardData, error)) *MockDataViewerActivity_DetermineCardData_Call { + _c.Call.Return(run) + return _c +} + +// DownloadSplitFiles provides a mock function with given fields: ctx, downloadReq +func (_m *MockDataViewerActivity) DownloadSplitFiles(ctx context.Context, downloadReq common.DownloadFileReq) (*common.DownloadCard, error) { + ret := _m.Called(ctx, downloadReq) + + if len(ret) == 0 { + panic("no return value specified for DownloadSplitFiles") + } + + var r0 *common.DownloadCard + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.DownloadFileReq) (*common.DownloadCard, error)); ok { + return rf(ctx, downloadReq) + } + if rf, ok := ret.Get(0).(func(context.Context, common.DownloadFileReq) *common.DownloadCard); ok { + r0 = rf(ctx, downloadReq) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.DownloadCard) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.DownloadFileReq) error); ok { + r1 = rf(ctx, downloadReq) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_DownloadSplitFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DownloadSplitFiles' +type MockDataViewerActivity_DownloadSplitFiles_Call struct { + *mock.Call +} + +// DownloadSplitFiles is a helper method to define mock.On call +// - ctx context.Context +// - downloadReq common.DownloadFileReq +func (_e *MockDataViewerActivity_Expecter) DownloadSplitFiles(ctx interface{}, downloadReq interface{}) *MockDataViewerActivity_DownloadSplitFiles_Call { + return &MockDataViewerActivity_DownloadSplitFiles_Call{Call: _e.mock.On("DownloadSplitFiles", ctx, downloadReq)} +} + +func (_c *MockDataViewerActivity_DownloadSplitFiles_Call) Run(run func(ctx context.Context, downloadReq common.DownloadFileReq)) *MockDataViewerActivity_DownloadSplitFiles_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.DownloadFileReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_DownloadSplitFiles_Call) Return(_a0 *common.DownloadCard, _a1 error) *MockDataViewerActivity_DownloadSplitFiles_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_DownloadSplitFiles_Call) RunAndReturn(run func(context.Context, common.DownloadFileReq) (*common.DownloadCard, error)) *MockDataViewerActivity_DownloadSplitFiles_Call { + _c.Call.Return(run) + return _c +} + +// GetCardFromReadme provides a mock function with given fields: ctx, req +func (_m *MockDataViewerActivity) GetCardFromReadme(ctx context.Context, req types.UpdateViewerReq) (*common.CardData, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetCardFromReadme") + } + + var r0 *common.CardData + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) (*common.CardData, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.UpdateViewerReq) *common.CardData); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.CardData) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.UpdateViewerReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_GetCardFromReadme_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCardFromReadme' +type MockDataViewerActivity_GetCardFromReadme_Call struct { + *mock.Call +} + +// GetCardFromReadme is a helper method to define mock.On call +// - ctx context.Context +// - req types.UpdateViewerReq +func (_e *MockDataViewerActivity_Expecter) GetCardFromReadme(ctx interface{}, req interface{}) *MockDataViewerActivity_GetCardFromReadme_Call { + return &MockDataViewerActivity_GetCardFromReadme_Call{Call: _e.mock.On("GetCardFromReadme", ctx, req)} +} + +func (_c *MockDataViewerActivity_GetCardFromReadme_Call) Run(run func(ctx context.Context, req types.UpdateViewerReq)) *MockDataViewerActivity_GetCardFromReadme_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.UpdateViewerReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_GetCardFromReadme_Call) Return(_a0 *common.CardData, _a1 error) *MockDataViewerActivity_GetCardFromReadme_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_GetCardFromReadme_Call) RunAndReturn(run func(context.Context, types.UpdateViewerReq) (*common.CardData, error)) *MockDataViewerActivity_GetCardFromReadme_Call { + _c.Call.Return(run) + return _c +} + +// ScanRepoFiles provides a mock function with given fields: ctx, scanParam +func (_m *MockDataViewerActivity) ScanRepoFiles(ctx context.Context, scanParam common.ScanRepoFileReq) (*common.RepoFilesClass, error) { + ret := _m.Called(ctx, scanParam) + + if len(ret) == 0 { + panic("no return value specified for ScanRepoFiles") + } + + var r0 *common.RepoFilesClass + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.ScanRepoFileReq) (*common.RepoFilesClass, error)); ok { + return rf(ctx, scanParam) + } + if rf, ok := ret.Get(0).(func(context.Context, common.ScanRepoFileReq) *common.RepoFilesClass); ok { + r0 = rf(ctx, scanParam) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.RepoFilesClass) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.ScanRepoFileReq) error); ok { + r1 = rf(ctx, scanParam) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_ScanRepoFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ScanRepoFiles' +type MockDataViewerActivity_ScanRepoFiles_Call struct { + *mock.Call +} + +// ScanRepoFiles is a helper method to define mock.On call +// - ctx context.Context +// - scanParam common.ScanRepoFileReq +func (_e *MockDataViewerActivity_Expecter) ScanRepoFiles(ctx interface{}, scanParam interface{}) *MockDataViewerActivity_ScanRepoFiles_Call { + return &MockDataViewerActivity_ScanRepoFiles_Call{Call: _e.mock.On("ScanRepoFiles", ctx, scanParam)} +} + +func (_c *MockDataViewerActivity_ScanRepoFiles_Call) Run(run func(ctx context.Context, scanParam common.ScanRepoFileReq)) *MockDataViewerActivity_ScanRepoFiles_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.ScanRepoFileReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_ScanRepoFiles_Call) Return(_a0 *common.RepoFilesClass, _a1 error) *MockDataViewerActivity_ScanRepoFiles_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_ScanRepoFiles_Call) RunAndReturn(run func(context.Context, common.ScanRepoFileReq) (*common.RepoFilesClass, error)) *MockDataViewerActivity_ScanRepoFiles_Call { + _c.Call.Return(run) + return _c +} + +// UpdateCardData provides a mock function with given fields: ctx, cardReq +func (_m *MockDataViewerActivity) UpdateCardData(ctx context.Context, cardReq common.UpdateCardReq) error { + ret := _m.Called(ctx, cardReq) + + if len(ret) == 0 { + panic("no return value specified for UpdateCardData") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, common.UpdateCardReq) error); ok { + r0 = rf(ctx, cardReq) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDataViewerActivity_UpdateCardData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateCardData' +type MockDataViewerActivity_UpdateCardData_Call struct { + *mock.Call +} + +// UpdateCardData is a helper method to define mock.On call +// - ctx context.Context +// - cardReq common.UpdateCardReq +func (_e *MockDataViewerActivity_Expecter) UpdateCardData(ctx interface{}, cardReq interface{}) *MockDataViewerActivity_UpdateCardData_Call { + return &MockDataViewerActivity_UpdateCardData_Call{Call: _e.mock.On("UpdateCardData", ctx, cardReq)} +} + +func (_c *MockDataViewerActivity_UpdateCardData_Call) Run(run func(ctx context.Context, cardReq common.UpdateCardReq)) *MockDataViewerActivity_UpdateCardData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.UpdateCardReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_UpdateCardData_Call) Return(_a0 error) *MockDataViewerActivity_UpdateCardData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDataViewerActivity_UpdateCardData_Call) RunAndReturn(run func(context.Context, common.UpdateCardReq) error) *MockDataViewerActivity_UpdateCardData_Call { + _c.Call.Return(run) + return _c +} + +// UpdateWorkflowStatus provides a mock function with given fields: ctx, status +func (_m *MockDataViewerActivity) UpdateWorkflowStatus(ctx context.Context, status common.UpdateWorkflowStatusReq) error { + ret := _m.Called(ctx, status) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkflowStatus") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, common.UpdateWorkflowStatusReq) error); ok { + r0 = rf(ctx, status) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockDataViewerActivity_UpdateWorkflowStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateWorkflowStatus' +type MockDataViewerActivity_UpdateWorkflowStatus_Call struct { + *mock.Call +} + +// UpdateWorkflowStatus is a helper method to define mock.On call +// - ctx context.Context +// - status common.UpdateWorkflowStatusReq +func (_e *MockDataViewerActivity_Expecter) UpdateWorkflowStatus(ctx interface{}, status interface{}) *MockDataViewerActivity_UpdateWorkflowStatus_Call { + return &MockDataViewerActivity_UpdateWorkflowStatus_Call{Call: _e.mock.On("UpdateWorkflowStatus", ctx, status)} +} + +func (_c *MockDataViewerActivity_UpdateWorkflowStatus_Call) Run(run func(ctx context.Context, status common.UpdateWorkflowStatusReq)) *MockDataViewerActivity_UpdateWorkflowStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.UpdateWorkflowStatusReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_UpdateWorkflowStatus_Call) Return(_a0 error) *MockDataViewerActivity_UpdateWorkflowStatus_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockDataViewerActivity_UpdateWorkflowStatus_Call) RunAndReturn(run func(context.Context, common.UpdateWorkflowStatusReq) error) *MockDataViewerActivity_UpdateWorkflowStatus_Call { + _c.Call.Return(run) + return _c +} + +// UploadParquetFiles provides a mock function with given fields: ctx, uploadReq +func (_m *MockDataViewerActivity) UploadParquetFiles(ctx context.Context, uploadReq common.UploadParquetReq) (*common.CardData, error) { + ret := _m.Called(ctx, uploadReq) + + if len(ret) == 0 { + panic("no return value specified for UploadParquetFiles") + } + + var r0 *common.CardData + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.UploadParquetReq) (*common.CardData, error)); ok { + return rf(ctx, uploadReq) + } + if rf, ok := ret.Get(0).(func(context.Context, common.UploadParquetReq) *common.CardData); ok { + r0 = rf(ctx, uploadReq) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*common.CardData) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.UploadParquetReq) error); ok { + r1 = rf(ctx, uploadReq) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDataViewerActivity_UploadParquetFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UploadParquetFiles' +type MockDataViewerActivity_UploadParquetFiles_Call struct { + *mock.Call +} + +// UploadParquetFiles is a helper method to define mock.On call +// - ctx context.Context +// - uploadReq common.UploadParquetReq +func (_e *MockDataViewerActivity_Expecter) UploadParquetFiles(ctx interface{}, uploadReq interface{}) *MockDataViewerActivity_UploadParquetFiles_Call { + return &MockDataViewerActivity_UploadParquetFiles_Call{Call: _e.mock.On("UploadParquetFiles", ctx, uploadReq)} +} + +func (_c *MockDataViewerActivity_UploadParquetFiles_Call) Run(run func(ctx context.Context, uploadReq common.UploadParquetReq)) *MockDataViewerActivity_UploadParquetFiles_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.UploadParquetReq)) + }) + return _c +} + +func (_c *MockDataViewerActivity_UploadParquetFiles_Call) Return(_a0 *common.CardData, _a1 error) *MockDataViewerActivity_UploadParquetFiles_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDataViewerActivity_UploadParquetFiles_Call) RunAndReturn(run func(context.Context, common.UploadParquetReq) (*common.CardData, error)) *MockDataViewerActivity_UploadParquetFiles_Call { + _c.Call.Return(run) + return _c +} + +// NewMockDataViewerActivity creates a new instance of MockDataViewerActivity. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockDataViewerActivity(t interface { + mock.TestingT + Cleanup(func()) +}) *MockDataViewerActivity { + mock := &MockDataViewerActivity{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/api/handler/dataset_viewer.go b/api/handler/dataset_viewer.go deleted file mode 100644 index 4f2d649d..00000000 --- a/api/handler/dataset_viewer.go +++ /dev/null @@ -1,65 +0,0 @@ -package handler - -import ( - "log/slog" - "strconv" - - "github.com/gin-gonic/gin" - "opencsg.com/csghub-server/api/httpbase" - "opencsg.com/csghub-server/common/config" - "opencsg.com/csghub-server/common/utils/common" - "opencsg.com/csghub-server/component" -) - -type DatasetViewerHandler struct { - c component.DatasetViewerComponent -} - -func NewDatasetViewerHandler(cfg *config.Config) (*DatasetViewerHandler, error) { - dvc, err := component.NewDatasetViewerComponent(cfg) - if err != nil { - return nil, err - } - - return &DatasetViewerHandler{ - c: dvc, - }, nil -} - -// GetDatasetDemoData godoc -// @Security ApiKey -// @Summary Get the demo data of the dataset -// @Description get the demo data of the dataset -// @Tags Dataset -// @Accept json -// @Produce json -// @Param namespace path string true "namespace" -// @Parsm name path string true "name" -// @Param file_path path string true "file_path" -// @Param count query int true "count" -// @Success 200 {object} types.Response{} "OK" -// @Failure 400 {object} types.APIBadRequest "Bad request" -// @Failure 500 {object} types.APIInternalServerError "Internal server error" -// @Router /datasets/{namespace}/{name}/viewer/{file_path} [get] -func (h *DatasetViewerHandler) View(ctx *gin.Context) { - namespace, name, err := common.GetNamespaceAndNameFromContext(ctx) - if err != nil { - slog.Error("Bad request format", "error", err) - httpbase.BadRequest(ctx, err.Error()) - return - } - req := new(component.ViewParquetFileReq) - req.Namespace = namespace - req.RepoName = name - req.Path = ctx.Param("file_path") - pcount := ctx.Query("count") - req.RowCount, _ = strconv.Atoi(pcount) - resp, err := h.c.ViewParquetFile(ctx.Request.Context(), req) - if err != nil { - slog.Error("Failed to view parquet file", "error", err) - httpbase.ServerError(ctx, err) - return - } - - httpbase.OK(ctx, resp) -} diff --git a/api/handler/internal.go b/api/handler/internal.go index 91e6950d..de93efab 100644 --- a/api/handler/internal.go +++ b/api/handler/internal.go @@ -1,6 +1,7 @@ package handler import ( + "context" "log/slog" "net/http" "strings" @@ -13,6 +14,7 @@ import ( "opencsg.com/csghub-server/common/config" "opencsg.com/csghub-server/common/types" "opencsg.com/csghub-server/component" + dvCom "opencsg.com/csghub-server/dataviewer/common" ) func NewInternalHandler(config *config.Config) (*InternalHandler, error) { @@ -101,15 +103,23 @@ func (h *InternalHandler) LfsAuthenticate(ctx *gin.Context) { ctx.PureJSON(http.StatusOK, resp) } -// TODO: add logic func (h *InternalHandler) PreReceive(ctx *gin.Context) { ctx.PureJSON(http.StatusOK, gin.H{ "reference_counter_increased": true, }) } -// TODO: add logic func (h *InternalHandler) PostReceive(ctx *gin.Context) { + successResp := gin.H{ + "reference_counter_decreased": true, + "messages": []Messages{ + { + Message: "Welcome to OpenCSG!", + Type: "alert", + }, + }, + } + var req types.PostReceiveReq if err := ctx.ShouldBind(&req); err != nil { slog.Error("Bad request format", "error", err) @@ -123,6 +133,7 @@ func (h *InternalHandler) PostReceive(ctx *gin.Context) { // the format of ref is main ref = strings.ReplaceAll(ref, "\n", "") paths := strings.Split(req.GlRepository, "/") + diffReq := types.GetDiffBetweenTwoCommitsReq{ LeftCommitId: strs[0], RightCommitId: strs[1], @@ -134,10 +145,17 @@ func (h *InternalHandler) PostReceive(ctx *gin.Context) { callback, err := h.internal.GetCommitDiff(ctx.Request.Context(), diffReq) if err != nil { slog.Error("post receive: failed to get commit diff", slog.Any("error", err)) - httpbase.ServerError(ctx, err) - return + if diffReq.RightCommitId == types.NoCommitID { + // delete branch action + ctx.PureJSON(http.StatusOK, successResp) + return + } else { + httpbase.ServerError(ctx, err) + return + } } callback.Ref = originalRef + //start workflow to handle push request workflowOptions := client.StartWorkflowOptions{ TaskQueue: workflow.HandlePushQueueName, @@ -151,17 +169,32 @@ func (h *InternalHandler) PostReceive(ctx *gin.Context) { httpbase.ServerError(ctx, err) return } + + if diffReq.RepoType == types.DatasetRepo { + h.CallDataViewer(ctx.Request.Context(), diffReq.Namespace, diffReq.Name, diffReq.Ref) + } + slog.Info("start handle push workflow", slog.String("workflow_id", we.GetID()), slog.Any("req", callback)) - ctx.PureJSON(http.StatusOK, gin.H{ - "reference_counter_decreased": true, - "messages": []Messages{ - { - Message: "Welcome to OpenCSG!", - Type: "alert", - }, - }, - }) + ctx.PureJSON(http.StatusOK, successResp) +} + +func (h *InternalHandler) CallDataViewer(ctx context.Context, namespace, name, branch string) { + if branch == dvCom.ParquetBranch || branch == dvCom.DuckdbBranch { + return + } + req := types.UpdateViewerReq{ + Namespace: namespace, + Name: name, + Branch: branch, + RepoType: types.DatasetRepo, + } + res, err := h.internal.TriggerDataviewerWorkflow(ctx, req) + if err != nil { + slog.Error("fail to read dataviewer response", slog.Any("req", req), slog.Any("err", err)) + return + } + slog.Info("dataviewer callback response", slog.Any("req", req), slog.Any("res", res)) } func (h *InternalHandler) GetAuthorizedKeys(ctx *gin.Context) { diff --git a/api/router/api.go b/api/router/api.go index 3ad4c5fe..2a9c1474 100644 --- a/api/router/api.go +++ b/api/router/api.go @@ -427,6 +427,13 @@ func NewRouter(config *config.Config, enableSwagger bool) (*gin.Engine, error) { return nil, fmt.Errorf("error creating prompt handler,%w", err) } createPromptRoutes(apiGroup, promptHandler) + + dataViewerAddr := fmt.Sprintf("%s:%d", config.DataViewer.Host, config.DataViewer.Port) + dsViewerHandler, err := handler.NewInternalServiceProxyHandler(dataViewerAddr) + if err != nil { + return nil, fmt.Errorf("error creating dataset viewer proxy:%w", err) + } + createDataViewerRoutes(apiGroup, dsViewerHandler) return r, nil } @@ -837,3 +844,15 @@ func createTagsRoutes(apiGroup *gin.RouterGroup, tagHandler *handler.TagsHandler tagsGrp.DELETE("/:id", tagHandler.DeleteTag) } } + +func createDataViewerRoutes(apiGroup *gin.RouterGroup, dsViewerHandler *handler.InternalServiceProxyHandler) { + datasetRepoGrp := apiGroup.Group("/datasets/:namespace/:name") + fileViewerGrp := datasetRepoGrp.Group("/viewer") + { + fileViewerGrp.Any("/*any", dsViewerHandler.Proxy) + } + dataViewerGrp := datasetRepoGrp.Group("/dataviewer") + { + dataViewerGrp.Any("/*any", dsViewerHandler.Proxy) + } +} diff --git a/builder/dataviewer/client.go b/builder/dataviewer/client.go new file mode 100644 index 00000000..3037f37a --- /dev/null +++ b/builder/dataviewer/client.go @@ -0,0 +1,38 @@ +package dataviewer + +import ( + "context" + "fmt" + + "opencsg.com/csghub-server/api/httpbase" + "opencsg.com/csghub-server/builder/rpc" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" +) + +type DataviewerClient interface { + TriggerWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) +} + +type dataviewerClientImpl struct { + hc *rpc.HttpClient +} + +func NewDataviewerClient(config *config.Config, opts ...rpc.RequestOption) DataviewerClient { + remoteURL := fmt.Sprintf("%s:%d", config.DataViewer.Host, config.DataViewer.Port) + return &dataviewerClientImpl{ + hc: rpc.NewHttpClient(remoteURL, opts...), + } +} + +func (c *dataviewerClientImpl) TriggerWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) { + url := fmt.Sprintf("/api/v1/%ss/%s/%s/callback/%s", req.RepoType, req.Namespace, req.Name, req.Branch) + var r httpbase.R + r.Data = &types.WorkFlowInfo{} + err := c.hc.Post(ctx, url, nil, &r) + if err != nil { + return nil, fmt.Errorf("fail trigger workflow repo %s/%s branch %s", req.Namespace, req.Name, req.Branch) + } + + return r.Data.(*types.WorkFlowInfo), nil +} diff --git a/builder/git/gitserver/gitaly/branch.go b/builder/git/gitserver/gitaly/branch.go index 5f44e4f5..783d9ca6 100644 --- a/builder/git/gitserver/gitaly/branch.go +++ b/builder/git/gitserver/gitaly/branch.go @@ -49,3 +49,61 @@ func (c *Client) GetRepoBranches(ctx context.Context, req gitserver.GetBranchesR return branches, nil } + +func (c *Client) GetRepoBranchByName(ctx context.Context, req gitserver.GetBranchReq) (*types.Branch, error) { + var branch types.Branch + repoType := fmt.Sprintf("%ss", string(req.RepoType)) + ctx, cancel := context.WithTimeout(ctx, timeoutTime) + defer cancel() + branchReq := &gitalypb.FindBranchRequest{ + Repository: &gitalypb.Repository{ + StorageName: c.config.GitalyServer.Storge, + RelativePath: BuildRelativePath(repoType, req.Namespace, req.Name), + }, + Name: []byte(req.Ref), + } + resp, err := c.refClient.FindBranch(ctx, branchReq) + + if err != nil { + return nil, err + } + + // if branch not found, return nil + if resp == nil || resp.Branch == nil { + return nil, nil + } + + branch.Name = filepath.Base(string(resp.Branch.Name)) + branch.Message = string(resp.Branch.TargetCommit.Subject) + branch.Commit = types.RepoBranchCommit{ + ID: resp.Branch.TargetCommit.Id, + } + + return &branch, nil +} + +func (c *Client) DeleteRepoBranch(ctx context.Context, req gitserver.DeleteBranchReq) error { + repoType := fmt.Sprintf("%ss", string(req.RepoType)) + + deleteBranchReq := &gitalypb.UserDeleteBranchRequest{ + Repository: &gitalypb.Repository{ + StorageName: c.config.GitalyServer.Storge, + RelativePath: BuildRelativePath(repoType, req.Namespace, req.Name), + GlRepository: filepath.Join(repoType, req.Namespace, req.Name), + }, + BranchName: []byte(req.Ref), + User: &gitalypb.User{ + GlId: "user-1", + Name: []byte(req.Name), + GlUsername: req.Username, + Email: []byte(req.Email), + }, + } + + _, err := c.operationClient.UserDeleteBranch(ctx, deleteBranchReq) + if err != nil { + return err + } + + return nil +} diff --git a/builder/git/gitserver/gitea/branch.go b/builder/git/gitserver/gitea/branch.go index bb10762b..df7e435a 100644 --- a/builder/git/gitserver/gitea/branch.go +++ b/builder/git/gitserver/gitea/branch.go @@ -33,3 +33,32 @@ func (c *Client) GetRepoBranches(ctx context.Context, req gitserver.GetBranchesR } return branches, err } + +func (c *Client) GetRepoBranchByName(ctx context.Context, req gitserver.GetBranchReq) (*types.Branch, error) { + var branch types.Branch + namespace := common.WithPrefix(req.Namespace, repoPrefixByType(req.RepoType)) + giteaBranch, _, err := c.giteaClient.GetRepoBranch( + namespace, + req.Name, + req.Ref, + ) + if err != nil { + return nil, err + } + + if giteaBranch == nil { + return nil, nil + } + + branch.Name = giteaBranch.Name + branch.Message = giteaBranch.Commit.Message + branch.Commit = types.RepoBranchCommit{ + ID: giteaBranch.Commit.ID, + } + + return &branch, err +} + +func (c *Client) DeleteRepoBranch(ctx context.Context, req gitserver.DeleteBranchReq) error { + return nil +} diff --git a/builder/git/gitserver/interface.go b/builder/git/gitserver/interface.go index 1d10eaf7..eff741f9 100644 --- a/builder/git/gitserver/interface.go +++ b/builder/git/gitserver/interface.go @@ -26,6 +26,8 @@ type GitServer interface { UpdateRepo(ctx context.Context, req UpdateRepoReq) (*CreateRepoResp, error) DeleteRepo(ctx context.Context, req DeleteRepoReq) error GetRepoBranches(ctx context.Context, req GetBranchesReq) ([]types.Branch, error) + GetRepoBranchByName(ctx context.Context, req GetBranchReq) (*types.Branch, error) + DeleteRepoBranch(ctx context.Context, req DeleteBranchReq) error GetRepoCommits(ctx context.Context, req GetRepoCommitsReq) ([]types.Commit, *types.RepoPageOpts, error) GetRepoLastCommit(ctx context.Context, req GetRepoLastCommitReq) (*types.Commit, error) GetSingleCommit(ctx context.Context, req GetRepoLastCommitReq) (*types.CommitResponse, error) diff --git a/builder/git/gitserver/types.go b/builder/git/gitserver/types.go index 23bd47de..403eb730 100644 --- a/builder/git/gitserver/types.go +++ b/builder/git/gitserver/types.go @@ -94,6 +94,22 @@ type GetBranchesReq struct { RepoType types.RepositoryType `json:"repo_type"` } +type GetBranchReq struct { + Namespace string `json:"namespace"` + Name string `json:"name"` + Ref string `json:"ref"` + RepoType types.RepositoryType `json:"repo_type"` +} + +type DeleteBranchReq struct { + Namespace string `json:"namespace"` + Name string `json:"name"` + Ref string `json:"ref"` + RepoType types.RepositoryType `json:"repo_type"` + Username string `json:"username"` + Email string `json:"email"` +} + type GetRepoCommitsReq struct { Namespace string `json:"namespace"` Name string `json:"name"` diff --git a/builder/parquet/duckdb_reader.go b/builder/parquet/duckdb_reader.go index 3705f198..cbf7be73 100644 --- a/builder/parquet/duckdb_reader.go +++ b/builder/parquet/duckdb_reader.go @@ -1,18 +1,22 @@ package parquet import ( + "context" "database/sql" "fmt" - "log" "log/slog" + "strings" + "github.com/XSAM/otelsql" _ "github.com/marcboeker/go-duckdb" "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" ) type Reader interface { - RowCount(objName string) (count int, err error) - TopN(objName string, count int) (columns []string, rows [][]interface{}, err error) + RowCount(ctx context.Context, objNames []string, req types.QueryReq, lfs bool) (count int, err error) + TopN(ctx context.Context, objName string, count int) (columns []string, columnsType []string, rows [][]interface{}, err error) + FetchRows(ctx context.Context, objNames []string, req types.QueryReq, lfs bool) (columns []string, columnsType []string, rows [][]interface{}, err error) } type duckdbReader struct { @@ -20,36 +24,47 @@ type duckdbReader struct { bucket string } -// NewS3Reader create a new reader to read from s3 compatible object storage service -func NewS3Reader(cfg *config.Config) (Reader, error) { +func NewS3Reader(ctx context.Context, cfg *config.Config) (Reader, error) { + urlStyle := "vhost" + if cfg.S3.BucketLookup == "path" { + urlStyle = "path" + } s3SetupSql := fmt.Sprintf(` INSTALL httpfs; LOAD httpfs; + INSTALL json; + LOAD json; SET s3_region = '%s'; SET s3_endpoint = '%s'; - SET s3_url_style = 'vhost'; SET s3_access_key_id = '%s'; SET s3_secret_access_key = '%s'; - `, cfg.S3.Region, cfg.S3.Endpoint, cfg.S3.AccessKeyID, cfg.S3.AccessKeySecret) - db, err := sql.Open("duckdb", "") + SET s3_use_ssl = %t; + SET s3_url_style = '%s'; + `, cfg.S3.Region, cfg.S3.Endpoint, cfg.S3.AccessKeyID, cfg.S3.AccessKeySecret, cfg.S3.EnableSSL, urlStyle) + db, err := otelsql.Open("duckdb", "") if err != nil { return nil, fmt.Errorf("failed to connect to duckdb, cause:%w", err) } - slog.Debug("setup duckdb", slog.String("sql", s3SetupSql)) - _, err = db.Exec(s3SetupSql) + err = otelsql.RegisterDBStatsMetrics(db) + if err != nil { + return nil, fmt.Errorf("failed to report db stats metrics, cause:%w", err) + } + _, err = db.ExecContext(ctx, s3SetupSql) if err != nil { return nil, fmt.Errorf("failed to setup s3 for duckdb, cause:%w", err) } - slog.Info("setup duckdb succeeded") - + slog.Debug("setup duckdb succeeded") return &duckdbReader{db: db, bucket: cfg.S3.Bucket}, nil } -// RowCount returns the total number of rows in a parquet file in S3 bucket. -func (r *duckdbReader) RowCount(objName string) (int, error) { - selectCount := fmt.Sprintf("select count(*) from read_parquet('s3://%s/%s');", r.bucket, objName) - fmt.Println(selectCount) - row := r.db.QueryRow(selectCount) +func (r *duckdbReader) RowCount(ctx context.Context, objNames []string, req types.QueryReq, lfs bool) (int, error) { + multiFiles := r.genSelectMultiObjStr(objNames, lfs) + whereStr := "" + if len(req.Where) > 0 { + whereStr = fmt.Sprintf("WHERE %s", req.Where) + } + selectCount := fmt.Sprintf("SELECT count(*) FROM read_parquet(%s, union_by_name = true) %s;", multiFiles, whereStr) + row := r.db.QueryRowContext(ctx, selectCount) if row.Err() != nil { return 0, fmt.Errorf("failed to get row count: %w", row.Err()) } @@ -58,21 +73,51 @@ func (r *duckdbReader) RowCount(objName string) (int, error) { return count, err } -// TopN returns the top N rows of a parquet file in S3 bucket. -func (r *duckdbReader) TopN(objName string, count int) ([]string, [][]interface{}, error) { - topN := fmt.Sprintf("select * from read_parquet('s3://%s/%s') limit %d;", r.bucket, objName, count) +func (r *duckdbReader) TopN(ctx context.Context, objName string, count int) ([]string, []string, [][]interface{}, error) { + topN := fmt.Sprintf("SELECT * FROM read_parquet('s3://%s/%s') limit %d;", r.bucket, objName, count) slog.Debug("query topN", slog.String("query", topN)) - rows, err := r.db.Query(topN) + rows, err := r.db.QueryContext(ctx, topN) + if err != nil { + return nil, nil, nil, fmt.Errorf("failed to execute query,cause:%w", err) + } + defer rows.Close() + return r.getColumnsAndValues(rows) +} + +func (r *duckdbReader) FetchRows(ctx context.Context, objNames []string, req types.QueryReq, lfs bool) ([]string, []string, [][]interface{}, error) { + multiFiles := r.genSelectMultiObjStr(objNames, lfs) + offset := (req.PageIndex - 1) * req.PageSize + whereStr := "" + if len(req.Where) > 0 { + whereStr = fmt.Sprintf("WHERE %s", req.Where) + } + orderbyStr := "" + if len(strings.Trim(req.Orderby, " ")) > 0 { + orderbyStr = "order by " + req.Orderby + } + querySql := fmt.Sprintf("SELECT * FROM read_parquet(%s, union_by_name = true) %s %s limit %d offset %d;", multiFiles, whereStr, orderbyStr, req.PageSize, offset) + rows, err := r.db.QueryContext(ctx, querySql) if err != nil { - return nil, nil, fmt.Errorf("failed to execute query,cause:%w", err) + return nil, nil, nil, fmt.Errorf("failed to execute fetch rows, cause:%w", err) } defer rows.Close() + return r.getColumnsAndValues(rows) +} - columns, err := rows.Columns() +func (r *duckdbReader) getColumnsAndValues(rows *sql.Rows) ([]string, []string, [][]interface{}, error) { + colsType, err := rows.ColumnTypes() if err != nil { - return nil, nil, fmt.Errorf("failed to get columns,cause:%w", err) + return nil, nil, nil, fmt.Errorf("failed to get duckdb query columns type, cause:%w", err) + } + + var ( + columns []string + columnsType []string + ) + for _, columnType := range colsType { + columns = append(columns, columnType.Name()) + columnsType = append(columnsType, columnType.ScanType().Name()) } - slog.Debug("get parquet columns", slog.Any("columns", columns)) values := make([][]interface{}, 0) for rows.Next() { @@ -81,12 +126,31 @@ func (r *duckdbReader) TopN(objName string, count int) ([]string, [][]interface{ for i := range fields { pointers[i] = &fields[i] } - // Scan values into the slice if err := rows.Scan(pointers...); err != nil { - log.Fatal(err) + return nil, nil, nil, fmt.Errorf("failed to scan rows, cause:%w", err) + // log.Fatal(err) } values = append(values, fields) } - return columns, values, nil + return columns, columnsType, values, nil +} + +func (r *duckdbReader) genSelectMultiObjStr(objNames []string, lfs bool) string { + var parquetFiles []string + for _, objName := range objNames { + if lfs { + parquetFiles = append(parquetFiles, fmt.Sprintf("'s3://%s/%s'", r.bucket, objName)) + } else { + parquetFiles = append(parquetFiles, fmt.Sprintf("'%s'", objName)) + } + } + fileStr := "" + if len(objNames) > 1 { + fileStr = "[" + strings.Join(parquetFiles, ",") + "]" + } else { + fileStr = parquetFiles[0] + } + + return fileStr } diff --git a/builder/parquet/duckdb_writer.go b/builder/parquet/duckdb_writer.go new file mode 100644 index 00000000..0eeb6137 --- /dev/null +++ b/builder/parquet/duckdb_writer.go @@ -0,0 +1,80 @@ +package parquet + +import ( + "context" + "database/sql" + "fmt" + "log/slog" + "strings" + + "github.com/XSAM/otelsql" + _ "github.com/marcboeker/go-duckdb" + "opencsg.com/csghub-server/common/config" +) + +type Writer interface { + ConvertToParquet(ctx context.Context, method string, objNames []string, thread int, path string) error +} + +type duckdbWriter struct { + db *sql.DB + bucket string +} + +func NewS3Writer(ctx context.Context, cfg *config.Config) (Writer, error) { + urlStyle := "vhost" + if cfg.S3.BucketLookup == "path" { + urlStyle = "path" + } + s3SetupSql := fmt.Sprintf(` + INSTALL httpfs; + LOAD httpfs; + INSTALL json; + LOAD json; + SET s3_region = '%s'; + SET s3_endpoint = '%s'; + SET s3_access_key_id = '%s'; + SET s3_secret_access_key = '%s'; + SET s3_use_ssl = %t; + SET s3_url_style = '%s'; + `, cfg.S3.Region, cfg.S3.Endpoint, cfg.S3.AccessKeyID, cfg.S3.AccessKeySecret, cfg.S3.EnableSSL, urlStyle) + db, err := otelsql.Open("duckdb", "") + if err != nil { + return nil, fmt.Errorf("failed to connect to duckdb, cause:%w", err) + } + err = otelsql.RegisterDBStatsMetrics(db) + if err != nil { + return nil, fmt.Errorf("failed to report db stats metrics, cause:%w", err) + } + _, err = db.ExecContext(ctx, s3SetupSql) + if err != nil { + return nil, fmt.Errorf("failed to setup s3 for duckdb, cause:%w", err) + } + slog.Debug("setup duckdb succeeded") + return &duckdbWriter{db: db, bucket: cfg.S3.Bucket}, nil +} + +func (r *duckdbWriter) ConvertToParquet(ctx context.Context, method string, objNames []string, thread int, path string) error { + fileStr := "" + if len(objNames) > 1 { + fileStr = "[" + strings.Join(objNames, ",") + "]" + } else { + fileStr = objNames[0] + } + exportCMD := fmt.Sprintf(` + SET preserve_insertion_order=false; + SET threads = %d; + COPY (SELECT * FROM %s(%s)) TO '%s' ( + FORMAT 'PARQUET', + CODEC 'Snappy', + PER_THREAD_OUTPUT TRUE, + FILENAME_PATTERN '{i}' + ); + `, thread, method, fileStr, path) + slog.Debug("export parquet sql", slog.String("sql", exportCMD)) + _, err := r.db.ExecContext(ctx, exportCMD) + if err != nil { + return fmt.Errorf("failed to export parquet: %w", err) + } + return nil +} diff --git a/builder/store/database/dataviewer.go b/builder/store/database/dataviewer.go new file mode 100644 index 00000000..d769b02c --- /dev/null +++ b/builder/store/database/dataviewer.go @@ -0,0 +1,143 @@ +package database + +import ( + "context" + "database/sql" + "errors" + "fmt" + "time" + + "github.com/uptrace/bun" + "opencsg.com/csghub-server/common/types" +) + +type Dataviewer struct { + ID int64 `bun:",pk,autoincrement" json:"id"` + RepoID int64 `bun:",notnull" json:"repo_id"` + RepoPath string `bun:",notnull" json:"repo_path"` + RepoBranch string `bun:",notnull" json:"repo_branch"` + WorkflowID string `bun:",notnull" json:"workflow_id"` + times + DataviewerJob *DataviewerJob `bun:"rel:has-one,join:workflow_id=workflow_id" json:"dataviewer_job"` +} + +type DataviewerJob struct { + ID int64 `bun:",pk,autoincrement" json:"id"` + RepoID int64 `bun:",notnull" json:"repo_id"` + WorkflowID string `bun:",notnull" json:"workflow_id"` + Status int `bun:",notnull" json:"status"` + AutoCard bool `bun:",notnull" json:"auto_card"` + CardData string `bun:",nullzero" json:"card_data"` + CardMD5 string `bun:",nullzero" json:"card_md5"` + RunID string `bun:",nullzero" json:"run_id"` + Logs string `bun:",nullzero" json:"logs"` + StartTime time.Time `bun:",nullzero" json:"start_time"` + EndTime time.Time `bun:",nullzero" json:"end_time"` + times +} + +type DataviewerStore interface { + GetViewerByRepoID(ctx context.Context, repoID int64) (*Dataviewer, error) + CreateViewer(ctx context.Context, viewer Dataviewer) error + CreateJob(ctx context.Context, job DataviewerJob) error + UpdateViewer(ctx context.Context, viewer Dataviewer) (*Dataviewer, error) + GetJob(ctx context.Context, workflowID string) (*DataviewerJob, error) + UpdateJob(ctx context.Context, job DataviewerJob) (*DataviewerJob, error) + GetRunningJobsByRepoID(ctx context.Context, repoID int64) ([]DataviewerJob, error) +} + +type dataviewerStoreImpl struct { + db *DB +} + +func NewDataviewerStore() DataviewerStore { + return &dataviewerStoreImpl{db: defaultDB} +} + +func NewDataViewerStoreWithDB(db *DB) DataviewerStore { + return &dataviewerStoreImpl{db: db} +} + +func (s *dataviewerStoreImpl) GetViewerByRepoID(ctx context.Context, repoID int64) (*Dataviewer, error) { + var dataViewer Dataviewer + err := s.db.Operator.Core.NewSelect().Model(&dataViewer).Relation("DataviewerJob").Where("dataviewer.repo_id = ?", repoID).Scan(ctx) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } + return nil, fmt.Errorf("select viewer by repo_id %d error: %w", repoID, err) + } + return &dataViewer, nil +} + +func (s *dataviewerStoreImpl) CreateViewer(ctx context.Context, viewer Dataviewer) error { + err := s.db.Operator.Core.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { + + res, err := tx.NewInsert().Model(&viewer).Exec(ctx, &viewer) + if err := assertAffectedOneRow(res, err); err != nil { + return fmt.Errorf("create dataviewer repo_id %d, workflow_id %s error: %w", viewer.RepoID, viewer.WorkflowID, err) + } + + job := DataviewerJob{ + RepoID: viewer.RepoID, + WorkflowID: viewer.WorkflowID, + Status: types.WorkflowPending, + AutoCard: true, + } + + res, err = tx.NewInsert().Model(&job).Exec(ctx, &job) + if err := assertAffectedOneRow(res, err); err != nil { + return fmt.Errorf("create dataviewer job repo_id %d, workflow_id %s error: %w", viewer.RepoID, viewer.WorkflowID, err) + } + + return nil + }) + + return err +} + +func (s *dataviewerStoreImpl) CreateJob(ctx context.Context, job DataviewerJob) error { + res, err := s.db.Operator.Core.NewInsert().Model(&job).Exec(ctx, &job) + if err := assertAffectedOneRow(res, err); err != nil { + return fmt.Errorf("create dataviewer job repo_id %d, workflow_id %s error: %w", job.RepoID, job.WorkflowID, err) + } + return nil +} + +func (s *dataviewerStoreImpl) UpdateViewer(ctx context.Context, input Dataviewer) (*Dataviewer, error) { + _, err := s.db.Operator.Core.NewUpdate().Model(&input).WherePK().Exec(ctx) + if err != nil { + return nil, fmt.Errorf("update viewer by id %d error: %w", input.ID, err) + } + return &input, nil +} + +func (s *dataviewerStoreImpl) GetJob(ctx context.Context, workflowID string) (*DataviewerJob, error) { + var job DataviewerJob + err := s.db.Operator.Core.NewSelect().Model(&job).Where("workflow_id = ?", workflowID).Scan(ctx) + if err != nil { + return nil, fmt.Errorf("select viewer job by workflow_id %s error: %w", workflowID, err) + } + return &job, nil +} + +func (s *dataviewerStoreImpl) UpdateJob(ctx context.Context, job DataviewerJob) (*DataviewerJob, error) { + res, err := s.db.Operator.Core.NewUpdate().Model(&job).WherePK().Exec(ctx) + if err := assertAffectedOneRow(res, err); err != nil { + return nil, fmt.Errorf("update viewer job workflow_id %s error: %w", job.WorkflowID, err) + } + + return &job, nil +} + +func (s *dataviewerStoreImpl) GetRunningJobsByRepoID(ctx context.Context, repoID int64) ([]DataviewerJob, error) { + var jobs []DataviewerJob + _, err := s.db.Operator.Core.NewSelect().Model(&jobs). + Where("repo_id = ?", repoID). + Where("status >= 0 and status <=1"). + Exec(ctx, &jobs) + if err != nil { + return nil, fmt.Errorf("select running viewer jobs by repo_id %d, error: %w", repoID, err) + } + return jobs, nil +} diff --git a/builder/store/database/dataviewer_test.go b/builder/store/database/dataviewer_test.go new file mode 100644 index 00000000..2dbad3a4 --- /dev/null +++ b/builder/store/database/dataviewer_test.go @@ -0,0 +1,91 @@ +package database_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/common/tests" +) + +func TestDataviewerStore_CreateAndGetViewerByRepoIDAndUpdate(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + viewer := database.Dataviewer{ + RepoID: 1, + RepoPath: "test/path", + RepoBranch: "test-branch", + WorkflowID: "test-workflow", + } + + dv := database.NewDataViewerStoreWithDB(db) + err := dv.CreateViewer(ctx, viewer) + require.Nil(t, err) + + res, err := dv.GetViewerByRepoID(ctx, int64(1)) + require.Nil(t, err) + require.Equal(t, res.RepoID, int64(1)) + require.Equal(t, res.WorkflowID, "test-workflow") + + viewer.WorkflowID = "updated-workflow" + res, err = dv.UpdateViewer(ctx, viewer) + require.Nil(t, err) + require.Equal(t, res.WorkflowID, "updated-workflow") +} + +func TestDataviewerStore_CreateAndGetAndUpdateJob(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + job := database.DataviewerJob{ + RepoID: 1, + Status: 0, + WorkflowID: "test-workflow", + } + dv := database.NewDataViewerStoreWithDB(db) + err := dv.CreateJob(ctx, job) + require.Nil(t, err) + + res, err := dv.GetJob(ctx, "test-workflow") + require.Nil(t, err) + require.Equal(t, res.WorkflowID, "test-workflow") + + job.ID = res.ID + job.CardData = "updated-data" + res, err = dv.UpdateJob(ctx, job) + require.Nil(t, err) + require.Equal(t, res.CardData, "updated-data") +} + +func TestDataviewerStore_GetRunningJobsByRepoID(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + job1 := database.DataviewerJob{ + RepoID: 1, + Status: 0, + WorkflowID: "test-workflow1", + } + + job2 := database.DataviewerJob{ + RepoID: 1, + Status: 1, + WorkflowID: "test-workflow2", + } + + dv := database.NewDataViewerStoreWithDB(db) + err := dv.CreateJob(ctx, job1) + require.Nil(t, err) + + err = dv.CreateJob(ctx, job2) + require.Nil(t, err) + + jobs, err := dv.GetRunningJobsByRepoID(ctx, int64(1)) + require.Nil(t, err) + require.Equal(t, len(jobs), 2) +} diff --git a/builder/store/database/migrations/20250115132744_create_table_dataviewer.go b/builder/store/database/migrations/20250115132744_create_table_dataviewer.go new file mode 100644 index 00000000..5866aea4 --- /dev/null +++ b/builder/store/database/migrations/20250115132744_create_table_dataviewer.go @@ -0,0 +1,82 @@ +package migrations + +import ( + "context" + "fmt" + "time" + + "github.com/uptrace/bun" +) + +type Dataviewer struct { + ID int64 `bun:",pk,autoincrement" json:"id"` + RepoID int64 `bun:",notnull" json:"repo_id"` + RepoPath string `bun:",notnull" json:"repo_path"` + RepoBranch string `bun:",notnull" json:"repo_branch"` + WorkflowID string `bun:",notnull" json:"workflow_id"` + times +} + +type DataviewerJob struct { + ID int64 `bun:",pk,autoincrement" json:"id"` + RepoID int64 `bun:",notnull" json:"repo_id"` + WorkflowID string `bun:",notnull" json:"workflow_id"` + Status int `bun:",notnull" json:"status"` + AutoCard bool `bun:",notnull" json:"auto_card"` + CardData string `bun:",nullzero" json:"card_data"` + CardMD5 string `bun:",nullzero" json:"card_md5"` + RunID string `bun:",nullzero" json:"run_id"` + Logs string `bun:",nullzero" json:"logs"` + StartTime time.Time `bun:",nullzero" json:"start_time"` + EndTime time.Time `bun:",nullzero" json:"end_time"` + times +} + +func init() { + Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error { + err := createTables(ctx, db, Dataviewer{}) + if err != nil { + return fmt.Errorf("create table dataviewers fail: %w", err) + } + _, err = db.NewCreateIndex(). + Model((*Dataviewer)(nil)). + Index("idx_unique_dataviewer_repoid"). + Column("repo_id"). + Unique(). + IfNotExists(). + Exec(ctx) + if err != nil { + return fmt.Errorf("create index idx_unique_dataviewer_repoid fail: %w", err) + } + + err = createTables(ctx, db, DataviewerJob{}) + if err != nil { + return fmt.Errorf("create table dataviewer_jobs fail: %w", err) + } + + _, err = db.NewCreateIndex(). + Model((*DataviewerJob)(nil)). + Index("idx_unique_dataviewer_job_workflowid"). + Column("workflow_id"). + Unique(). + IfNotExists(). + Exec(ctx) + if err != nil { + return fmt.Errorf("create index idx_unique_dataviewer_job_workflowid fail: %w", err) + } + + _, err = db.NewCreateIndex(). + Model((*DataviewerJob)(nil)). + Index("idx_dataviewer_job_repoid_status_workflow_updatetime"). + Column("repo_id", "status", "updated_at"). + IfNotExists(). + Exec(ctx) + if err != nil { + return fmt.Errorf("create index idx_dataviewer_job_repoid_status_workflow_updatetime fail: %w", err) + } + return err + + }, func(ctx context.Context, db *bun.DB) error { + return dropTables(ctx, db, Dataviewer{}, DataviewerJob{}) + }) +} diff --git a/builder/temporal/temporal.go b/builder/temporal/temporal.go index b1c4afa0..1a0e886d 100644 --- a/builder/temporal/temporal.go +++ b/builder/temporal/temporal.go @@ -2,8 +2,10 @@ package temporal import ( "context" + "log/slog" "go.temporal.io/sdk/client" + "go.temporal.io/sdk/log" "go.temporal.io/sdk/worker" ) @@ -33,6 +35,20 @@ func NewClient(temporalClient client.Client) (*clientImpl, error) { return c, nil } +func NewClientByHostPort(hostPort string) (*clientImpl, error) { + logger := log.NewStructuredLogger(slog.Default()) + temporalClient, err := client.Dial(client.Options{ + HostPort: hostPort, + Logger: logger, + }) + if err != nil { + return nil, err + } + c := _client.(*clientImpl) + c.Client = temporalClient + return c, nil +} + func (c *clientImpl) NewWorker(queue string, options worker.Options) worker.Registry { w := worker.New(c.Client, queue, options) c.workers = append(c.workers, w) diff --git a/cmd/csghub-server/cmd/dataviewer/dataviewer.go b/cmd/csghub-server/cmd/dataviewer/dataviewer.go new file mode 100644 index 00000000..2fca3945 --- /dev/null +++ b/cmd/csghub-server/cmd/dataviewer/dataviewer.go @@ -0,0 +1,18 @@ +package dataviewer + +import ( + "github.com/spf13/cobra" +) + +func init() { + // add subcommands here + Cmd.AddCommand(launchCmd) +} + +var Cmd = &cobra.Command{ + Use: "dataviewer", + Short: "entry point for data viewer", + Run: func(cmd *cobra.Command, args []string) { + _ = cmd.Help() + }, +} diff --git a/cmd/csghub-server/cmd/dataviewer/launch.go b/cmd/csghub-server/cmd/dataviewer/launch.go new file mode 100644 index 00000000..3fd6e1b6 --- /dev/null +++ b/cmd/csghub-server/cmd/dataviewer/launch.go @@ -0,0 +1,73 @@ +package dataviewer + +import ( + "context" + "fmt" + "log/slog" + + "github.com/spf13/cobra" + "opencsg.com/csghub-server/api/httpbase" + "opencsg.com/csghub-server/builder/instrumentation" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/builder/temporal" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/dataviewer/router" +) + +var launchCmd = &cobra.Command{ + Use: "launch", + Short: "Launch data viewer server", + Example: serverExample(), + RunE: func(cmd *cobra.Command, args []string) (err error) { + cfg, err := config.LoadConfig() + if err != nil { + return err + } + slog.Debug("config", slog.Any("data", cfg)) + + if len(cfg.APIToken) < 128 { + return fmt.Errorf("API token length is less than 128, please check") + } + dbConfig := database.DBConfig{ + Dialect: database.DatabaseDialect(cfg.Database.Driver), + DSN: cfg.Database.DSN, + } + database.InitDB(dbConfig) + + tc, err := temporal.NewClientByHostPort(cfg.WorkFLow.Endpoint) + if err != nil { + return fmt.Errorf("build workflow client, error: %w", err) + } + + stopOtel, err := instrumentation.SetupOTelSDK(context.Background(), cfg, "dataviewer-api") + if err != nil { + panic(err) + } + + r, err := router.NewDataViewerRouter(cfg, tc) + if err != nil { + return fmt.Errorf("failed to init dataviewer router: %w", err) + } + + slog.Info("dataviewer http server is running", slog.Any("port", cfg.DataViewer.Port)) + server := httpbase.NewGracefulServer( + httpbase.GraceServerOpt{ + Port: cfg.DataViewer.Port, + }, + r, + ) + server.Run() + _ = stopOtel(context.Background()) + + temporal.Stop() + + return nil + }, +} + +func serverExample() string { + return ` +# for development +csghub-server dataviewer launch +` +} diff --git a/cmd/csghub-server/cmd/root.go b/cmd/csghub-server/cmd/root.go index 93052d05..9b6d3525 100644 --- a/cmd/csghub-server/cmd/root.go +++ b/cmd/csghub-server/cmd/root.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/cobra" "opencsg.com/csghub-server/cmd/csghub-server/cmd/accounting" "opencsg.com/csghub-server/cmd/csghub-server/cmd/cron" + "opencsg.com/csghub-server/cmd/csghub-server/cmd/dataviewer" "opencsg.com/csghub-server/cmd/csghub-server/cmd/deploy" "opencsg.com/csghub-server/cmd/csghub-server/cmd/git" "opencsg.com/csghub-server/cmd/csghub-server/cmd/logscan" @@ -64,7 +65,11 @@ func init() { user.Cmd, git.Cmd, moderation.Cmd, + dataviewer.Cmd, ) + + addCommands() + } func setupLog(lvl, format string) { diff --git a/cmd/csghub-server/cmd/root_ce.go b/cmd/csghub-server/cmd/root_ce.go new file mode 100644 index 00000000..996c99b3 --- /dev/null +++ b/cmd/csghub-server/cmd/root_ce.go @@ -0,0 +1,6 @@ +//go:build !ee && !saas + +package cmd + +func addCommands() { +} diff --git a/common/config/config.go b/common/config/config.go index f975b012..c6c1d4ec 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -94,6 +94,7 @@ type Config struct { InternalEndpoint string `env:"STARHUB_SERVER_S3_INTERNAL_ENDPOINT, default="` Bucket string `env:"STARHUB_SERVER_S3_BUCKET, default=opencsg-test"` EnableSSL bool `env:"STARHUB_SERVER_S3_ENABLE_SSL, default=false"` + BucketLookup string `env:"STARHUB_SERVER_S3_BUCKET_LOOKUP, default=auto"` } SensitiveCheck struct { @@ -208,7 +209,9 @@ type Config struct { } WorkFLow struct { - Endpoint string `env:"OPENCSG_WORKFLOW_SERVER_ENDPOINT, default=localhost:7233"` + Endpoint string `env:"OPENCSG_WORKFLOW_SERVER_ENDPOINT, default=localhost:7233"` + ExecutionTimeout int64 `env:"OPENCSG_WORKFLOW_EXECUTION_TIMEOUT, default=43200"` + TaskTimeout int64 `env:"OPENCSG_WORKFLOW_TASK_TIMEOUT, default=43200"` } Argo struct { @@ -228,6 +231,22 @@ type Config struct { CalcRecomScoreCronExpression string `env:"STARHUB_SERVER_CRON_JOB_CLAC_RECOM_SCORE_CRON_EXPRESSION, default=0 1 * * *"` } + DataViewer struct { + Host string `env:"OPENCSG_DATAVIEWER_SERVER_HOST, default=http://localhost"` + Port int `env:"OPENCSG_DATAVIEWER_SERVER_PORT, default=8093"` + MaxConcurrentActivityExecutionSize int `env:"OPENCSG_DATAVIEWER_MAX_CONCURRENT_ACTIVITY_EXECUTION_SIZE, default=5"` + MaxConcurrentLocalActivityExecutionSize int `env:"OPENCSG_DATAVIEWER_MAX_CONCURRENT_LOCAL_ACTIVITY_EXECUTION_SIZE, default=10"` + MaxConcurrentWorkflowTaskExecutionSize int `env:"OPENCSG_DATAVIEWER_MAX_CONCURRENT_WORKFLOW_TASK_EXECUTION_SIZE, default=2"` + ActivityStartToCloseTimeout int `env:"OPENCSG_DATAVIEWER_ACTIVITY_START_TO_CLOSE_TIMEOUT, default=7200"` + ActivityMaximumAttempts int32 `env:"OPENCSG_DATAVIEWER_ACTIVITY_MAXIMUM_ATTEMPTS, default=2"` + CacheDir string `env:"OPENCSG_DATAVIEWER_CACHE_DIR, default=/tmp/opencsg"` + DownloadLfsFile bool `env:"OPENCSG_DATAVIEWER_DOWNLOAD_LFS_FILE, default=true"` + ThreadNumOfExport int `env:"OPENCSG_DATAVIEWER_THREAD_NUM_OF_EXPORT, default=4"` + MaxFileSize int64 `env:"OPENCSG_DATAVIEWER_MAX_FILE_SIZE, default=104857600"` // 100 MB + MaxConcurrentSessionExecutionSize int `env:"OPENCSG_DATAVIEWER_MAX_CONCURRENT_SESSION_EXECUTION_SIZE, default=1"` + SessionExecutionTimeout int `env:"OPENCSG_DATAVIEWER_SESSION_EXECUTION_TIMEOUT, default=240"` // 240 minutes + } + Proxy struct { Enable bool `env:"STARHUB_SERVER_PROXY_ENABLE, default=false"` URL string `env:"STARHUB_SERVER_PROXY_URL, default="` diff --git a/common/tests/stores.go b/common/tests/stores.go index 507a7157..b5427b9e 100644 --- a/common/tests/stores.go +++ b/common/tests/stores.go @@ -48,6 +48,7 @@ type MockStores struct { Telemetry database.TelemetryStore RepoFile database.RepoFileStore Event database.EventStore + ViewerStore database.DataviewerStore } func NewMockStores(t interface { @@ -96,9 +97,14 @@ func NewMockStores(t interface { RepoFile: mockdb.NewMockRepoFileStore(t), Event: mockdb.NewMockEventStore(t), TagRule: mockdb.NewMockTagRuleStore(t), + ViewerStore: mockdb.NewMockDataviewerStore(t), } } +func (s *MockStores) ViewerMock() *mockdb.MockDataviewerStore { + return s.ViewerStore.(*mockdb.MockDataviewerStore) +} + func (s *MockStores) UserMock() *mockdb.MockUserStore { return s.User.(*mockdb.MockUserStore) } diff --git a/common/types/dataset.go b/common/types/dataset.go index 14462801..a81688e6 100644 --- a/common/types/dataset.go +++ b/common/types/dataset.go @@ -4,6 +4,8 @@ import ( "time" ) +var OssFileExpire = 259200 * time.Second + type DatasetTagCommit struct { ID string `json:"id"` } @@ -44,3 +46,79 @@ type Dataset struct { SensitiveCheckStatus string `json:"sensitive_check_status"` MirrorLastUpdatedAt time.Time `json:"mirror_last_updated_at"` } + +type DataViewerReq struct { + Config string `json:"config"` + Split string `json:"split"` + Search string `json:"search"` + Where string `json:"where"` + Orderby string `json:"orderby"` +} + +type QueryReq struct { + PageSize int `json:"page_size"` + PageIndex int `json:"page_index"` + Search string `json:"search"` + Where string `json:"where"` + Orderby string `json:"orderby"` +} + +var GitattributesFileName = ".gitattributes" + +const DatasetGitattributesContent = `*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.lz4 filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +# Audio files - uncompressed +*.pcm filter=lfs diff=lfs merge=lfs -text +*.sam filter=lfs diff=lfs merge=lfs -text +*.raw filter=lfs diff=lfs merge=lfs -text +# Audio files - compressed +*.aac filter=lfs diff=lfs merge=lfs -text +*.flac filter=lfs diff=lfs merge=lfs -text +*.mp3 filter=lfs diff=lfs merge=lfs -text +*.ogg filter=lfs diff=lfs merge=lfs -text +*.wav filter=lfs diff=lfs merge=lfs -text +# Image files - uncompressed +*.bmp filter=lfs diff=lfs merge=lfs -text +*.gif filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.tiff filter=lfs diff=lfs merge=lfs -text +# Image files - compressed +*.jpg filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.webp filter=lfs diff=lfs merge=lfs -text + +` diff --git a/common/types/dataviewer.go b/common/types/dataviewer.go new file mode 100644 index 00000000..baa61b73 --- /dev/null +++ b/common/types/dataviewer.go @@ -0,0 +1,32 @@ +package types + +const ( + WorkflowPending = iota + WorkflowRunning = 1 + WorkflowDone = 2 + WorkflowFailed = 3 +) + +const ( + WorkflowMsgPending = "Pending" + WorkflowMsgRunning = "The dataset viewer should be available soon." + WorkflowMsgDone = "Done" +) + +type UpdateViewerReq struct { + Namespace string `json:"namespace"` + Name string `json:"name"` + Branch string `json:"branch"` + CurrentUser string `json:"current_user"` + RepoType RepositoryType `json:"repo_type"` + RepoID int64 `json:"repo_id"` +} + +type WorkFlowInfo struct { + Namespace string `json:"namespace"` + Name string `json:"name"` + Branch string `json:"branch"` + RepoType RepositoryType `json:"repo_type"` + WorkFlowID string `json:"workflow_id"` + WorkFlowRunID string `json:"workflow_run_id"` +} diff --git a/common/types/git_server_type.go b/common/types/git_server_type.go index fa3e28f5..d3eb3eb3 100644 --- a/common/types/git_server_type.go +++ b/common/types/git_server_type.go @@ -3,4 +3,5 @@ package types const ( GitServerTypeGitaly string = "gitaly" GitServerTypeGitea string = "gitea" + NoCommitID string = "0000000000000000000000000000000000000000" ) diff --git a/common/types/repo.go b/common/types/repo.go index 68498a97..73147407 100644 --- a/common/types/repo.go +++ b/common/types/repo.go @@ -4,6 +4,8 @@ import ( "time" ) +var REPOCARD_FILENAME = "README.md" + type RepositoryType string type RepositorySource string type RepositorySyncStatus string diff --git a/component/code.go b/component/code.go index 18792ee3..3f9f0558 100644 --- a/component/code.go +++ b/component/code.go @@ -102,7 +102,7 @@ func (c *codeComponentImpl) Create(ctx context.Context, req *types.CreateCodeReq NewBranch: req.DefaultBranch, Namespace: req.Namespace, Name: req.Name, - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.CodeRepo)) if err != nil { return nil, fmt.Errorf("failed to create README.md file, cause: %w", err) diff --git a/component/code_test.go b/component/code_test.go index 56a9530e..3f4fb69d 100644 --- a/component/code_test.go +++ b/component/code_test.go @@ -51,7 +51,7 @@ func TestCodeComponent_Create(t *testing.T) { NewBranch: "main", Namespace: "ns", Name: "n", - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.CodeRepo)).Return(nil) cc.mocks.gitServer.EXPECT().CreateRepoFile(buildCreateFileReq(&types.CreateFileParams{ Username: "user", diff --git a/component/dataset.go b/component/dataset.go index 8c19ce02..a4554d60 100644 --- a/component/dataset.go +++ b/component/dataset.go @@ -17,68 +17,9 @@ import ( "opencsg.com/csghub-server/common/utils/common" ) -const datasetGitattributesContent = `*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text -*.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ckpt filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.lz4 filter=lfs diff=lfs merge=lfs -text -*.mlmodel filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.npy filter=lfs diff=lfs merge=lfs -text -*.npz filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pickle filter=lfs diff=lfs merge=lfs -text -*.pkl filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.safetensors filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.zst filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text -# Audio files - uncompressed -*.pcm filter=lfs diff=lfs merge=lfs -text -*.sam filter=lfs diff=lfs merge=lfs -text -*.raw filter=lfs diff=lfs merge=lfs -text -# Audio files - compressed -*.aac filter=lfs diff=lfs merge=lfs -text -*.flac filter=lfs diff=lfs merge=lfs -text -*.mp3 filter=lfs diff=lfs merge=lfs -text -*.ogg filter=lfs diff=lfs merge=lfs -text -*.wav filter=lfs diff=lfs merge=lfs -text -# Image files - uncompressed -*.bmp filter=lfs diff=lfs merge=lfs -text -*.gif filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -*.tiff filter=lfs diff=lfs merge=lfs -text -# Image files - compressed -*.jpg filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.webp filter=lfs diff=lfs merge=lfs -text - -` - const ( initCommitMessage = "initial commit" ossFileExpire = 259200 * time.Second - readmeFileName = "README.md" gitattributesFileName = ".gitattributes" ) @@ -203,7 +144,7 @@ func (c *datasetComponentImpl) Create(ctx context.Context, req *types.CreateData NewBranch: req.DefaultBranch, Namespace: req.Namespace, Name: req.Name, - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.DatasetRepo)) if err != nil { return nil, fmt.Errorf("failed to create README.md file, cause: %w", err) @@ -215,7 +156,7 @@ func (c *datasetComponentImpl) Create(ctx context.Context, req *types.CreateData Email: user.Email, Message: initCommitMessage, Branch: req.DefaultBranch, - Content: datasetGitattributesContent, + Content: types.DatasetGitattributesContent, NewBranch: req.DefaultBranch, Namespace: req.Namespace, Name: req.Name, diff --git a/component/dataset_test.go b/component/dataset_test.go index 69f1744d..3d630eea 100644 --- a/component/dataset_test.go +++ b/component/dataset_test.go @@ -50,7 +50,7 @@ func TestDatasetCompnent_Create(t *testing.T) { Content: "\n---\nlicense: \n---\n\t", Namespace: "ns", Name: "n", - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.DatasetRepo), ).Return(nil) dc.mocks.gitServer.EXPECT().CreateRepoFile(buildCreateFileReq( @@ -58,7 +58,7 @@ func TestDatasetCompnent_Create(t *testing.T) { Username: "user", Message: initCommitMessage, Branch: "main", - Content: datasetGitattributesContent, + Content: types.DatasetGitattributesContent, Namespace: "ns", Name: "n", FilePath: gitattributesFileName, diff --git a/component/dataset_viewer.go b/component/dataset_viewer.go deleted file mode 100644 index f3f031c3..00000000 --- a/component/dataset_viewer.go +++ /dev/null @@ -1,104 +0,0 @@ -package component - -import ( - "context" - "fmt" - "log/slog" - "sync" - - "opencsg.com/csghub-server/builder/git" - "opencsg.com/csghub-server/builder/git/gitserver" - "opencsg.com/csghub-server/builder/parquet" - "opencsg.com/csghub-server/common/config" - "opencsg.com/csghub-server/common/types" -) - -var ( - REPOCARD_FILENAME = "README.md" -) - -type ViewParquetFileReq struct { - Namespace string `json:"namespace"` - RepoName string `json:"name"` - Branch string `json:"branch"` - Path string `json:"path"` - RowCount int `json:"row_count"` -} -type ViewParquetFileResp struct { - Columns []string `json:"columns"` - Rows [][]interface{} `json:"rows"` -} -type datasetViewerComponentImpl struct { - gs gitserver.GitServer - preader parquet.Reader - once *sync.Once - cfg *config.Config -} - -type DatasetViewerComponent interface { - ViewParquetFile(ctx context.Context, req *ViewParquetFileReq) (*ViewParquetFileResp, error) -} - -func NewDatasetViewerComponent(cfg *config.Config) (DatasetViewerComponent, error) { - gs, err := git.NewGitServer(cfg) - if err != nil { - return nil, fmt.Errorf("failed to create git server,cause:%w", err) - } - return &datasetViewerComponentImpl{ - gs: gs, - once: new(sync.Once), - cfg: cfg, - }, nil -} - -func (c *datasetViewerComponentImpl) lazyInit() { - c.once.Do(func() { - r, err := parquet.NewS3Reader(c.cfg) - if err != nil { - slog.Error("failed to create parquet reader,cause:%w", slog.Any("error", err)) - } - c.preader = r - }) -} - -func (c *datasetViewerComponentImpl) ViewParquetFile(ctx context.Context, req *ViewParquetFileReq) (*ViewParquetFileResp, error) { - c.lazyInit() - - objName, err := c.getParquetObject(req) - if err != nil { - slog.Error("Failed to view parquet file", slog.Any("error", err)) - return nil, err - } - rowCount := req.RowCount - if rowCount < 1 { - rowCount = 20 - } else if rowCount > 100 { - rowCount = 100 - } - columns, rows, err := c.preader.TopN(objName, rowCount) - if err != nil { - slog.Error("Failed to view parquet file", slog.Any("error", err)) - return nil, err - } - resp := &ViewParquetFileResp{ - Columns: columns, - Rows: rows, - } - return resp, nil -} - -func (c *datasetViewerComponentImpl) getParquetObject(req *ViewParquetFileReq) (string, error) { - getFileContentReq := gitserver.GetRepoInfoByPathReq{ - Namespace: req.Namespace, - Name: req.RepoName, - Ref: req.Branch, - Path: req.Path, - RepoType: types.DatasetRepo, - } - f, err := c.gs.GetRepoFileContents(context.Background(), getFileContentReq) - if err != nil { - return "", fmt.Errorf("failed to get file contents,cause:%v", err) - } - - return "lfs/" + f.LfsRelativePath, nil -} diff --git a/component/internal.go b/component/internal.go index 07af29ca..964e91d2 100644 --- a/component/internal.go +++ b/component/internal.go @@ -8,6 +8,7 @@ import ( "strconv" pb "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb" + "opencsg.com/csghub-server/builder/dataviewer" "opencsg.com/csghub-server/builder/git" "opencsg.com/csghub-server/builder/git/gitserver" "opencsg.com/csghub-server/builder/git/gitserver/gitaly" @@ -25,6 +26,7 @@ type internalComponentImpl struct { namespaceStore database.NamespaceStore repoComponent RepoComponent gitServer gitserver.GitServer + dataviewer dataviewer.DataviewerClient } type InternalComponent interface { @@ -33,6 +35,7 @@ type InternalComponent interface { GetAuthorizedKeys(ctx context.Context, key string) (*database.SSHKey, error) GetCommitDiff(ctx context.Context, req types.GetDiffBetweenTwoCommitsReq) (*types.GiteaCallbackPushReq, error) LfsAuthenticate(ctx context.Context, req types.LfsAuthenticateReq) (*types.LfsAuthenticateResp, error) + TriggerDataviewerWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) } func NewInternalComponent(config *config.Config) (InternalComponent, error) { @@ -44,6 +47,7 @@ func NewInternalComponent(config *config.Config) (InternalComponent, error) { c.repoComponent, err = NewRepoComponentImpl(config) c.tokenStore = database.NewAccessTokenStore() c.namespaceStore = database.NewNamespaceStore() + c.dataviewer = dataviewer.NewDataviewerClient(config) if err != nil { return nil, err } @@ -194,3 +198,11 @@ func (c *internalComponentImpl) LfsAuthenticate(ctx context.Context, req types.L RepoPath: c.config.APIServer.PublicDomain + "/" + filepath.Join(repoType, req.Namespace, req.Name+".git"), }, nil } + +func (c *internalComponentImpl) TriggerDataviewerWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) { + res, err := c.dataviewer.TriggerWorkflow(ctx, req) + if err != nil { + return nil, fmt.Errorf("fail to trigger dataviewer workflow, error: %w", err) + } + return res, nil +} diff --git a/component/model.go b/component/model.go index 19cd2437..a5d18b49 100644 --- a/component/model.go +++ b/component/model.go @@ -260,7 +260,7 @@ func (c *modelComponentImpl) Create(ctx context.Context, req *types.CreateModelR NewBranch: req.DefaultBranch, Namespace: req.Namespace, Name: req.Name, - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.ModelRepo)) if err != nil { return nil, fmt.Errorf("failed to create README.md file, cause: %w", err) @@ -550,7 +550,7 @@ func (c *modelComponentImpl) SDKModelInfo(ctx context.Context, namespace, name, } } - filePaths, err := getFilePaths(namespace, name, "", types.ModelRepo, ref, c.gitServer.GetRepoFileTree) + filePaths, err := GetFilePaths(namespace, name, "", types.ModelRepo, ref, c.gitServer.GetRepoFileTree) if err != nil { return nil, fmt.Errorf("failed to get all %s files, error: %w", types.ModelRepo, err) } @@ -647,7 +647,7 @@ func (c *modelComponentImpl) SetRelationDatasets(ctx context.Context, req types. Namespace: req.Namespace, Name: req.Name, Ref: types.MainBranch, - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.ModelRepo, } @@ -664,7 +664,7 @@ func (c *modelComponentImpl) SetRelationDatasets(ctx context.Context, req types. var readmeReq types.UpdateFileReq readmeReq.Branch = types.MainBranch readmeReq.Message = "update dataset tags" - readmeReq.FilePath = REPOCARD_FILENAME + readmeReq.FilePath = types.REPOCARD_FILENAME readmeReq.RepoType = types.ModelRepo readmeReq.Namespace = req.Namespace readmeReq.Name = req.Name @@ -699,7 +699,7 @@ func (c *modelComponentImpl) AddRelationDataset(ctx context.Context, req types.R Namespace: req.Namespace, Name: req.Name, Ref: "main", - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.ModelRepo, } metaMap, splits, err := GetMetaMapFromReadMe(c.gitServer, getFileContentReq) @@ -721,7 +721,7 @@ func (c *modelComponentImpl) AddRelationDataset(ctx context.Context, req types.R var readmeReq types.UpdateFileReq readmeReq.Branch = "main" readmeReq.Message = "add relation dataset" - readmeReq.FilePath = REPOCARD_FILENAME + readmeReq.FilePath = types.REPOCARD_FILENAME readmeReq.RepoType = types.ModelRepo readmeReq.Namespace = req.Namespace readmeReq.Name = req.Name @@ -756,7 +756,7 @@ func (c *modelComponentImpl) DelRelationDataset(ctx context.Context, req types.R Namespace: req.Namespace, Name: req.Name, Ref: "main", - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.ModelRepo, } metaMap, splits, err := GetMetaMapFromReadMe(c.gitServer, getFileContentReq) @@ -783,7 +783,7 @@ func (c *modelComponentImpl) DelRelationDataset(ctx context.Context, req types.R var readmeReq types.UpdateFileReq readmeReq.Branch = "main" readmeReq.Message = "delete relation dataset" - readmeReq.FilePath = REPOCARD_FILENAME + readmeReq.FilePath = types.REPOCARD_FILENAME readmeReq.RepoType = types.ModelRepo readmeReq.Namespace = req.Namespace readmeReq.Name = req.Name @@ -863,7 +863,7 @@ func GetFilePathObjects(namespace, repoName, folder string, repoType types.Repos return allFiles, nil } -func getFilePaths(namespace, repoName, folder string, repoType types.RepositoryType, ref string, gsTree func(ctx context.Context, req gitserver.GetRepoInfoByPathReq) ([]*types.File, error)) ([]string, error) { +func GetFilePaths(namespace, repoName, folder string, repoType types.RepositoryType, ref string, gsTree func(ctx context.Context, req gitserver.GetRepoInfoByPathReq) ([]*types.File, error)) ([]string, error) { var filePaths []string allFiles, err := getAllFiles(namespace, repoName, folder, repoType, ref, gsTree) if err != nil { diff --git a/component/model_test.go b/component/model_test.go index 5cae3bf9..a8194302 100644 --- a/component/model_test.go +++ b/component/model_test.go @@ -97,7 +97,7 @@ func TestModelComponent_Create(t *testing.T) { NewBranch: "main", Namespace: "ns", Name: "n", - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.ModelRepo)).Return(nil) mc.mocks.gitServer.EXPECT().CreateRepoFile(buildCreateFileReq(&types.CreateFileParams{ Username: "user", @@ -362,7 +362,7 @@ func TestModelComponent_SetRelationDatasets(t *testing.T) { Namespace: "ns", Name: "n", Ref: "main", - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.ModelRepo, }).Return(&types.File{}, nil) mc.mocks.gitServer.EXPECT().UpdateRepoFile(&types.UpdateFileReq{ @@ -398,7 +398,7 @@ func TestModelComponent_AddRelationDataset(t *testing.T) { Namespace: "ns", Name: "n", Ref: "main", - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.ModelRepo, }).Return(&types.File{}, nil) mc.mocks.gitServer.EXPECT().UpdateRepoFile(&types.UpdateFileReq{ @@ -434,7 +434,7 @@ func TestModelComponent_DeleteRelationDataset(t *testing.T) { Namespace: "ns", Name: "n", Ref: "main", - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.ModelRepo, }).Return(&types.File{ Content: "LS0tCiBkYXRhc2V0czoKICAgLSBkczE=", diff --git a/component/prompt.go b/component/prompt.go index 1d4e789e..142c494f 100644 --- a/component/prompt.go +++ b/component/prompt.go @@ -400,7 +400,7 @@ func (c *promptComponentImpl) SetRelationModels(ctx context.Context, req types.R Namespace: req.Namespace, Name: req.Name, Ref: types.MainBranch, - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.PromptRepo, } metaMap, splits, err := GetMetaMapFromReadMe(c.gitServer, getFileContentReq) @@ -416,7 +416,7 @@ func (c *promptComponentImpl) SetRelationModels(ctx context.Context, req types.R var readmeReq types.UpdateFileReq readmeReq.Branch = types.MainBranch readmeReq.Message = "update model relation tags" - readmeReq.FilePath = REPOCARD_FILENAME + readmeReq.FilePath = types.REPOCARD_FILENAME readmeReq.RepoType = types.PromptRepo readmeReq.Namespace = req.Namespace readmeReq.Name = req.Name @@ -498,7 +498,7 @@ func (c *promptComponentImpl) AddRelationModel(ctx context.Context, req types.Re Namespace: req.Namespace, Name: req.Name, Ref: types.MainBranch, - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.PromptRepo, } metaMap, splits, err := GetMetaMapFromReadMe(c.gitServer, getFileContentReq) @@ -520,7 +520,7 @@ func (c *promptComponentImpl) AddRelationModel(ctx context.Context, req types.Re var readmeReq types.UpdateFileReq readmeReq.Branch = types.MainBranch readmeReq.Message = "add relation model" - readmeReq.FilePath = REPOCARD_FILENAME + readmeReq.FilePath = types.REPOCARD_FILENAME readmeReq.RepoType = types.PromptRepo readmeReq.Namespace = req.Namespace readmeReq.Name = req.Name @@ -555,7 +555,7 @@ func (c *promptComponentImpl) DelRelationModel(ctx context.Context, req types.Re Namespace: req.Namespace, Name: req.Name, Ref: types.MainBranch, - Path: REPOCARD_FILENAME, + Path: types.REPOCARD_FILENAME, RepoType: types.PromptRepo, } metaMap, splits, err := GetMetaMapFromReadMe(c.gitServer, getFileContentReq) @@ -582,7 +582,7 @@ func (c *promptComponentImpl) DelRelationModel(ctx context.Context, req types.Re var readmeReq types.UpdateFileReq readmeReq.Branch = types.MainBranch readmeReq.Message = "delete relation model" - readmeReq.FilePath = REPOCARD_FILENAME + readmeReq.FilePath = types.REPOCARD_FILENAME readmeReq.RepoType = types.PromptRepo readmeReq.Namespace = req.Namespace readmeReq.Name = req.Name @@ -667,7 +667,7 @@ func (c *promptComponentImpl) CreatePromptRepo(ctx context.Context, req *types.C NewBranch: req.DefaultBranch, Namespace: req.Namespace, Name: req.Name, - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.PromptRepo)) if err != nil { return nil, fmt.Errorf("failed to create prompt repo README.md file, cause: %w", err) @@ -679,7 +679,7 @@ func (c *promptComponentImpl) CreatePromptRepo(ctx context.Context, req *types.C Email: user.Email, Message: initCommitMessage, Branch: req.DefaultBranch, - Content: datasetGitattributesContent, + Content: types.DatasetGitattributesContent, NewBranch: req.DefaultBranch, Namespace: req.Namespace, Name: req.Name, diff --git a/component/prompt_test.go b/component/prompt_test.go index dddc8b26..7a4996a3 100644 --- a/component/prompt_test.go +++ b/component/prompt_test.go @@ -381,7 +381,7 @@ func TestPromptComponent_SetRelationModels(t *testing.T) { pc.mocks.gitServer.EXPECT().UpdateRepoFile(&types.UpdateFileReq{ Branch: types.MainBranch, Message: "update model relation tags", - FilePath: REPOCARD_FILENAME, + FilePath: types.REPOCARD_FILENAME, RepoType: types.PromptRepo, Namespace: "ns", Name: "n", @@ -423,7 +423,7 @@ func TestPromptComponent_AddRelationModel(t *testing.T) { pc.mocks.gitServer.EXPECT().UpdateRepoFile(&types.UpdateFileReq{ Branch: types.MainBranch, Message: "add relation model", - FilePath: REPOCARD_FILENAME, + FilePath: types.REPOCARD_FILENAME, RepoType: types.PromptRepo, Namespace: "ns", Name: "n", @@ -465,7 +465,7 @@ func TestPromptComponent_DelRelationModel(t *testing.T) { pc.mocks.gitServer.EXPECT().UpdateRepoFile(&types.UpdateFileReq{ Branch: types.MainBranch, Message: "delete relation model", - FilePath: REPOCARD_FILENAME, + FilePath: types.REPOCARD_FILENAME, RepoType: types.PromptRepo, Namespace: "ns", Name: "n", @@ -538,7 +538,7 @@ func TestPromptComponent_CreatePromptRepo(t *testing.T) { Email: "foo@bar.com", Message: "initial commit", Branch: "main", - Content: base64.StdEncoding.EncodeToString([]byte(datasetGitattributesContent)), + Content: base64.StdEncoding.EncodeToString([]byte(types.DatasetGitattributesContent)), NewBranch: "main", FilePath: ".gitattributes", Namespace: "ns", diff --git a/component/recom.go b/component/recom.go index 0e3183d8..712b23f8 100644 --- a/component/recom.go +++ b/component/recom.go @@ -132,7 +132,7 @@ func (rc *recomComponentImpl) calcQualityScore(ctx context.Context, repo *databa score := 0.0 // get file counts from git server namespace, name := repo.NamespaceAndName() - files, err := getFilePaths(namespace, name, "", repo.RepositoryType, "", rc.gitServer.GetRepoFileTree) + files, err := GetFilePaths(namespace, name, "", repo.RepositoryType, "", rc.gitServer.GetRepoFileTree) if err != nil { return 0, fmt.Errorf("failed to get repo file tree,%w", err) } diff --git a/component/repo.go b/component/repo.go index 406a4326..ebb407b8 100644 --- a/component/repo.go +++ b/component/repo.go @@ -1348,7 +1348,7 @@ func (c *repoComponentImpl) SDKListFiles(ctx context.Context, repoType types.Rep ref = repo.DefaultBranch } - filePaths, err := getFilePaths(namespace, name, "", repoType, ref, c.git.GetRepoFileTree) + filePaths, err := GetFilePaths(namespace, name, "", repoType, ref, c.git.GetRepoFileTree) if err != nil { return nil, fmt.Errorf("failed to get all %s files, error: %w", repoType, err) } diff --git a/component/space.go b/component/space.go index 1850810e..58e971d6 100644 --- a/component/space.go +++ b/component/space.go @@ -117,7 +117,7 @@ func (c *spaceComponentImpl) Create(ctx context.Context, req types.CreateSpaceRe NewBranch: req.DefaultBranch, Namespace: req.Namespace, Name: req.Name, - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.SpaceRepo)) if err != nil { return nil, fmt.Errorf("failed to create README.md file, cause: %w", err) diff --git a/component/space_ce_test.go b/component/space_ce_test.go index c9175045..f082edbe 100644 --- a/component/space_ce_test.go +++ b/component/space_ce_test.go @@ -62,7 +62,7 @@ func TestSpaceComponent_Create(t *testing.T) { NewBranch: "main", Namespace: "ns", Name: "n", - FilePath: readmeFileName, + FilePath: types.ReadmeFileName, }, types.SpaceRepo)).Return(nil) sc.mocks.gitServer.EXPECT().CreateRepoFile(buildCreateFileReq(&types.CreateFileParams{ Username: "user", diff --git a/component/wire_gen_test.go b/component/wire_gen_test.go index a8fec516..754f6e0a 100644 --- a/component/wire_gen_test.go +++ b/component/wire_gen_test.go @@ -321,56 +321,6 @@ func initializeTestAccountingComponent(ctx context.Context, t interface { return componentTestAccountingWithMocks } -func initializeTestDatasetViewerComponent(ctx context.Context, t interface { - Cleanup(func()) - mock.TestingT -}) *testDatasetViewerWithMocks { - mockStores := tests.NewMockStores(t) - config := ProvideTestConfig() - mockRepoComponent := component.NewMockRepoComponent(t) - mockGitServer := gitserver.NewMockGitServer(t) - mockReader := parquet.NewMockReader(t) - componentDatasetViewerComponentImpl := NewTestDatasetViewerComponent(mockStores, config, mockRepoComponent, mockGitServer, mockReader) - mockAccountingComponent := component.NewMockAccountingComponent(t) - mockTagComponent := component.NewMockTagComponent(t) - mockSpaceComponent := component.NewMockSpaceComponent(t) - mockRuntimeArchitectureComponent := component.NewMockRuntimeArchitectureComponent(t) - mockSensitiveComponent := component.NewMockSensitiveComponent(t) - componentMockedComponents := &mockedComponents{ - accounting: mockAccountingComponent, - repo: mockRepoComponent, - tag: mockTagComponent, - space: mockSpaceComponent, - runtimeArchitecture: mockRuntimeArchitectureComponent, - sensitive: mockSensitiveComponent, - } - mockUserSvcClient := rpc.NewMockUserSvcClient(t) - mockClient := s3.NewMockClient(t) - mockMirrorServer := mirrorserver.NewMockMirrorServer(t) - mockPriorityQueue := queue.NewMockPriorityQueue(t) - mockDeployer := deploy.NewMockDeployer(t) - mockAccountingClient := accounting.NewMockAccountingClient(t) - mockModerationSvcClient := rpc.NewMockModerationSvcClient(t) - mocks := &Mocks{ - stores: mockStores, - components: componentMockedComponents, - gitServer: mockGitServer, - userSvcClient: mockUserSvcClient, - s3Client: mockClient, - mirrorServer: mockMirrorServer, - mirrorQueue: mockPriorityQueue, - deployer: mockDeployer, - accountingClient: mockAccountingClient, - preader: mockReader, - moderationClient: mockModerationSvcClient, - } - componentTestDatasetViewerWithMocks := &testDatasetViewerWithMocks{ - datasetViewerComponentImpl: componentDatasetViewerComponentImpl, - mocks: mocks, - } - return componentTestDatasetViewerWithMocks -} - func initializeTestGitHTTPComponent(ctx context.Context, t interface { Cleanup(func()) mock.TestingT @@ -1600,11 +1550,6 @@ type testAccountingWithMocks struct { mocks *Mocks } -type testDatasetViewerWithMocks struct { - *datasetViewerComponentImpl - mocks *Mocks -} - type testGitHTTPWithMocks struct { *gitHTTPComponentImpl mocks *Mocks diff --git a/component/wireset.go b/component/wireset.go index 364f500d..2955bdf5 100644 --- a/component/wireset.go +++ b/component/wireset.go @@ -258,15 +258,6 @@ func NewTestAccountingComponent(stores *tests.MockStores, accountingClient accou var AccountingComponentSet = wire.NewSet(NewTestAccountingComponent) -func NewTestDatasetViewerComponent(stores *tests.MockStores, cfg *config.Config, repoComponent RepoComponent, gitServer gitserver.GitServer, preader parquet.Reader) *datasetViewerComponentImpl { - return &datasetViewerComponentImpl{ - cfg: cfg, - preader: preader, - } -} - -var DatasetViewerComponentSet = wire.NewSet(NewTestDatasetViewerComponent) - func NewTestGitHTTPComponent( config *config.Config, stores *tests.MockStores, diff --git a/dataviewer/common/types.go b/dataviewer/common/types.go new file mode 100644 index 00000000..1d1bb552 --- /dev/null +++ b/dataviewer/common/types.go @@ -0,0 +1,174 @@ +package common + +import ( + "context" + "regexp" + + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" +) + +type RepoDataType string + +var ( + WILDCARD = "*" + REG = regexp.MustCompile(`(?s)---\n(.*?)\n---`) + ParquetBranch = "refs-convert-parquet" + DuckdbBranch = "refs-convert-duckdb" + TaskQueueDataViewerDatasetUpdate = "data_viewer_queue_dataset_update" +) + +type ViewParquetFileReq struct { + Namespace string `json:"namespace"` + RepoName string `json:"name"` + Branch string `json:"branch"` + Path string `json:"path"` + Per int `json:"per"` + Page int `json:"page"` + CurrentUser string `json:"current_user"` +} + +type ViewParquetFileResp struct { + Columns []string `json:"columns"` + ColumnsType []string `json:"columns_type"` + Rows [][]interface{} `json:"rows"` + Total int `json:"total"` + Orderby string `json:"orderby"` + Where string `json:"where"` + Search string `json:"search"` +} + +type CardData struct { + Configs []ConfigData `yaml:"configs" json:"configs"` + DatasetInfos []DatasetInfo `yaml:"dataset_info" json:"dataset_info"` +} + +type ConfigData struct { + ConfigName string `yaml:"config_name" json:"config_name"` + DataFiles []DataFiles `yaml:"data_files" json:"data_files"` +} + +type DataFiles struct { + Split string `yaml:"split" json:"split"` + Path interface{} `yaml:"path" json:"path"` +} + +type DatasetInfo struct { + ConfigName string `yaml:"config_name" json:"config_name"` + Splits []Split `yaml:"splits" json:"splits"` +} + +type Split struct { + Name string `yaml:"name" json:"name"` + NumExamples int `yaml:"num_examples" json:"num_examples"` + Files []FileObject `yaml:"files,omitempty" json:"files,omitempty"` + Origins []FileObject `yaml:"origins,omitempty" json:"origins,omitempty"` +} + +type RepoFilesReq struct { + Namespace string + RepoName string + RepoType types.RepositoryType + Ref string + Folder string + GSTree func(ctx context.Context, req gitserver.GetRepoInfoByPathReq) ([]*types.File, error) +} + +type RepoFilesClass struct { + AllFiles map[string]*types.File + ParquetFiles map[string]*types.File + JsonlFiles map[string]*types.File + CsvFiles map[string]*types.File +} + +type DownloadCard struct { + Configs []ConfigData `yaml:"configs" json:"configs"` + Subsets []DownloadSubset `yaml:"subsets" json:"subsets"` +} + +type DownloadSubset struct { + ConfigName string `yaml:"config_name" json:"config_name"` + Splits []DownloadSplit `yaml:"splits" json:"splits"` +} + +type DownloadSplit struct { + Name string `yaml:"name" json:"name"` + LocalPath string `yaml:"local_path" json:"local_path"` + ExportPath string `yaml:"export_path" json:"export_path"` + Files []FileObject `yaml:"files,omitempty" json:"files,omitempty"` +} + +type FileObject struct { + RepoFile string `yaml:"repo_file" json:"repo_file"` + Size int64 `yaml:"size" json:"size"` + LastCommit string `yaml:"last_commit" json:"last_commit"` + Lfs bool `yaml:"lfs" json:"lfs"` + LfsRelativePath string `yaml:"lfs_relative_path" json:"lfs_relative_path"` + SubsetName string `yaml:"subset_name" json:"subset_name"` + SplitName string `yaml:"split_name" json:"split_name"` + ConvertPath string `yaml:"convert_path" json:"convert_path"` + ObjectKey string `yaml:"object_key" json:"object_key"` + LocalRepoPath string `yaml:"local_repo_path" json:"local_repo_path"` + LocalFileName string `yaml:"local_file_name" json:"local_file_name"` +} + +type CataLogRespone struct { + Configs []ConfigData `yaml:"configs" json:"configs"` + DatasetInfos []DatasetInfo `yaml:"dataset_info" json:"dataset_info"` + Status int `yaml:"status" json:"status"` + Logs string `yaml:"logs" json:"logs"` +} + +type WorkflowUpdateParams struct { + Req types.UpdateViewerReq + Config *config.Config +} + +type ScanRepoFileReq struct { + Req types.UpdateViewerReq + MaxFileSize int64 +} + +type DetermineCardReq struct { + Card CardData + Class RepoFilesClass + RepoDataType RepoDataType +} + +type CheckBuildReq struct { + Req types.UpdateViewerReq + Card CardData +} + +type CopyParquetReq struct { + Req types.UpdateViewerReq + ComputedCardData CardData + NewBranch string +} + +type DownloadFileReq CheckBuildReq + +type ConvertReq struct { + Req types.UpdateViewerReq + DownloadCard DownloadCard + RepoDataType RepoDataType +} + +type UploadParquetReq struct { + Req types.UpdateViewerReq + DownloadCard DownloadCard + NewBranch string +} + +type UpdateCardReq struct { + Req types.UpdateViewerReq + OriginCardData CardData + FinalCardData CardData +} + +type UpdateWorkflowStatusReq struct { + Req types.UpdateViewerReq + WorkflowErr error + ShouldUpdateViewer bool +} diff --git a/dataviewer/component/callback.go b/dataviewer/component/callback.go new file mode 100644 index 00000000..1761e14c --- /dev/null +++ b/dataviewer/component/callback.go @@ -0,0 +1,121 @@ +package component + +import ( + "context" + "fmt" + "log/slog" + "time" + + enumspb "go.temporal.io/api/enums/v1" + "go.temporal.io/sdk/client" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/builder/temporal" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" + "opencsg.com/csghub-server/dataviewer/workflows" +) + +type CallbackComponent interface { + TriggerDataviewUpdateWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) +} + +type callbackComponentImpl struct { + cfg *config.Config + workflowClient temporal.Client + gitServer gitserver.GitServer + repoStore database.RepoStore + dataviewerStore database.DataviewerStore +} + +func NewCallbackComponent(cfg *config.Config, tc temporal.Client, gs gitserver.GitServer) (CallbackComponent, error) { + return &callbackComponentImpl{ + cfg: cfg, + workflowClient: tc, + gitServer: gs, + repoStore: database.NewRepoStore(), + dataviewerStore: database.NewDataviewerStore(), + }, nil +} + +func (c *callbackComponentImpl) TriggerDataviewUpdateWorkflow(ctx context.Context, req types.UpdateViewerReq) (*types.WorkFlowInfo, error) { + if req.Branch == dvCom.ParquetBranch || req.Branch == dvCom.DuckdbBranch { + return nil, fmt.Errorf("skip update dataviewer for repo %s/%s branch %s changes", req.Namespace, req.Name, req.Branch) + } + repo, err := c.repoStore.FindByPath(ctx, req.RepoType, req.Namespace, req.Name) + if err != nil { + return nil, fmt.Errorf("failed to find dataset, error: %w", err) + } + req.Branch = repo.DefaultBranch + req.RepoID = repo.ID + + jobs, err := c.dataviewerStore.GetRunningJobsByRepoID(ctx, req.RepoID) + if err != nil { + return nil, fmt.Errorf("failed to get running jobs by repo_id %d, error: %w", req.RepoID, err) + } + if len(jobs) > 0 { + slog.Debug("there are still running jobs for this dataset", slog.Any("req", req), slog.Any("running jobs count", len(jobs))) + return nil, fmt.Errorf("there are still running jobs for this dataset %s/%s branch %s", req.Namespace, req.Name, req.Branch) + } + + dv, err := c.dataviewerStore.GetViewerByRepoID(ctx, repo.ID) + if err != nil { + return nil, fmt.Errorf("failed to get dataviewer by repo_id %d, error: %w", repo.ID, err) + } + + newWorkflowID := workflows.GenerateWorkFlowID(req) + + if dv == nil { + dataviewer := database.Dataviewer{ + RepoID: repo.ID, + RepoPath: fmt.Sprintf("%s/%s", req.Namespace, repo.Name), + RepoBranch: req.Branch, + WorkflowID: newWorkflowID, + } + err = c.dataviewerStore.CreateViewer(ctx, dataviewer) + if err != nil { + return nil, fmt.Errorf("fail to create dataviewer, error: %w", err) + } + } else { + job := database.DataviewerJob{ + RepoID: repo.ID, + WorkflowID: newWorkflowID, + Status: types.WorkflowPending, + AutoCard: true, + Logs: types.WorkflowMsgPending, + } + err := c.dataviewerStore.CreateJob(ctx, job) + if err != nil { + return nil, fmt.Errorf("fail to create dataviewer job, error: %w", err) + } + } + + executeTimeOut := time.Duration(c.cfg.WorkFLow.ExecutionTimeout) * time.Second + taskTimeout := time.Duration(c.cfg.WorkFLow.TaskTimeout) * time.Second + options := client.StartWorkflowOptions{ + ID: newWorkflowID, + TaskQueue: dvCom.TaskQueueDataViewerDatasetUpdate, + WorkflowIDReusePolicy: enumspb.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY, + WorkflowExecutionTimeout: executeTimeOut, + WorkflowTaskTimeout: taskTimeout, + } + wfRun, err := c.workflowClient.ExecuteWorkflow(ctx, options, workflows.DataViewerUpdateWorkflow, + dvCom.WorkflowUpdateParams{Req: req, Config: c.cfg}) + if err != nil { + return nil, fmt.Errorf("fail to execute workflow, error: %w", err) + } + + slog.Info("submit workflow", slog.Any("WorkflowID", wfRun.GetID()), slog.Any("RunID", wfRun.GetRunID()), slog.Any("req", req)) + + workFlowInfo := types.WorkFlowInfo{ + Namespace: req.Namespace, + Name: req.Name, + Branch: req.Branch, + RepoType: req.RepoType, + WorkFlowID: wfRun.GetID(), + WorkFlowRunID: wfRun.GetRunID(), + } + + return &workFlowInfo, nil +} diff --git a/dataviewer/component/callback_test.go b/dataviewer/component/callback_test.go new file mode 100644 index 00000000..f16afbe5 --- /dev/null +++ b/dataviewer/component/callback_test.go @@ -0,0 +1,104 @@ +package component + +import ( + "context" + "testing" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "go.temporal.io/sdk/client" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/builder/temporal" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" + + mockGit "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/git/gitserver" + mockdb "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/store/database" + mock_temporal "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/temporal" +) + +var _ client.WorkflowRun = (*MockWorkflowRun)(nil) + +type MockWorkflowRun struct { +} + +func (mw *MockWorkflowRun) GetID() string { + return "113" +} + +func (mw *MockWorkflowRun) GetRunID() string { + return "234" +} +func (mw *MockWorkflowRun) Get(ctx context.Context, valuePtr interface{}) error { + return nil +} + +func (mw *MockWorkflowRun) GetWithOptions(ctx context.Context, valuePtr interface{}, options client.WorkflowRunGetOptions) error { + return nil +} + +func NewTestNewCallbackComponent(cfg *config.Config, + tc temporal.Client, gs gitserver.GitServer, + rs database.RepoStore, ds database.DataviewerStore, +) CallbackComponent { + abc := &callbackComponentImpl{ + cfg: cfg, + workflowClient: tc, + gitServer: gs, + repoStore: rs, + dataviewerStore: ds, + } + return abc +} + +func TestDatasetViewerComppnent_TriggerWorkflow(t *testing.T) { + ctx := context.TODO() + + config := &config.Config{} + + req := types.UpdateViewerReq{ + Namespace: "test-ns", + Name: "test-name", + Branch: "test-branch", + RepoType: types.DatasetRepo, + RepoID: int64(1), + } + + repo := mockdb.NewMockRepoStore(t) + repo.EXPECT().FindByPath(ctx, req.RepoType, req.Namespace, req.Name).Return(&database.Repository{ + ID: int64(1), + DefaultBranch: "test-branch", + }, nil) + + dvstore := mockdb.NewMockDataviewerStore(t) + + dvstore.EXPECT().GetRunningJobsByRepoID(ctx, int64(1)).Return([]database.DataviewerJob{}, nil) + + dvstore.EXPECT().GetViewerByRepoID(ctx, int64(1)).Return(&database.Dataviewer{ + ID: int64(1), + RepoID: int64(1), + WorkflowID: "test-workflow-id", + }, nil) + + dvstore.EXPECT().CreateJob(mock.Anything, mock.Anything).RunAndReturn(func(ctx context.Context, job database.DataviewerJob) error { + require.NotNil(t, job.WorkflowID) + return nil + }) + + mockGitServer := mockGit.NewMockGitServer(t) + + mtc := mock_temporal.NewMockClient(t) + + mtc.EXPECT().ExecuteWorkflow( + mock.Anything, mock.Anything, + mock.AnythingOfType("func(internal.Context, common.WorkflowUpdateParams) error"), + dvCom.WorkflowUpdateParams{Req: req, Config: config}).Return(&MockWorkflowRun{}, nil) + + cbComp := NewTestNewCallbackComponent(config, mtc, mockGitServer, repo, dvstore) + + workflow, err := cbComp.TriggerDataviewUpdateWorkflow(ctx, req) + require.Nil(t, err) + require.NotNil(t, workflow) +} diff --git a/dataviewer/component/dataset_viewer.go b/dataviewer/component/dataset_viewer.go new file mode 100644 index 00000000..176140d3 --- /dev/null +++ b/dataviewer/component/dataset_viewer.go @@ -0,0 +1,582 @@ +package component + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "log/slog" + "regexp" + "strings" + + "gopkg.in/yaml.v3" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/parquet" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + hubCom "opencsg.com/csghub-server/component" + dvCom "opencsg.com/csghub-server/dataviewer/common" + "opencsg.com/csghub-server/dataviewer/workflows" +) + +type DatasetViewerComponent interface { + ViewParquetFile(ctx context.Context, req *dvCom.ViewParquetFileReq) (*dvCom.ViewParquetFileResp, error) + Rows(ctx context.Context, req *dvCom.ViewParquetFileReq, viewerReq types.DataViewerReq) (*dvCom.ViewParquetFileResp, error) + GetCatalog(ctx context.Context, req *dvCom.ViewParquetFileReq) (*dvCom.CataLogRespone, error) +} + +type datasetViewerComponentImpl struct { + repoStore database.RepoStore + repoComponent hubCom.RepoComponent + gitServer gitserver.GitServer + preader parquet.Reader + cfg *config.Config + viewerStore database.DataviewerStore +} + +func NewDatasetViewerComponent(cfg *config.Config, gs gitserver.GitServer) (DatasetViewerComponent, error) { + r, err := hubCom.NewRepoComponentImpl(cfg) + if err != nil { + return nil, fmt.Errorf("failed to create repo component,cause:%w", err) + } + + return &datasetViewerComponentImpl{ + gitServer: gs, + cfg: cfg, + repoComponent: r, + repoStore: database.NewRepoStore(), + viewerStore: database.NewDataviewerStore(), + }, nil +} + +func (c *datasetViewerComponentImpl) lazyInit(ctx context.Context) error { + if c.preader != nil { + return nil + } + r, err := parquet.NewS3Reader(ctx, c.cfg) + if err != nil { + c.preader = nil + return fmt.Errorf("failed to create parquet reader,cause: %w", err) + } + c.preader = r + return nil +} + +func (c *datasetViewerComponentImpl) ViewParquetFile(ctx context.Context, req *dvCom.ViewParquetFileReq) (*dvCom.ViewParquetFileResp, error) { + err := c.lazyInit(ctx) + if err != nil { + return nil, fmt.Errorf("failed to init parquet reader, %w", err) + } + + r, err := c.repoStore.FindByPath(ctx, types.DatasetRepo, req.Namespace, req.RepoName) + if err != nil { + return nil, fmt.Errorf("failed to find dataset, error: %w", err) + } + + allow, err := c.repoComponent.AllowReadAccessRepo(ctx, r, req.CurrentUser) + if err != nil { + return nil, fmt.Errorf("failed to check dataset permission, error: %w", err) + } + if !allow { + return nil, hubCom.ErrForbidden + } + req.Branch = r.DefaultBranch + objName, err := c.getParquetObject(ctx, req) + if err != nil { + return nil, fmt.Errorf("no valid parquet file in request, %w", err) + } + + sqlReq := types.QueryReq{ + PageSize: req.Per, + PageIndex: req.Page, + Search: "", + Where: "", + Orderby: "", + } + + total, err := c.preader.RowCount(ctx, []string{objName}, sqlReq, true) + if err != nil { + return nil, fmt.Errorf("failed to get total count of parquet file, %w", err) + } + + columns, columnsType, rows, err := c.preader.FetchRows(ctx, []string{objName}, sqlReq, true) + if err != nil { + return nil, fmt.Errorf("failed to view parquet rows, %w", err) + } + + resp := &dvCom.ViewParquetFileResp{ + Columns: columns, + ColumnsType: columnsType, + Rows: rows, + Total: total, + } + return resp, nil +} + +func (c *datasetViewerComponentImpl) Rows(ctx context.Context, req *dvCom.ViewParquetFileReq, viewerReq types.DataViewerReq) (*dvCom.ViewParquetFileResp, error) { + r, err := c.repoStore.FindByPath(ctx, types.DatasetRepo, req.Namespace, req.RepoName) + if err != nil { + return nil, fmt.Errorf("failed to find dataset, error: %w", err) + } + + allow, err := c.repoComponent.AllowReadAccessRepo(ctx, r, req.CurrentUser) + if err != nil { + return nil, fmt.Errorf("failed to check dataset permission, error: %w", err) + } + if !allow { + return nil, hubCom.ErrForbidden + } + req.Branch = r.DefaultBranch + + err = c.lazyInit(ctx) + if err != nil { + return nil, fmt.Errorf("failed to init parquet reader, %w", err) + } + + _, parquetObjs, err := c.getViewerCardData(ctx, r.ID, &viewerReq) + if err != nil { + slog.Warn("do not found viewer card data", slog.Any("repo_id", r.ID), slog.Any("req", req), slog.Any("error", err)) + parquetObjs, err = c.getRepoParquetObjs(ctx, req, viewerReq) + if err != nil { + return nil, fmt.Errorf("failed to get parquet objects, %w", err) + } + } + + if len(parquetObjs) < 1 { + return nil, fmt.Errorf("no valid parquet file in request for row data") + } + + sqlReq := types.QueryReq{ + PageSize: req.Per, + PageIndex: req.Page, + Search: viewerReq.Search, + Where: viewerReq.Where, + Orderby: viewerReq.Orderby, + } + + total, err := c.preader.RowCount(ctx, parquetObjs, sqlReq, true) + if err != nil { + return nil, fmt.Errorf("failed to get total count of parquet file, %w", err) + } + columns, columnsType, rows, err := c.preader.FetchRows(ctx, parquetObjs, sqlReq, true) + if err != nil { + return nil, fmt.Errorf("failed to view parquet rows, %w", err) + } + + resp := &dvCom.ViewParquetFileResp{ + Columns: columns, + ColumnsType: columnsType, + Rows: rows, + Total: total, + Orderby: viewerReq.Orderby, + Where: viewerReq.Where, + Search: viewerReq.Search, + } + return resp, nil +} + +func (c *datasetViewerComponentImpl) getRepoParquetObjs(ctx context.Context, req *dvCom.ViewParquetFileReq, viewerReq types.DataViewerReq) ([]string, error) { + cardData, err := c.getDatasetCatalog(ctx, req, false) + if err != nil { + return nil, fmt.Errorf("failed to get dataset catalog, error: %w", err) + } + slog.Debug("Rows cardData", slog.Any("cardData", cardData)) + var reqFiles []string + var hasWildCard bool + var tree []string + + for _, config := range cardData.Configs { + if config.ConfigName == viewerReq.Config { + for _, datafile := range config.DataFiles { + if datafile.Split == viewerReq.Split { + reqFiles, hasWildCard = c.getPatternFileList(datafile.Path) + break + } + } + break + } + } + + realReqFiles := reqFiles + if hasWildCard { + // need get real files match test/test-* in repo + realReqFiles, _ = c.convertRealFiles(req, reqFiles, tree) + } + parquetObjs := c.getFilesOBJs(ctx, req, realReqFiles) + if len(parquetObjs) < 1 { + return nil, fmt.Errorf("no valid files in request") + } + return parquetObjs, nil +} + +func (c *datasetViewerComponentImpl) GetCatalog(ctx context.Context, req *dvCom.ViewParquetFileReq) (*dvCom.CataLogRespone, error) { + r, err := c.repoStore.FindByPath(ctx, types.DatasetRepo, req.Namespace, req.RepoName) + if err != nil { + return nil, fmt.Errorf("failed to find dataset, error: %w", err) + } + + allow, err := c.repoComponent.AllowReadAccessRepo(ctx, r, req.CurrentUser) + if err != nil { + return nil, fmt.Errorf("failed to check dataset permission, error: %w", err) + } + if !allow { + return nil, hubCom.ErrForbidden + } + req.Branch = r.DefaultBranch + + err = c.lazyInit(ctx) + if err != nil { + return nil, fmt.Errorf("failed to init parquet reader, %w", err) + } + + viewerCardData, _, err := c.getViewerCardData(ctx, r.ID, nil) + if err != nil { + slog.Warn("do not found viewer card data", slog.Any("repo_id", r.ID), slog.Any("req", req), slog.Any("error", err)) + } else { + return viewerCardData, nil + } + + cardData, err := c.getDatasetCatalog(ctx, req, true) + if err != nil { + return nil, fmt.Errorf("failed to get dataset catalog, error: %w", err) + } + return &dvCom.CataLogRespone{ + Configs: cardData.Configs, + DatasetInfos: cardData.DatasetInfos, + }, nil +} + +func (c *datasetViewerComponentImpl) getViewerCardData(ctx context.Context, repoID int64, viewerReq *types.DataViewerReq) (*dvCom.CataLogRespone, []string, error) { + viewer, err := c.viewerStore.GetViewerByRepoID(ctx, repoID) + if err != nil { + return nil, nil, fmt.Errorf("failed to get viewer by repo_id %d, error: %w", repoID, err) + } + + if viewer == nil || viewer.DataviewerJob == nil || len(viewer.DataviewerJob.CardData) < 1 { + return nil, nil, fmt.Errorf("viewer card data is empty") + } + + if viewer.DataviewerJob.Status == types.WorkflowPending || viewer.DataviewerJob.Status == types.WorkflowFailed { + return &dvCom.CataLogRespone{ + Status: viewer.DataviewerJob.Status, + Logs: viewer.DataviewerJob.Logs, + }, nil, nil + } + + var viewerCardData dvCom.CardData + err = json.Unmarshal([]byte(viewer.DataviewerJob.CardData), &viewerCardData) + if err != nil { + return nil, nil, fmt.Errorf("failed to unmarshal viewer card data, error: %w", err) + } + + parquetObjs := []string{} + var newInfos []dvCom.DatasetInfo + + for _, info := range viewerCardData.DatasetInfos { + newSplits := []dvCom.Split{} + for _, split := range info.Splits { + if viewerReq != nil && viewerReq.Config == info.ConfigName && viewerReq.Split == split.Name { + for _, f := range split.Files { + parquetObjs = append(parquetObjs, fmt.Sprintf("lfs/%s", f.LfsRelativePath)) + } + } + newSplit := dvCom.Split{ + Name: split.Name, + NumExamples: split.NumExamples, + Files: nil, + Origins: nil, + } + newSplits = append(newSplits, newSplit) + } + info.Splits = newSplits + newInfos = append(newInfos, info) + } + viewerCardData.DatasetInfos = newInfos + + return &dvCom.CataLogRespone{ + Configs: viewerCardData.Configs, + DatasetInfos: viewerCardData.DatasetInfos, + Status: viewer.DataviewerJob.Status, + Logs: viewer.DataviewerJob.Logs, + }, parquetObjs, nil +} + +func (c *datasetViewerComponentImpl) getDatasetCatalog(ctx context.Context, req *dvCom.ViewParquetFileReq, calcTotal bool) (*dvCom.CardData, error) { + cardData, err := c.getRepoCardData(ctx, req, calcTotal) + if err == nil { + return cardData, nil + } + slog.Warn("cannot get card data for repo", slog.Any("req", req), slog.Any("error", err)) + cardData, err = c.autoGenerateCatalog(ctx, req, calcTotal) + if err != nil { + return nil, fmt.Errorf("failed to auto gen catalog, error: %w", err) + } + return cardData, nil +} + +func (c *datasetViewerComponentImpl) getRepoCardData(ctx context.Context, req *dvCom.ViewParquetFileReq, calcTotal bool) (*dvCom.CardData, error) { + getFileContentReq := gitserver.GetRepoInfoByPathReq{ + Namespace: req.Namespace, + Name: req.RepoName, + Ref: req.Branch, + Path: types.REPOCARD_FILENAME, + RepoType: types.DatasetRepo, + } + f, err := c.gitServer.GetRepoFileContents(ctx, getFileContentReq) + if err != nil { + return nil, fmt.Errorf("failed to get readme.md contents, cause:%w", err) + } + slog.Debug("getRepoCardData", slog.Any("f.Content", f.Content)) + decodedContent, err := base64.StdEncoding.DecodeString(f.Content) + if err != nil { + return nil, fmt.Errorf("failed to base64 decode readme.md contents, cause:%w", err) + } + decodedContentStr := string(decodedContent) + matches := dvCom.REG.FindStringSubmatch(decodedContentStr) + yamlString := "" + if len(matches) > 1 { + yamlString = matches[1] + } else { + return nil, fmt.Errorf("repo card yaml configs is empty") + } + + var card dvCom.CardData + err = yaml.Unmarshal([]byte(yamlString), &card) + if err != nil { + return nil, fmt.Errorf("failed to Unmarshal readme.md yaml contents, cause: %w, decodedContent: %v", err, yamlString) + } + slog.Debug("Unmarshal", slog.Any("card", card)) + if card.Configs == nil { + return nil, fmt.Errorf("repo card data configs is empty") + } + if calcTotal && card.DatasetInfos == nil { + card = c.generateCardDatasetInfo(ctx, req, card) + } + return &card, nil +} + +func (c *datasetViewerComponentImpl) generateCardDatasetInfo(ctx context.Context, req *dvCom.ViewParquetFileReq, card dvCom.CardData) dvCom.CardData { + var configs []dvCom.ConfigData + var infos []dvCom.DatasetInfo + var tree []string + for _, conf := range card.Configs { + var datafiles []dvCom.DataFiles + var splits []dvCom.Split + for _, datafile := range conf.DataFiles { + var newPath interface{} + reqFiles, hasWildCard := c.getPatternFileList(datafile.Path) + if len(reqFiles) > 0 { + newPath = reqFiles + } else { + slog.Warn("datafile.Path is not either string or []interface{})", slog.Any("datafile.Path", datafile.Path)) + newPath = datafile.Path + } + datafiles = append(datafiles, dvCom.DataFiles{Split: datafile.Split, Path: newPath}) + realReqFiles := reqFiles + if hasWildCard { + realReqFiles, tree = c.convertRealFiles(req, reqFiles, tree) + } + total := c.getFilesRowCount(ctx, req, realReqFiles) + splits = append(splits, dvCom.Split{Name: datafile.Split, NumExamples: total}) + } + configs = append(configs, dvCom.ConfigData{ConfigName: conf.ConfigName, DataFiles: datafiles}) + infos = append(infos, dvCom.DatasetInfo{ConfigName: conf.ConfigName, Splits: splits}) + } + return dvCom.CardData{Configs: configs, DatasetInfos: infos} +} + +func (c *datasetViewerComponentImpl) getPatternFileList(path interface{}) ([]string, bool) { + if path == nil { + return []string{}, false + } + var ( + files []string + hasWildCard bool + ) + hasWildCard = false + if slice, ok := path.([]interface{}); ok { + for _, v := range slice { + files = append(files, v.(string)) + if strings.HasSuffix(v.(string), dvCom.WILDCARD) { + hasWildCard = true + } + } + } else if slice, ok := path.([]string); ok { + files = slice + for _, v := range slice { + if strings.HasSuffix(v, dvCom.WILDCARD) { + hasWildCard = true + break + } + } + } else { + files = []string{path.(string)} + if strings.HasSuffix(path.(string), dvCom.WILDCARD) { + hasWildCard = true + } + } + return files, hasWildCard +} + +func (c *datasetViewerComponentImpl) convertRealFiles(req *dvCom.ViewParquetFileReq, splitFiles []string, tree []string) ([]string, []string) { + var err error + if len(tree) < 1 { + // skip get all tree + tree, err = hubCom.GetFilePaths(req.Namespace, req.RepoName, "", types.DatasetRepo, req.Branch, c.gitServer.GetRepoFileTree) + if err != nil { + slog.Error("Failed to get repo file paths", slog.Any("req", req), slog.Any("error", err)) + return splitFiles, tree + } + if tree == nil { + return splitFiles, tree + } + } + + var phyFiles []string + + for _, filePattern := range splitFiles { + if !strings.Contains(filePattern, dvCom.WILDCARD) { + phyFiles = append(phyFiles, filePattern) + } else { + fileReg, err := regexp.Compile(filePattern) + if err != nil { + slog.Warn("invalid regexp format", slog.Any("filePattern", filePattern), slog.Any("err", err)) + phyFiles = append(phyFiles, filePattern) + continue + } + for _, repoFile := range tree { + // repo file match like: test/test-* and end with .parquet + if fileReg.MatchString(repoFile) && workflows.IsValidParquetFile(repoFile) { + phyFiles = append(phyFiles, repoFile) + } + } + } + } + slog.Debug("convertRealFiles", slog.Any("splitFiles", splitFiles), slog.Any("phyFiles", phyFiles)) + return phyFiles, tree +} + +func (c *datasetViewerComponentImpl) autoGenerateCatalog(ctx context.Context, req *dvCom.ViewParquetFileReq, calcTotal bool) (*dvCom.CardData, error) { + tree, err := hubCom.GetFilePaths(req.Namespace, req.RepoName, "", types.DatasetRepo, req.Branch, c.gitServer.GetRepoFileTree) + if err != nil { + return nil, fmt.Errorf("failed to get repo tree, error: %w", err) + } + if tree == nil { + return nil, fmt.Errorf("failed to find any files") + } + slog.Debug("get tree", slog.Any("tree", tree)) + cardData := c.genDefaultCatalog(ctx, req, tree, calcTotal) + return &cardData, nil +} + +func (c *datasetViewerComponentImpl) genDefaultCatalog(ctx context.Context, req *dvCom.ViewParquetFileReq, tree []string, calcTotal bool) dvCom.CardData { + var ( + trainFiles []string + testFiles []string + valFiles []string + ) + var configData dvCom.ConfigData + var datasetInfo dvCom.DatasetInfo + for _, item := range tree { + if !workflows.IsValidParquetFile(item) { + continue + } + if workflows.IsTrainFile(strings.ToLower(item)) { + trainFiles = append(trainFiles, item) + } else if workflows.IsTestFile(strings.ToLower(item)) { + testFiles = append(testFiles, item) + } else if workflows.IsValidationFile(strings.ToLower(item)) { + valFiles = append(valFiles, item) + } + } + if len(trainFiles) > 0 { + total := 0 + if calcTotal { + total = c.getFilesRowCount(ctx, req, trainFiles) + } + configData.DataFiles = append(configData.DataFiles, dvCom.DataFiles{Split: workflows.TrainSplitName, Path: trainFiles}) + datasetInfo.Splits = append(datasetInfo.Splits, dvCom.Split{Name: workflows.TrainSplitName, NumExamples: total}) + } + if len(testFiles) > 0 { + total := 0 + if calcTotal { + total = c.getFilesRowCount(ctx, req, testFiles) + } + configData.DataFiles = append(configData.DataFiles, dvCom.DataFiles{Split: workflows.TestSplitName, Path: testFiles}) + datasetInfo.Splits = append(datasetInfo.Splits, dvCom.Split{Name: workflows.TestSplitName, NumExamples: total}) + } + if len(valFiles) > 0 { + total := 0 + if calcTotal { + total = c.getFilesRowCount(ctx, req, valFiles) + } + configData.DataFiles = append(configData.DataFiles, dvCom.DataFiles{Split: workflows.ValSplitName, Path: valFiles}) + datasetInfo.Splits = append(datasetInfo.Splits, dvCom.Split{Name: workflows.ValSplitName, NumExamples: total}) + } + configData.ConfigName = workflows.DefaultSubsetName + datasetInfo.ConfigName = workflows.DefaultSubsetName + var configList []dvCom.ConfigData + var dsInfoList []dvCom.DatasetInfo + if len(configData.DataFiles) > 0 { + configList = append(configList, configData) + dsInfoList = append(dsInfoList, datasetInfo) + } + return dvCom.CardData{Configs: configList, DatasetInfos: dsInfoList} +} + +func (c *datasetViewerComponentImpl) getFilesRowCount(ctx context.Context, req *dvCom.ViewParquetFileReq, files []string) int { + slog.Debug("getFilesRowCount", slog.Any("files", files)) + parquetObjs := c.getFilesOBJs(ctx, req, files) + if len(parquetObjs) < 1 { + return 0 + } + sqlReq := types.QueryReq{ + PageSize: 10, + PageIndex: 1, + Search: "", + Orderby: "", + } + + total, err := c.preader.RowCount(ctx, parquetObjs, sqlReq, true) + if err != nil { + slog.Warn("failed to get parquet row counts", slog.Any("parquetObjs", parquetObjs), slog.Any("error", err)) + } + return total +} + +func (c *datasetViewerComponentImpl) getFilesOBJs(ctx context.Context, req *dvCom.ViewParquetFileReq, files []string) []string { + var parquetObjs []string + for _, file := range files { + objName, err := c.getParquetObject(ctx, &dvCom.ViewParquetFileReq{ + Namespace: req.Namespace, + RepoName: req.RepoName, + Branch: req.Branch, + Path: file, + }) + if err != nil { + slog.Warn("failed to get parquet object name", slog.Any("req", req), slog.Any("error", err)) + continue + } + parquetObjs = append(parquetObjs, objName) + } + return parquetObjs +} + +func (c *datasetViewerComponentImpl) getParquetObject(ctx context.Context, req *dvCom.ViewParquetFileReq) (string, error) { + getFileContentReq := gitserver.GetRepoInfoByPathReq{ + Namespace: req.Namespace, + Name: req.RepoName, + Ref: req.Branch, + Path: req.Path, + RepoType: types.DatasetRepo, + } + f, err := c.gitServer.GetRepoFileContents(ctx, getFileContentReq) + if err != nil { + return "", fmt.Errorf("failed to get file contents,cause:%v", err) + } + if f.LfsRelativePath == "" { + return "", fmt.Errorf("file LfsRelativePath is empty for %s", getFileContentReq.Path) + } + return "lfs/" + f.LfsRelativePath, nil +} diff --git a/dataviewer/component/dataset_viewer_test.go b/dataviewer/component/dataset_viewer_test.go new file mode 100644 index 00000000..a15b117a --- /dev/null +++ b/dataviewer/component/dataset_viewer_test.go @@ -0,0 +1,267 @@ +package component + +import ( + "context" + "testing" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +func TestDatasetViewerComppnent_ViewParquetFile(t *testing.T) { + + ctx := context.TODO() + dc := initializeTestDatasetViewerComponent(ctx, t) + + repo := &database.Repository{DefaultBranch: "main"} + dc.mocks.stores.RepoMock().EXPECT().FindByPath(ctx, types.DatasetRepo, "ns", "repo").Return( + repo, nil, + ) + dc.mocks.components.repo.EXPECT().AllowReadAccessRepo(ctx, repo, "user").Return(true, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + Ref: "main", + Path: "foo", + RepoType: types.DatasetRepo, + }).Return(&types.File{ + LfsRelativePath: "a/b", + }, nil) + dc.mocks.preader.EXPECT().RowCount(mock.Anything, []string{"lfs/a/b"}, types.QueryReq{ + PageSize: 10, + PageIndex: 1, + }, true).Return(100, nil) + dc.mocks.preader.EXPECT().FetchRows(mock.Anything, []string{"lfs/a/b"}, types.QueryReq{ + PageSize: 10, + PageIndex: 1, + }, true).Return([]string{"a", "b"}, []string{"c", "d"}, [][]interface{}{ + {1, 2, 3}, + }, nil) + + resp, err := dc.ViewParquetFile(ctx, &dvCom.ViewParquetFileReq{ + Namespace: "ns", + RepoName: "repo", + Branch: "main", + Path: "foo", + Per: 10, + Page: 1, + CurrentUser: "user", + }) + require.Nil(t, err) + require.Equal(t, &dvCom.ViewParquetFileResp{ + Columns: []string{"a", "b"}, + ColumnsType: []string{"c", "d"}, + Rows: [][]interface{}{ + {1, 2, 3}, + }, + Total: 100, + }, resp) + +} + +func TestDatasetViewerComppnent_Rows(t *testing.T) { + ctx := context.TODO() + dc := initializeTestDatasetViewerComponent(ctx, t) + + repo := &database.Repository{DefaultBranch: "main"} + + dc.mocks.stores.RepoMock().EXPECT().FindByPath(ctx, types.DatasetRepo, "ns", "repo").Return( + repo, nil, + ) + dc.mocks.components.repo.EXPECT().AllowReadAccessRepo(ctx, repo, "user").Return(true, nil) + + dc.mocks.stores.ViewerMock().EXPECT().GetViewerByRepoID(ctx, int64(0)).Return(nil, nil) + + dc.mocks.gitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + Ref: "main", + Path: types.REPOCARD_FILENAME, + RepoType: types.DatasetRepo, + }).Return(&types.File{ + LfsRelativePath: "a/b", + Content: "LS0tCmNvbmZpZ3M6Ci0gY29uZmlnX25hbWU6ICJmb28iCiAgZGF0YV9maWxlczoKICAtIHNwbGl0OiB0cmFpbgogICAgcGF0aDogZm9vLy4qCi0gY29uZmlnX25hbWU6ICJiYXIiCiAgZGF0YV9maWxlczoKICAtIHNwbGl0OiB0cmFpbgpwYXRoOiBiYXIvLioKLS0tCg==", + }, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + Ref: "main", + Path: "foo/foobar.parquet", + RepoType: types.DatasetRepo, + }).Return(&types.File{ + LfsRelativePath: "a/b", + }, nil) + dc.mocks.preader.EXPECT().RowCount(mock.Anything, []string{"lfs/a/b"}, types.QueryReq{ + PageSize: 10, + PageIndex: 1, + }, true).Return(100, nil) + dc.mocks.preader.EXPECT().FetchRows(mock.Anything, []string{"lfs/a/b"}, types.QueryReq{ + PageSize: 10, + PageIndex: 1, + }, true).Return([]string{"a", "b"}, []string{"c", "d"}, [][]interface{}{ + {1, 2, 3}, + }, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileTree(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + + Ref: "main", + RepoType: types.DatasetRepo, + }).Return( + []*types.File{ + {Name: "foobar.parquet", Path: "foo/foobar.parquet"}, + }, nil, + ) + + resp, err := dc.Rows(ctx, &dvCom.ViewParquetFileReq{ + Namespace: "ns", + RepoName: "repo", + Branch: "main", + Path: "foo", + Per: 10, + Page: 1, + CurrentUser: "user", + }, types.DataViewerReq{Split: "train", Config: "foo"}) + require.Nil(t, err) + require.Equal(t, &dvCom.ViewParquetFileResp{ + Columns: []string{"a", "b"}, + ColumnsType: []string{"c", "d"}, + Rows: [][]interface{}{ + {1, 2, 3}, + }, + Total: 100, + }, resp) + +} + +func TestDatasetViewerComppnent_GetCatalog(t *testing.T) { + t.Run("has card data", func(t *testing.T) { + + ctx := context.TODO() + dc := initializeTestDatasetViewerComponent(ctx, t) + + repo := &database.Repository{DefaultBranch: "main"} + dc.mocks.stores.RepoMock().EXPECT().FindByPath(ctx, types.DatasetRepo, "ns", "repo").Return( + repo, nil, + ) + dc.mocks.components.repo.EXPECT().AllowReadAccessRepo(ctx, repo, "user").Return(true, nil) + dc.mocks.stores.ViewerMock().EXPECT().GetViewerByRepoID(ctx, int64(0)).Return(nil, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + Ref: "main", + Path: types.REPOCARD_FILENAME, + RepoType: types.DatasetRepo, + }).Return(&types.File{ + LfsRelativePath: "a/b", + Content: "LS0tCmNvbmZpZ3M6Ci0gY29uZmlnX25hbWU6ICJmb28iCiAgZGF0YV9maWxlczoKICAtIHNwbGl0OiB0cmFpbgogICAgcGF0aDogZm9vLy4qCi0gY29uZmlnX25hbWU6ICJiYXIiCiAgZGF0YV9maWxlczoKICAtIHNwbGl0OiB0cmFpbgpwYXRoOiBiYXIvLioKLS0tCg==", + }, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + Ref: "main", + Path: "foo/foobar.parquet", + RepoType: types.DatasetRepo, + }).Return(&types.File{ + LfsRelativePath: "a/b", + }, nil) + dc.mocks.preader.EXPECT().RowCount(mock.Anything, []string{"lfs/a/b"}, types.QueryReq{ + PageSize: 10, + PageIndex: 1, + }, true).Return(100, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileTree(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + + Ref: "main", + RepoType: types.DatasetRepo, + }).Return( + []*types.File{ + {Name: "foobar.parquet", Path: "foo/foobar.parquet"}, + }, nil, + ) + + data, err := dc.GetCatalog(ctx, &dvCom.ViewParquetFileReq{ + Namespace: "ns", + RepoName: "repo", + Branch: "main", + Path: "foo", + Per: 10, + Page: 1, + CurrentUser: "user", + }) + require.Nil(t, err) + require.Equal(t, &dvCom.CataLogRespone{ + Configs: []dvCom.ConfigData{ + {ConfigName: "foo", DataFiles: []dvCom.DataFiles{ + {Split: "train", Path: []string{"foo/.*"}}, + }}, {ConfigName: "bar", DataFiles: []dvCom.DataFiles{{Split: "train"}}}}, + DatasetInfos: []dvCom.DatasetInfo{ + {ConfigName: "foo", Splits: []dvCom.Split{{Name: "train", NumExamples: 100}}}, + {ConfigName: "bar", Splits: []dvCom.Split{{Name: "train", NumExamples: 0}}}}, + }, data) + }) + + t.Run("auto generate card data", func(t *testing.T) { + + ctx := context.TODO() + dc := initializeTestDatasetViewerComponent(ctx, t) + + repo := &database.Repository{DefaultBranch: "main"} + dc.mocks.stores.RepoMock().EXPECT().FindByPath(ctx, types.DatasetRepo, "ns", "repo").Return( + repo, nil, + ) + dc.mocks.components.repo.EXPECT().AllowReadAccessRepo(ctx, repo, "user").Return(true, nil) + dc.mocks.stores.ViewerMock().EXPECT().GetViewerByRepoID(ctx, int64(0)).Return(nil, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + Ref: "main", + Path: types.REPOCARD_FILENAME, + RepoType: types.DatasetRepo, + }).Return(&types.File{ + LfsRelativePath: "a/b", + Content: "xxx", + }, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + Ref: "main", + Path: "foo/train.parquet", + RepoType: types.DatasetRepo, + }).Return(&types.File{ + LfsRelativePath: "a/b", + }, nil) + dc.mocks.preader.EXPECT().RowCount(mock.Anything, []string{"lfs/a/b"}, types.QueryReq{ + PageSize: 10, + PageIndex: 1, + }, true).Return(100, nil) + dc.mocks.gitServer.EXPECT().GetRepoFileTree(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: "ns", + Name: "repo", + + Ref: "main", + RepoType: types.DatasetRepo, + }).Return( + []*types.File{ + {Name: "foobar.parquet", Path: "foo/train.parquet"}, + }, nil, + ) + + data, err := dc.GetCatalog(ctx, &dvCom.ViewParquetFileReq{ + Namespace: "ns", + RepoName: "repo", + Branch: "main", + Path: "foo", + Per: 10, + Page: 1, + CurrentUser: "user", + }) + require.Nil(t, err) + require.Equal(t, &dvCom.CataLogRespone{Configs: []dvCom.ConfigData{{ConfigName: "default", DataFiles: []dvCom.DataFiles{{Split: "train", Path: []string{"foo/train.parquet"}}}}}, DatasetInfos: []dvCom.DatasetInfo{{ConfigName: "default", Splits: []dvCom.Split{{Name: "train", NumExamples: 100}}}}}, data) + }) +} diff --git a/dataviewer/component/mocks_test.go b/dataviewer/component/mocks_test.go new file mode 100644 index 00000000..f716f163 --- /dev/null +++ b/dataviewer/component/mocks_test.go @@ -0,0 +1,65 @@ +package component + +import ( + "github.com/google/wire" + mock_accounting "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/accounting" + mock_deploy "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/deploy" + mock_git "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/git/gitserver" + mock_mirror "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/git/mirrorserver" + mock_preader "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/parquet" + mock_rpc "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/rpc" + mock_rsa "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/rsa" + mock_s3 "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/store/s3" + mock_component "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/component" + mock_mirror_queue "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/mirror/queue" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/parquet" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/tests" + hubCom "opencsg.com/csghub-server/component" +) + +type mockedComponents struct { + accounting *mock_component.MockAccountingComponent + repo *mock_component.MockRepoComponent + tag *mock_component.MockTagComponent + space *mock_component.MockSpaceComponent + runtimeArchitecture *mock_component.MockRuntimeArchitectureComponent + sensitive *mock_component.MockSensitiveComponent +} + +var MockedStoreSet = wire.NewSet( + tests.NewMockStores, +) + +type Mocks struct { + stores *tests.MockStores + components *mockedComponents + gitServer *mock_git.MockGitServer + userSvcClient *mock_rpc.MockUserSvcClient + s3Client *mock_s3.MockClient + mirrorServer *mock_mirror.MockMirrorServer + mirrorQueue *mock_mirror_queue.MockPriorityQueue + deployer *mock_deploy.MockDeployer + accountingClient *mock_accounting.MockAccountingClient + preader *mock_preader.MockReader + moderationClient *mock_rpc.MockModerationSvcClient + rsaReader *mock_rsa.MockKeysReader +} + +func ProvideTestConfig() *config.Config { + return &config.Config{} +} + +func NewTestDatasetViewerComponent(stores *tests.MockStores, cfg *config.Config, repoComponent hubCom.RepoComponent, gitServer gitserver.GitServer, preader parquet.Reader) *datasetViewerComponentImpl { + return &datasetViewerComponentImpl{ + cfg: cfg, + repoStore: stores.Repo, + repoComponent: repoComponent, + gitServer: gitServer, + preader: preader, + viewerStore: stores.ViewerStore, + } +} + +var DatasetViewerComponentSet = wire.NewSet(NewTestDatasetViewerComponent) diff --git a/dataviewer/component/utils_test.go b/dataviewer/component/utils_test.go new file mode 100644 index 00000000..c902621d --- /dev/null +++ b/dataviewer/component/utils_test.go @@ -0,0 +1,79 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run -mod=mod github.com/google/wire/cmd/wire + +package component + +import ( + "context" + + "github.com/stretchr/testify/mock" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/accounting" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/deploy" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/git/mirrorserver" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/parquet" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/rpc" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/rsa" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/store/s3" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/component" + "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/mirror/queue" + "opencsg.com/csghub-server/common/tests" +) + +func initializeTestDatasetViewerComponent(ctx context.Context, t interface { + Cleanup(func()) + mock.TestingT +}) *testDatasetViewerWithMocks { + mockStores := tests.NewMockStores(t) + config := ProvideTestConfig() + mockRepoComponent := component.NewMockRepoComponent(t) + mockGitServer := gitserver.NewMockGitServer(t) + mockReader := parquet.NewMockReader(t) + componentDatasetViewerComponentImpl := NewTestDatasetViewerComponent(mockStores, config, mockRepoComponent, mockGitServer, mockReader) + mockAccountingComponent := component.NewMockAccountingComponent(t) + mockTagComponent := component.NewMockTagComponent(t) + mockSpaceComponent := component.NewMockSpaceComponent(t) + mockRuntimeArchitectureComponent := component.NewMockRuntimeArchitectureComponent(t) + mockSensitiveComponent := component.NewMockSensitiveComponent(t) + componentMockedComponents := &mockedComponents{ + accounting: mockAccountingComponent, + repo: mockRepoComponent, + tag: mockTagComponent, + space: mockSpaceComponent, + runtimeArchitecture: mockRuntimeArchitectureComponent, + sensitive: mockSensitiveComponent, + } + mockUserSvcClient := rpc.NewMockUserSvcClient(t) + mockClient := s3.NewMockClient(t) + mockMirrorServer := mirrorserver.NewMockMirrorServer(t) + mockPriorityQueue := queue.NewMockPriorityQueue(t) + mockDeployer := deploy.NewMockDeployer(t) + mockAccountingClient := accounting.NewMockAccountingClient(t) + mockModerationSvcClient := rpc.NewMockModerationSvcClient(t) + mockKeysReader := rsa.NewMockKeysReader(t) + mocks := &Mocks{ + stores: mockStores, + components: componentMockedComponents, + gitServer: mockGitServer, + userSvcClient: mockUserSvcClient, + s3Client: mockClient, + mirrorServer: mockMirrorServer, + mirrorQueue: mockPriorityQueue, + deployer: mockDeployer, + accountingClient: mockAccountingClient, + preader: mockReader, + moderationClient: mockModerationSvcClient, + rsaReader: mockKeysReader, + } + componentTestDatasetViewerWithMocks := &testDatasetViewerWithMocks{ + datasetViewerComponentImpl: componentDatasetViewerComponentImpl, + mocks: mocks, + } + return componentTestDatasetViewerWithMocks +} + +type testDatasetViewerWithMocks struct { + *datasetViewerComponentImpl + mocks *Mocks +} diff --git a/dataviewer/handler/callback.go b/dataviewer/handler/callback.go new file mode 100644 index 00000000..dfa0f241 --- /dev/null +++ b/dataviewer/handler/callback.go @@ -0,0 +1,60 @@ +package handler + +import ( + "log/slog" + + "github.com/gin-gonic/gin" + "opencsg.com/csghub-server/api/httpbase" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/temporal" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + "opencsg.com/csghub-server/common/utils/common" + dvCom "opencsg.com/csghub-server/dataviewer/common" + "opencsg.com/csghub-server/dataviewer/component" +) + +type CallbackHandler struct { + callbackComp component.CallbackComponent +} + +func NewCallBackHandler(cfg *config.Config, tc temporal.Client, gs gitserver.GitServer) (*CallbackHandler, error) { + callbackComp, err := component.NewCallbackComponent(cfg, tc, gs) + if err != nil { + return nil, err + } + return &CallbackHandler{ + callbackComp: callbackComp, + }, nil +} + +func (h *CallbackHandler) Callback(ctx *gin.Context) { + currentUser := httpbase.GetCurrentUser(ctx) + namespace, name, err := common.GetNamespaceAndNameFromContext(ctx) + if err != nil { + slog.Error("Bad repo request format", "error", err) + httpbase.BadRequest(ctx, err.Error()) + return + } + branch := ctx.Param("branch") + + req := types.UpdateViewerReq{ + Namespace: namespace, + Name: name, + Branch: branch, + CurrentUser: currentUser, + RepoType: types.DatasetRepo, + } + + if req.Branch == dvCom.ParquetBranch || req.Branch == dvCom.DuckdbBranch { + httpbase.OK(ctx, nil) + } + + resp, err := h.callbackComp.TriggerDataviewUpdateWorkflow(ctx.Request.Context(), req) + if err != nil { + slog.Error("fail to trigger workflow", slog.Any("req", req), slog.Any("error", err)) + httpbase.BadRequest(ctx, err.Error()) + return + } + httpbase.OK(ctx, resp) +} diff --git a/dataviewer/handler/dataset_viewer.go b/dataviewer/handler/dataset_viewer.go new file mode 100644 index 00000000..33cc6176 --- /dev/null +++ b/dataviewer/handler/dataset_viewer.go @@ -0,0 +1,218 @@ +package handler + +import ( + "fmt" + "log/slog" + "regexp" + "strings" + + "github.com/gin-gonic/gin" + "opencsg.com/csghub-server/api/httpbase" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + "opencsg.com/csghub-server/common/utils/common" + dvCom "opencsg.com/csghub-server/dataviewer/common" + "opencsg.com/csghub-server/dataviewer/component" +) + +type DatasetViewerHandler struct { + c component.DatasetViewerComponent +} + +func NewDatasetViewerHandler(cfg *config.Config, gs gitserver.GitServer) (*DatasetViewerHandler, error) { + dvc, err := component.NewDatasetViewerComponent(cfg, gs) + if err != nil { + return nil, err + } + + return &DatasetViewerHandler{ + c: dvc, + }, nil +} + +// GetDatasetDemoData godoc +// @Security ApiKey +// @Summary Get the demo data of the dataset +// @Description get the demo data of the dataset +// @Tags Dataset +// @Accept json +// @Produce json +// @Param namespace path string true "namespace" +// @Parsm name path string true "name" +// @Param file_path path string true "file_path" +// @Param per query int false "per" default(50) +// @Param page query int false "per page" default(1) +// @Success 200 {object} types.Response{} "OK" +// @Failure 400 {object} types.APIBadRequest "Bad request" +// @Failure 500 {object} types.APIInternalServerError "Internal server error" +// @Router /datasets/{namespace}/{name}/viewer/{file_path} [get] +func (h *DatasetViewerHandler) View(ctx *gin.Context) { + currentUser := httpbase.GetCurrentUser(ctx) + namespace, name, err := common.GetNamespaceAndNameFromContext(ctx) + if err != nil { + slog.Error("Bad repo request format", "error", err) + httpbase.BadRequest(ctx, err.Error()) + return + } + per, page, err := common.GetPerAndPageFromContext(ctx) + if err != nil { + slog.Error("Bad paging request format", "error", err) + httpbase.BadRequest(ctx, err.Error()) + return + } + req := new(dvCom.ViewParquetFileReq) + req.Namespace = namespace + req.RepoName = name + req.Path = ctx.Param("file_path") + req.Per = per + req.Page = page + req.CurrentUser = currentUser + + resp, err := h.c.ViewParquetFile(ctx.Request.Context(), req) + if err != nil { + slog.Error("Failed to view parquet file", "error", err) + httpbase.ServerError(ctx, err) + return + } + + httpbase.OK(ctx, resp) +} + +// GetDatasetCatalog godoc +// @Security ApiKey +// @Summary Get catalog of the dataset +// @Description get catalog of the dataset +// @Tags Dataset +// @Accept json +// @Produce json +// @Param namespace path string true "namespace" +// @Parsm name path string true "name" +// @Success 200 {object} types.Response{} "OK" +// @Failure 400 {object} types.APIBadRequest "Bad request" +// @Failure 500 {object} types.APIInternalServerError "Internal server error" +// @Router /datasets/{namespace}/{name}/dataviewer/catalog [get] +func (h *DatasetViewerHandler) Catalog(ctx *gin.Context) { + currentUser := httpbase.GetCurrentUser(ctx) + namespace, name, err := common.GetNamespaceAndNameFromContext(ctx) + if err != nil { + slog.Error("Bad request format", "error", err) + httpbase.BadRequest(ctx, err.Error()) + return + } + req := new(dvCom.ViewParquetFileReq) + req.Namespace = namespace + req.RepoName = name + req.CurrentUser = currentUser + + catalog, err := h.c.GetCatalog(ctx.Request.Context(), req) + if err != nil { + slog.Error("Failed to get dataset catalog", slog.Any("req", req), slog.Any("error", err)) + httpbase.ServerError(ctx, err) + return + } + httpbase.OK(ctx, catalog) +} + +// GetDatasetCatalog godoc +// @Security ApiKey +// @Summary Get catalog of the dataset +// @Description get catalog of the dataset +// @Tags Dataset +// @Accept json +// @Produce json +// @Param namespace path string true "namespace" +// @Parsm name path string true "name" +// @Param config query string true "config" +// @Param split query string true "split" +// @Param search query string false "search" +// @Param where query string false "where" +// @Param orderby query string false "orderby" +// @Param per query int false "per" default(50) +// @Param page query int false "per page" default(1) +// @Success 200 {object} types.Response{} "OK" +// @Failure 400 {object} types.APIBadRequest "Bad request" +// @Failure 500 {object} types.APIInternalServerError "Internal server error" +// @Router /datasets/{namespace}/{name}/dataviewer/rows [get] +func (h *DatasetViewerHandler) Rows(ctx *gin.Context) { + currentUser := httpbase.GetCurrentUser(ctx) + namespace, name, err := common.GetNamespaceAndNameFromContext(ctx) + if err != nil { + slog.Error("Bad repo request format", "error", err) + httpbase.BadRequest(ctx, err.Error()) + return + } + + per, page, err := common.GetPerAndPageFromContext(ctx) + if err != nil { + slog.Error("Bad paging request format", "error", err) + httpbase.BadRequest(ctx, err.Error()) + return + } + + // config=SelfRC&split=train + config := ctx.Query("config") + split := ctx.Query("split") + search := ctx.Query("search") + where := ctx.Query("where") + orderby := ctx.Query("orderby") + if config == "" || split == "" { + slog.Error("Bad view rows request format") + httpbase.BadRequest(ctx, "Bad view rows request format") + return + } + var viewReq types.DataViewerReq + viewReq.Config = config + viewReq.Split = split + viewReq.Search = search + viewReq.Where = where + viewReq.Orderby = orderby + + req := new(dvCom.ViewParquetFileReq) + req.Namespace = namespace + req.RepoName = name + req.CurrentUser = currentUser + req.Per = per + req.Page = page + + slog.Debug("hander.rows viewerReq", slog.Any("viewReq", viewReq)) + err = validateQueryParameter(where, "where") + if err != nil { + slog.Error("invalid character in parameter where", slog.Any("req", req), slog.Any("viewReq", viewReq), slog.Any("error", err)) + httpbase.ServerError(ctx, err) + return + } + + err = validateQueryParameter(orderby, "orderby") + if err != nil { + slog.Error("invalid character in parameter orderby", slog.Any("req", req), slog.Any("viewReq", viewReq), slog.Any("error", err)) + httpbase.ServerError(ctx, err) + return + } + + err = validateQueryParameter(search, "search") + if err != nil { + slog.Error("invalid character in parameter search", slog.Any("req", req), slog.Any("viewReq", viewReq), slog.Any("error", err)) + httpbase.ServerError(ctx, err) + return + } + + rows, err := h.c.Rows(ctx.Request.Context(), req, viewReq) + if err != nil { + slog.Error("Failed to get dataset rows", slog.Any("req", req), slog.Any("viewReq", viewReq), slog.Any("error", err)) + httpbase.ServerError(ctx, err) + return + } + + httpbase.OK(ctx, rows) +} + +func validateQueryParameter(parameterValue string, parameterName string) error { + SQLInvalidSymbols := []string{";", "--", `/\*`, `\*/`} + SQLInvalidSymbolsPattern := regexp.MustCompile(fmt.Sprintf("(?:%s)", strings.Join(SQLInvalidSymbols, "|"))) + + if SQLInvalidSymbolsPattern.MatchString(parameterValue) { + return fmt.Errorf("invalid character in %s", parameterName) + } + return nil +} diff --git a/dataviewer/router/api.go b/dataviewer/router/api.go new file mode 100644 index 00000000..a80587fe --- /dev/null +++ b/dataviewer/router/api.go @@ -0,0 +1,105 @@ +package router + +import ( + "fmt" + + "github.com/gin-contrib/pprof" + "github.com/gin-gonic/gin" + "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin" + "opencsg.com/csghub-server/api/middleware" + "opencsg.com/csghub-server/builder/git" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/temporal" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/dataviewer/handler" + "opencsg.com/csghub-server/dataviewer/workflows" +) + +type DataViewerService struct { + viewerHandler *handler.DatasetViewerHandler + callbackHandler *handler.CallbackHandler + gitServer gitserver.GitServer +} + +func NewDataViewerRouter(config *config.Config, tc temporal.Client) (*gin.Engine, error) { + r := gin.New() + if config.Instrumentation.OTLPEndpoint != "" { + r.Use(otelgin.Middleware("csghub-dataviewer")) + } + r.Use(gin.Recovery()) + r.Use(middleware.Log(config)) + needAPIKey := middleware.OnlyAPIKeyAuthenticator(config) + + //add router for golang pprof + debugGroup := r.Group("/debug", needAPIKey) + pprof.RouteRegister(debugGroup, "pprof") + + r.Use(middleware.Authenticator(config)) + apiGroup := r.Group("/api/v1") + datasetsGrp := apiGroup.Group("/datasets/:namespace/:name") + + dvService, err := createHandlers(config, tc) + if err != nil { + return nil, fmt.Errorf("creating handlers error: %w", err) + } + + activity, err := workflows.NewDataViewerActivity(config, dvService.gitServer) + if err != nil { + return nil, fmt.Errorf("failed to create new data viewer activity: %w", err) + } + + err = workflows.BuildDataViewerRunWorker(tc, config, activity) + if err != nil { + return nil, fmt.Errorf("building dataviewer run workers error: %w", err) + } + + createDataViewerRoutes(datasetsGrp, dvService.viewerHandler) + createCallbackRoutes(datasetsGrp, dvService.callbackHandler) + + return r, nil +} + +func createHandlers(cfg *config.Config, tc temporal.Client) ( + dataViewerService *DataViewerService, + err error, +) { + dataViewerService = &DataViewerService{} + gs, err := git.NewGitServer(cfg) + if err != nil { + err = fmt.Errorf("failed to create git server cause: %w", err) + return + } + dataViewerService.gitServer = gs + dataViewerService.viewerHandler, err = handler.NewDatasetViewerHandler(cfg, gs) + if err != nil { + err = fmt.Errorf("creating dataset viewer handler: %w", err) + return + } + + dataViewerService.callbackHandler, err = handler.NewCallBackHandler(cfg, tc, gs) + if err != nil { + err = fmt.Errorf("creating viewer callback handler: %w", err) + return + } + + return +} + +func createDataViewerRoutes(datasetsGrp *gin.RouterGroup, dsViewerHandler *handler.DatasetViewerHandler) { + fileViewerGrp := datasetsGrp.Group("/viewer") + { + fileViewerGrp.GET("/*file_path", dsViewerHandler.View) + } + dataViewerGrp := datasetsGrp.Group("/dataviewer") + { + dataViewerGrp.GET("/catalog", dsViewerHandler.Catalog) + dataViewerGrp.GET("/rows", dsViewerHandler.Rows) + } +} + +func createCallbackRoutes(datasetsGrp *gin.RouterGroup, dsCallbackHandler *handler.CallbackHandler) { + callbackGrp := datasetsGrp.Group("/callback") + { + callbackGrp.POST("/:branch", dsCallbackHandler.Callback) + } +} diff --git a/dataviewer/workflows/activity.go b/dataviewer/workflows/activity.go new file mode 100644 index 00000000..4dc174f5 --- /dev/null +++ b/dataviewer/workflows/activity.go @@ -0,0 +1,850 @@ +package workflows + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "io" + "log/slog" + "net/http" + "net/url" + "os" + "path" + "path/filepath" + "sort" + "strconv" + "strings" + "time" + + "github.com/minio/minio-go/v7" + "go.temporal.io/sdk/activity" + "gopkg.in/yaml.v2" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/git/gitserver/gitea" + "opencsg.com/csghub-server/builder/parquet" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/builder/store/s3" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +type DataViewerActivity interface { + BeginViewerJob(ctx context.Context) error + GetCardFromReadme(ctx context.Context, req types.UpdateViewerReq) (*dvCom.CardData, error) + ScanRepoFiles(ctx context.Context, scanParam dvCom.ScanRepoFileReq) (*dvCom.RepoFilesClass, error) + DetermineCardData(ctx context.Context, determineParam dvCom.DetermineCardReq) (*dvCom.CardData, error) + CheckIfNeedRebuild(ctx context.Context, checkParam dvCom.CheckBuildReq) (bool, error) + CreateParquetBranch(ctx context.Context, req types.UpdateViewerReq) (string, error) + CopyParquetFiles(ctx context.Context, copyReq dvCom.CopyParquetReq) (*dvCom.CardData, error) + DownloadSplitFiles(ctx context.Context, downloadReq dvCom.DownloadFileReq) (*dvCom.DownloadCard, error) + ConvertToParquetFiles(ctx context.Context, convertReq dvCom.ConvertReq) error + UploadParquetFiles(ctx context.Context, uploadReq dvCom.UploadParquetReq) (*dvCom.CardData, error) + UpdateCardData(ctx context.Context, cardReq dvCom.UpdateCardReq) error + CleanUp(ctx context.Context, req types.UpdateViewerReq) error + UpdateWorkflowStatus(ctx context.Context, status dvCom.UpdateWorkflowStatusReq) error +} + +type dataViewerActivityImpl struct { + gitServer gitserver.GitServer + s3Client s3.Client + cfg *config.Config + viewerStore database.DataviewerStore +} + +func NewDataViewerActivity(cfg *config.Config, gs gitserver.GitServer) (DataViewerActivity, error) { + s3Client, err := s3.NewMinio(cfg) + if err != nil { + return nil, fmt.Errorf("fail to init s3 client for data viewer, error: %w", err) + } + return &dataViewerActivityImpl{ + gitServer: gs, + s3Client: s3Client, + cfg: cfg, + viewerStore: database.NewDataviewerStore(), + }, nil +} + +func (dva *dataViewerActivityImpl) BeginViewerJob(ctx context.Context) error { + wfCtx := activity.GetInfo(ctx) + workflowID := wfCtx.WorkflowExecution.ID + runID := wfCtx.WorkflowExecution.RunID + job, err := dva.viewerStore.GetJob(ctx, workflowID) + if err != nil { + return fmt.Errorf("get viewer job by workflowID %s for beginning, cause: %w", workflowID, err) + } + + job.RunID = runID + job.Status = types.WorkflowRunning + job.Logs = types.WorkflowMsgRunning + job.StartTime = time.Now() + + _, err = dva.viewerStore.UpdateJob(ctx, *job) + if err != nil { + slog.Error("update viewer job info for beginning", slog.Any("job", job), slog.Any("error", err)) + return fmt.Errorf("update viewer job info by workflowID %s for beginning, cause: %w", workflowID, err) + } + return nil +} + +func (dva *dataViewerActivityImpl) GetCardFromReadme(ctx context.Context, req types.UpdateViewerReq) (*dvCom.CardData, error) { + fileReq := gitserver.GetRepoInfoByPathReq{ + Namespace: req.Namespace, + Name: req.Name, + Ref: req.Branch, + Path: types.REPOCARD_FILENAME, + RepoType: req.RepoType, + } + f, err := dva.gitServer.GetRepoFileContents(context.Background(), fileReq) + if err != nil { + return nil, fmt.Errorf("get %s repo %s/%s branch %s file %s content error: %w", fileReq.RepoType, fileReq.Namespace, fileReq.Name, fileReq.Ref, fileReq.Path, err) + } + slog.Debug("getRepoCardData", slog.Any("f.Content", f.Content)) + decodedContent, err := base64.StdEncoding.DecodeString(f.Content) + if err != nil { + return nil, fmt.Errorf("decode %s repo %s/%s branch %s file %s content, error: %w", fileReq.RepoType, fileReq.Namespace, fileReq.Name, fileReq.Ref, fileReq.Path, err) + } + matches := dvCom.REG.FindStringSubmatch(string(decodedContent)) + yamlString := "" + if len(matches) > 1 { + yamlString = matches[1] + } else { + return nil, fmt.Errorf("%s repo %s/%s branch %s card yaml config is empty due to invalid content", fileReq.RepoType, fileReq.Namespace, fileReq.Name, fileReq.Ref) + } + + var card dvCom.CardData + err = yaml.Unmarshal([]byte(yamlString), &card) + if err != nil { + return nil, fmt.Errorf("unmarshal %s repo %s/%s branch %s yaml error: %w, decoded content: %s", fileReq.RepoType, fileReq.Namespace, fileReq.Name, fileReq.Ref, err, yamlString) + } + return &card, nil +} + +func (dva *dataViewerActivityImpl) ScanRepoFiles(ctx context.Context, scanParam dvCom.ScanRepoFileReq) (*dvCom.RepoFilesClass, error) { + repoReq := dvCom.RepoFilesReq{ + Namespace: scanParam.Req.Namespace, + RepoName: scanParam.Req.Name, + RepoType: scanParam.Req.RepoType, + Ref: scanParam.Req.Branch, + Folder: "", + GSTree: dva.gitServer.GetRepoFileTree, + } + fileClass := dvCom.RepoFilesClass{ + AllFiles: make(map[string]*types.File), + ParquetFiles: make(map[string]*types.File), + JsonlFiles: make(map[string]*types.File), + CsvFiles: make(map[string]*types.File), + } + err := GetFilePaths(repoReq, &fileClass, scanParam.MaxFileSize) + if err != nil { + return nil, fmt.Errorf("scan repo file error: %w", err) + } + return &fileClass, nil +} + +func (dva *dataViewerActivityImpl) autoBuildCardData(card *dvCom.CardData, sortKeys []string, targetFiles map[string]*types.File) { + var ( + trainFiles []string + testFiles []string + valFiles []string + otherFiles []string + + trainFileObjects []dvCom.FileObject + testFileObjects []dvCom.FileObject + valFileObjects []dvCom.FileObject + otherFileObjects []dvCom.FileObject + ) + for _, path := range sortKeys { + file, exists := targetFiles[path] + if !exists { + continue + } + if IsTrainFile(path) { + trainFiles = append(trainFiles, path) + trainFileObjects = append(trainFileObjects, TransferFileObject(file, DefaultSubsetName, TrainSplitName)) + } else if IsTestFile(path) { + testFiles = append(testFiles, path) + testFileObjects = append(testFileObjects, TransferFileObject(file, DefaultSubsetName, TestSplitName)) + } else if IsValidationFile(path) { + valFiles = append(valFiles, path) + valFileObjects = append(valFileObjects, TransferFileObject(file, DefaultSubsetName, ValSplitName)) + } else { + otherFiles = append(otherFiles, path) + otherFileObjects = append(otherFileObjects, TransferFileObject(file, DefaultSubsetName, OtherSplitName)) + } + } + var configData dvCom.ConfigData + var datasetInfo dvCom.DatasetInfo + if len(trainFiles) > 0 { + configData.DataFiles = append(configData.DataFiles, + dvCom.DataFiles{Split: TrainSplitName, Path: trainFiles}, + ) + datasetInfo.Splits = append(datasetInfo.Splits, + dvCom.Split{Name: TrainSplitName, NumExamples: 0, Origins: trainFileObjects}, + ) + } + if len(testFiles) > 0 { + configData.DataFiles = append(configData.DataFiles, + dvCom.DataFiles{Split: TestSplitName, Path: testFiles}, + ) + datasetInfo.Splits = append(datasetInfo.Splits, + dvCom.Split{Name: TestSplitName, NumExamples: 0, Origins: testFileObjects}, + ) + } + if len(valFiles) > 0 { + configData.DataFiles = append(configData.DataFiles, + dvCom.DataFiles{Split: ValSplitName, Path: valFiles}, + ) + datasetInfo.Splits = append(datasetInfo.Splits, + dvCom.Split{Name: ValSplitName, NumExamples: 0, Origins: valFileObjects}, + ) + } + if len(otherFiles) > 0 { + configData.DataFiles = append(configData.DataFiles, + dvCom.DataFiles{Split: OtherSplitName, Path: otherFiles}, + ) + datasetInfo.Splits = append(datasetInfo.Splits, + dvCom.Split{Name: OtherSplitName, NumExamples: 0, Origins: otherFileObjects}, + ) + } + if len(configData.DataFiles) > 0 { + configData.ConfigName = DefaultSubsetName + datasetInfo.ConfigName = DefaultSubsetName + card.Configs = append(card.Configs, configData) + card.DatasetInfos = append(card.DatasetInfos, datasetInfo) + } +} + +func (dva *dataViewerActivityImpl) fillUpCardData(card *dvCom.CardData, sortKeys []string, targetFiles map[string]*types.File) *dvCom.CardData { + var configs []dvCom.ConfigData + var infos []dvCom.DatasetInfo + for _, conf := range card.Configs { + var datafiles []dvCom.DataFiles + var splits []dvCom.Split + for _, datafile := range conf.DataFiles { + var newPath interface{} + reqFiles := GetPatternFileList(datafile.Path) + if len(reqFiles) > 0 { + newPath = reqFiles + } else { + slog.Warn("datafile.Path is not either string or []interface{})", slog.Any("datafile.Path", datafile.Path)) + newPath = datafile.Path + } + datafiles = append(datafiles, dvCom.DataFiles{Split: datafile.Split, Path: newPath}) + realReqFiles := ConvertRealFiles(reqFiles, sortKeys, targetFiles, conf.ConfigName, datafile.Split) + splits = append(splits, dvCom.Split{Name: datafile.Split, NumExamples: 0, Origins: realReqFiles}) + } + configs = append(configs, dvCom.ConfigData{ConfigName: conf.ConfigName, DataFiles: datafiles}) + infos = append(infos, dvCom.DatasetInfo{ConfigName: conf.ConfigName, Splits: splits}) + } + return &dvCom.CardData{Configs: configs, DatasetInfos: infos} +} + +func (dva *dataViewerActivityImpl) DetermineCardData(ctx context.Context, determineParam dvCom.DetermineCardReq) (*dvCom.CardData, error) { + var scopeFiles map[string]*types.File + if determineParam.RepoDataType == RepoParquetData { + scopeFiles = determineParam.Class.ParquetFiles + } else if determineParam.RepoDataType == RepoJsonData { + scopeFiles = determineParam.Class.JsonlFiles + } else if determineParam.RepoDataType == RepoCsvData { + scopeFiles = determineParam.Class.CsvFiles + } + if scopeFiles == nil || len(scopeFiles) < 1 { + slog.Warn("no target valid files found", slog.Any("card", determineParam.Card)) + return nil, nil + } + + keys := make([]string, 0, len(scopeFiles)) + for key := range scopeFiles { + keys = append(keys, key) + } + sort.Strings(keys) + + if determineParam.Card.Configs == nil { + dva.autoBuildCardData(&determineParam.Card, keys, scopeFiles) + return &determineParam.Card, nil + } else { + newCard := dva.fillUpCardData(&determineParam.Card, keys, scopeFiles) + return newCard, nil + } +} + +func (dva *dataViewerActivityImpl) CheckIfNeedRebuild(ctx context.Context, checkParam dvCom.CheckBuildReq) (bool, error) { + if checkParam.Card.Configs == nil { + slog.Warn("card configs is nil, no need to rebuild", slog.Any("req", checkParam.Req), slog.Any("card", checkParam.Card)) + return false, nil + } + viewer, err := dva.viewerStore.GetViewerByRepoID(ctx, checkParam.Req.RepoID) + if err != nil { + slog.Error("get viewer for compare card", slog.Any("req", checkParam.Req), + slog.Any("repo id", checkParam.Req.RepoID), slog.Any("error", err)) + return true, nil + } + if viewer == nil { + return true, nil + } + newMD5 := GetCardDataMD5(checkParam.Card) + if viewer.DataviewerJob.CardMD5 == newMD5 { + slog.Warn("card data md5 not changed, no need to rebuild", slog.Any("req", checkParam.Req), + slog.Any("card", checkParam.Card), slog.Any("newMD5", newMD5)) + return false, nil + } + return true, nil +} + +func (dva *dataViewerActivityImpl) CreateParquetBranch(ctx context.Context, req types.UpdateViewerReq) (string, error) { + findReq := gitserver.GetBranchReq{ + Namespace: req.Namespace, + Name: req.Name, + Ref: dvCom.ParquetBranch, + RepoType: req.RepoType, + } + branch, err := dva.gitServer.GetRepoBranchByName(ctx, findReq) + if err != nil { + slog.Warn("get branch by name", slog.Any("branch", findReq.Ref), slog.Any("error", err)) + } + if err == nil && branch != nil { + deleteReq := gitserver.DeleteBranchReq{ + Namespace: req.Namespace, + Name: req.Name, + Ref: findReq.Ref, + RepoType: req.RepoType, + Username: GitDefaultUserName, + Email: GitDefaultUserEmail, + } + err = dva.gitServer.DeleteRepoBranch(ctx, deleteReq) + if err != nil { + slog.Error("failed to delete branch", slog.Any("req", req), slog.Any("req", req), slog.Any("err", err)) + return branch.Name, fmt.Errorf("delete branch %s error: %w", findReq.Ref, err) + } + } + + // Create .gitattributes file in new branch + createReq := &types.CreateFileReq{ + Username: GitDefaultUserName, + Email: GitDefaultUserEmail, + Message: "create branch", + Content: base64.StdEncoding.EncodeToString([]byte(types.DatasetGitattributesContent)), + NewBranch: findReq.Ref, + Namespace: req.Namespace, + Name: req.Name, + FilePath: types.GitattributesFileName, + RepoType: req.RepoType, + } + + err = dva.gitServer.CreateRepoFile(createReq) + if err != nil { + slog.Error("failed to create .gitattributes file in branch", slog.Any("branch", createReq.NewBranch), slog.Any("req", req), slog.Any("error", err)) + return "", fmt.Errorf("failed to create .gitattributes file in branch %s, cause: %w", createReq.NewBranch, err) + } + return createReq.NewBranch, nil +} + +func (dva *dataViewerActivityImpl) CopyParquetFiles(ctx context.Context, copyReq dvCom.CopyParquetReq) (*dvCom.CardData, error) { + r, err := parquet.NewS3Reader(ctx, dva.cfg) + if err != nil { + return nil, fmt.Errorf("failed to create duckdb reader, cause: %w", err) + } + cardData := dvCom.CardData{} + var datasetInfos []dvCom.DatasetInfo + for _, info := range copyReq.ComputedCardData.DatasetInfos { + newInfo := dvCom.DatasetInfo{} + newSplits := []dvCom.Split{} + for _, split := range info.Splits { + newSplit := dvCom.Split{} + newFiles := []dvCom.FileObject{} + objectNames := []string{} + count := 0 + if split.Origins != nil { + for idx, orginfile := range split.Origins { + getFileContentReq := gitserver.GetRepoInfoByPathReq{ + Namespace: copyReq.Req.Namespace, + Name: copyReq.Req.Name, + Ref: copyReq.Req.Branch, + Path: orginfile.RepoFile, + RepoType: copyReq.Req.RepoType, + } + f, err := dva.gitServer.GetRepoFileContents(context.Background(), getFileContentReq) + if err != nil { + slog.Error("failed to get file content", slog.Any("file", orginfile.RepoFile), + slog.Any("branch", copyReq.Req.Branch), slog.Any("req", copyReq.Req), slog.Any("error", err)) + return nil, fmt.Errorf("failed to get file %s content in branch %s, cause: %w", orginfile.RepoFile, + copyReq.Req.Branch, err) + } + newFileName := fmt.Sprintf("%s/%s/%05d.parquet", info.ConfigName, split.Name, idx) + createReq := &types.CreateFileReq{ + Username: GitDefaultUserName, + Email: GitDefaultUserEmail, + Message: fmt.Sprintf("submit %s file", newFileName), + Content: f.Content, + Branch: copyReq.NewBranch, + Namespace: copyReq.Req.Namespace, + Name: copyReq.Req.Name, + FilePath: newFileName, + RepoType: copyReq.Req.RepoType, + } + err = dva.gitServer.CreateRepoFile(createReq) + if err != nil { + slog.Error("failed to create file in branch", slog.Any("newfile", newFileName), + slog.Any("newBranch", copyReq.NewBranch), slog.Any("req", copyReq.Req), slog.Any("error", err)) + return nil, fmt.Errorf("failed to create new file %s in new branch %s, cause: %w", + newFileName, copyReq.NewBranch, err) + } + newFiles = append(newFiles, dvCom.FileObject{ + RepoFile: newFileName, + Size: orginfile.Size, + Lfs: orginfile.Lfs, + LfsRelativePath: orginfile.LfsRelativePath, + }) + objectNames = append(objectNames, filepath.Join("lfs", orginfile.LfsRelativePath)) + } + count, err = r.RowCount(ctx, objectNames, types.QueryReq{}, true) + if err != nil { + slog.Error("get S3 row count error", slog.Any("req", copyReq.Req), + slog.Any("config", info.ConfigName), slog.Any("split", split.Name), + slog.Any("objectNames", objectNames), slog.Any("error", err)) + return nil, fmt.Errorf("failed to get row count for repo %s/%s submit %s split %s, cause: %w", + copyReq.Req.Namespace, copyReq.Req.Name, info.ConfigName, split.Name, err) + } + } + newSplit.Name = split.Name + newSplit.Files = newFiles + newSplit.NumExamples = count + newSplit.Origins = split.Origins + newSplits = append(newSplits, newSplit) + } + newInfo.ConfigName = info.ConfigName + newInfo.Splits = newSplits + datasetInfos = append(datasetInfos, newInfo) + } + cardData.Configs = copyReq.ComputedCardData.Configs + cardData.DatasetInfos = datasetInfos + return &cardData, nil +} + +func (dva *dataViewerActivityImpl) DownloadSplitFiles(ctx context.Context, downloadReq dvCom.DownloadFileReq) (*dvCom.DownloadCard, error) { + var subsets []dvCom.DownloadSubset + cacheRepoPath := GetCacheRepoPath(ctx, dva.cfg.DataViewer.CacheDir, downloadReq.Req) + _, err := os.Stat(cacheRepoPath) + if err != nil && !os.IsNotExist(err) { + slog.Warn("check cach repo path error for download split file", slog.Any("cacheRepoPath", cacheRepoPath), slog.Any("error", err)) + } + if os.IsNotExist(err) { + err = os.MkdirAll(cacheRepoPath, os.ModePerm) + if err != nil { + slog.Error("create cache repo path error for download split file", slog.Any("cacheRepoPath", cacheRepoPath), slog.Any("error", err)) + return nil, fmt.Errorf("failed to create cache repo path %s for download split file, cause: %w", cacheRepoPath, err) + } + } else { + err = os.RemoveAll(cacheRepoPath) + if err != nil { + slog.Error("remove cache repo path error for download split file", slog.Any("cacheRepoPath", cacheRepoPath), slog.Any("error", err)) + return nil, fmt.Errorf("failed to remove cache repo path %s for download split file, cause: %w", cacheRepoPath, err) + } + err = os.MkdirAll(cacheRepoPath, os.ModePerm) + if err != nil { + slog.Error("create cache repo path error for download split file", slog.Any("cacheRepoPath", cacheRepoPath), slog.Any("error", err)) + return nil, fmt.Errorf("failed to create cache repo path %s for download split file, cause: %w", cacheRepoPath, err) + } + } + + for _, info := range downloadReq.Card.DatasetInfos { + newSplits := []dvCom.DownloadSplit{} + for _, split := range info.Splits { + newFiles := []dvCom.FileObject{} + for idx, file := range split.Origins { + extName := filepath.Ext(file.RepoFile) + localFileName := fmt.Sprintf("%05d%s", idx, extName) + downloadObj, err := dva.downloadFile(ctx, downloadReq.Req, file, &dvCom.FileObject{ + RepoFile: file.RepoFile, + LastCommit: file.LastCommit, + Lfs: file.Lfs, + LocalRepoPath: cacheRepoPath, + LocalFileName: localFileName, + Size: file.Size, + SubsetName: info.ConfigName, + SplitName: split.Name, + }) + if err != nil { + slog.Error("failed to download file", slog.Any("req", downloadReq.Req), + slog.Any("file", file), slog.Any("error", err)) + return nil, fmt.Errorf("failed to download file %s in branch %s, cause: %w", + file.RepoFile, downloadReq.Req.Branch, err) + } + // slog.Info("downloaded file successfully", slog.Any("req", req), slog.Any("file", file), slog.Any("downloadObj", downloadObj)) + newFiles = append(newFiles, *downloadObj) + } + splitPath := fmt.Sprintf("%s/%s/%s", cacheRepoPath, info.ConfigName, split.Name) + exportPath := fmt.Sprintf("%s_export", splitPath) + newSplit := dvCom.DownloadSplit{Name: split.Name, LocalPath: splitPath, ExportPath: exportPath, Files: newFiles} + newSplits = append(newSplits, newSplit) + } + newSubset := dvCom.DownloadSubset{ConfigName: info.ConfigName, Splits: newSplits} + subsets = append(subsets, newSubset) + } + return &dvCom.DownloadCard{Configs: downloadReq.Card.Configs, Subsets: subsets}, nil +} + +func (dva *dataViewerActivityImpl) downloadFile(ctx context.Context, req types.UpdateViewerReq, orginFile dvCom.FileObject, loadFile *dvCom.FileObject) (*dvCom.FileObject, error) { + cacheFilePath := fmt.Sprintf("%s/%s/%s", loadFile.LocalRepoPath, loadFile.SubsetName, loadFile.SplitName) + _, err := os.Stat(cacheFilePath) + if err != nil && !os.IsNotExist(err) { + slog.Warn("check cache file path error", slog.Any("cacheFilePath", cacheFilePath), slog.Any("error", err)) + } + if os.IsNotExist(err) { + err = os.MkdirAll(cacheFilePath, os.ModePerm) + if err != nil { + slog.Error("create cache file path error for download file", slog.Any("cacheFilePath", cacheFilePath), slog.Any("error", err)) + return nil, fmt.Errorf("failed to create cache file path %s for download file, cause: %w", cacheFilePath, err) + } + } + localFileFullPath := fmt.Sprintf("%s/%s", cacheFilePath, loadFile.LocalFileName) + if orginFile.Lfs { + err := dva.downloadLfsFile(ctx, localFileFullPath, orginFile, loadFile) + if err != nil { + return nil, fmt.Errorf("fail to download repo %s/%s lfs file %s, error: %w", req.Namespace, req.Name, orginFile.RepoFile, err) + } + } else { + err := dva.downloadNormalFile(ctx, localFileFullPath, req, orginFile, loadFile) + if err != nil { + return nil, fmt.Errorf("fail to download repo %s/%s normal file %s, error: %w", req.Namespace, req.Name, orginFile.RepoFile, err) + } + } + + return loadFile, nil +} + +func (dva *dataViewerActivityImpl) downloadLfsFile(ctx context.Context, localFileFullPath string, orginFile dvCom.FileObject, loadFile *dvCom.FileObject) error { + objectKey := orginFile.LfsRelativePath + objectKey = path.Join("lfs", objectKey) + loadFile.ObjectKey = objectKey + + if !dva.cfg.DataViewer.DownloadLfsFile { + slog.Warn("skip download lfs file", slog.Any("file", orginFile)) + return nil + } + + reqParams := make(url.Values) + signedUrl, err := dva.s3Client.PresignedGetObject(ctx, dva.cfg.S3.Bucket, objectKey, types.OssFileExpire, reqParams) + if err != nil { + return fmt.Errorf("fail to get lfs file download url error: %w", err) + } + resp, err := http.Get(signedUrl.String()) + if err != nil { + return fmt.Errorf("failed to do http request url %s, error: %w", signedUrl.String(), err) + } + defer resp.Body.Close() + + writeFile, err := os.Create(localFileFullPath) + if err != nil { + return fmt.Errorf("failed to create local file %s, error: %w", localFileFullPath, err) + } + defer writeFile.Close() + + _, err = io.Copy(writeFile, resp.Body) + if err != nil { + return fmt.Errorf("failed to save local file %s, error: %w", localFileFullPath, err) + } + return nil +} + +func (dva *dataViewerActivityImpl) downloadNormalFile(ctx context.Context, localFileFullPath string, req types.UpdateViewerReq, orginFile dvCom.FileObject, loadFile *dvCom.FileObject) error { + getFileReaderReq := gitserver.GetRepoInfoByPathReq{ + Namespace: req.Namespace, + Name: req.Name, + Ref: req.Branch, + Path: orginFile.RepoFile, + RepoType: req.RepoType, + } + reader, size, err := dva.gitServer.GetRepoFileReader(ctx, getFileReaderReq) + loadFile.Size = size + if err != nil { + return fmt.Errorf("failed to get repo %s/%s file %s for reader, error: %w", req.Namespace, req.Name, orginFile.RepoFile, err) + } + writeFile, err := os.Create(localFileFullPath) + if err != nil { + return fmt.Errorf("failed to create local file %s for repo %s/%s file %s, error: %w", localFileFullPath, req.Namespace, req.Name, orginFile.RepoFile, err) + } + defer writeFile.Close() + + _, err = io.Copy(writeFile, reader) + if err != nil { + return fmt.Errorf("failed to save local file %s for repo %s/%s file %s, error: %w", localFileFullPath, req.Namespace, req.Name, orginFile.RepoFile, err) + } + return nil +} + +func (dva *dataViewerActivityImpl) ConvertToParquetFiles(ctx context.Context, convertReq dvCom.ConvertReq) error { + var err error + writer, err := parquet.NewS3Writer(ctx, dva.cfg) + if err != nil { + return fmt.Errorf("failed to create duckdb reader, cause: %w", err) + } + for _, subset := range convertReq.DownloadCard.Subsets { + for _, split := range subset.Splits { + if len(split.Files) < 1 { + continue + } + objectNames := []string{} + for _, file := range split.Files { + if file.Lfs && !dva.cfg.DataViewer.DownloadLfsFile { + objectNames = append(objectNames, fmt.Sprintf("'s3://%s/%s'", dva.cfg.S3.Bucket, file.ObjectKey)) + } else { + objectNames = append(objectNames, fmt.Sprintf("'%s/%s/%s/%s'", file.LocalRepoPath, file.SubsetName, file.SplitName, file.LocalFileName)) + } + } + slog.Debug("ConvertToParquetFiles", slog.Any("objectNames", objectNames)) + _, err = os.Stat(split.ExportPath) + if err != nil && !os.IsNotExist(err) { + slog.Warn("check export file path error", slog.Any("ExportPath", split.ExportPath), slog.Any("error", err)) + } + if os.IsNotExist(err) { + err = os.MkdirAll(split.ExportPath, os.ModePerm) + if err != nil { + return fmt.Errorf("failed to create export path %s for convert, error: %w", split.ExportPath, err) + } + } + method := "" + if convertReq.RepoDataType == RepoJsonData { + method = "read_json_auto" + } else if convertReq.RepoDataType == RepoCsvData { + method = "read_csv_auto" + } + splitExportPath := fmt.Sprintf("%s/", strings.TrimSuffix(split.ExportPath, "/")) + err = writer.ConvertToParquet(ctx, method, objectNames, dva.cfg.DataViewer.ThreadNumOfExport, splitExportPath) + if err != nil { + slog.Error("failed to convert data", slog.Any("objectNames", objectNames), + slog.Any("req", convertReq.Req), slog.Any("configname", subset.ConfigName), + slog.Any("split", split), slog.Any("error", err)) + return fmt.Errorf("failed to convert data for repo %s/%s, subset %s, split: %v, cause: %w", + convertReq.Req.Namespace, convertReq.Req.Name, subset.ConfigName, split, err) + } + slog.Debug("convert parquet success", slog.Any("req", convertReq.Req), + slog.Any("subset", subset.ConfigName), slog.Any("split", split.Name), + slog.Any("exportPath", split.ExportPath)) + } + } + return nil +} + +func (dva *dataViewerActivityImpl) UploadParquetFiles(ctx context.Context, uploadReq dvCom.UploadParquetReq) (*dvCom.CardData, error) { + r, err := parquet.NewS3Reader(ctx, dva.cfg) + if err != nil { + return nil, fmt.Errorf("failed to create duckdb reader, cause: %w", err) + } + cardData := dvCom.CardData{} + var datasetInfos []dvCom.DatasetInfo + for _, subset := range uploadReq.DownloadCard.Subsets { + newInfo := dvCom.DatasetInfo{} + newSplits := []dvCom.Split{} + for _, split := range subset.Splits { + newSplit := dvCom.Split{} + newFiles := []dvCom.FileObject{} + if split.ExportPath == "" { + continue + } + entries, err := os.ReadDir(split.ExportPath) + if err != nil { + slog.Error("read export dir error", slog.Any("exportPath", split.ExportPath), slog.Any("error", err)) + return nil, fmt.Errorf("failed to read dir %s, cause: %w", split.ExportPath, err) + } + sort.Slice(entries, func(i, j int) bool { + nameI := entries[i].Name() + nameJ := entries[j].Name() + numI, _ := strconv.Atoi(nameI[:len(nameI)-len(filepath.Ext(nameI))]) + numJ, _ := strconv.Atoi(nameJ[:len(nameJ)-len(filepath.Ext(nameJ))]) + return numI < numJ + }) + objectNames := []string{} + for _, entry := range entries { + fileName := entry.Name() + if entry.Type().IsRegular() && IsValidParquetFile(fileName) { + extName := filepath.Ext(fileName) + fileNameSeq := fileName[:len(fileName)-len(extName)] + fileNameSeqInt, err := strconv.Atoi(fileNameSeq) + if err != nil { + slog.Warn("invalid file name to int error", slog.Any("fileName", fileName), slog.Any("ExportPath", split.ExportPath), slog.Any("error", err)) + continue + } + fileInfo, err := entry.Info() + if err != nil { + slog.Error("get file info error", slog.Any("filePath", fileName), slog.Any("error", err)) + return nil, fmt.Errorf("failed to get file info %s under path %s, cause: %w", fileName, split.ExportPath, err) + } + realFile := fmt.Sprintf("%s/%s", split.ExportPath, fileName) + newFileName := fmt.Sprintf("%05d%s", fileNameSeqInt, extName) + uploadFile := &dvCom.FileObject{ + ConvertPath: realFile, + RepoFile: fmt.Sprintf("%s/%s/%s", subset.ConfigName, split.Name, newFileName), + Size: fileInfo.Size(), + Lfs: true, + } + err = dva.uploadToRepo(ctx, uploadReq.Req, uploadFile, uploadReq.NewBranch) + if err != nil { + slog.Error("upload file to repo error", slog.Any("realFile", realFile), + slog.Any("req", uploadReq.Req), slog.Any("newbranch", uploadReq.NewBranch), slog.Any("error", err)) + return nil, fmt.Errorf("failed to upload file %s to repo %s/%s branch %s, cause: %w", realFile, + uploadReq.Req.Namespace, uploadReq.Req.Name, uploadReq.NewBranch, err) + } + newFiles = append(newFiles, *uploadFile) + objectNames = append(objectNames, realFile) + } + } + count, err := r.RowCount(ctx, objectNames, types.QueryReq{}, false) + if err != nil { + slog.Error("get row count error", slog.Any("req", uploadReq.Req), + slog.Any("config", subset.ConfigName), slog.Any("split", split.Name), + slog.Any("objectNames", objectNames), slog.Any("error", err)) + return nil, fmt.Errorf("failed to get row count for repo %s/%s submit %s split %s, cause: %w", + uploadReq.Req.Namespace, uploadReq.Req.Name, subset.ConfigName, split.Name, err) + } + newSplit.Name = split.Name + newSplit.Files = newFiles + newSplit.NumExamples = count + newSplit.Origins = split.Files + newSplits = append(newSplits, newSplit) + } + newInfo.ConfigName = subset.ConfigName + newInfo.Splits = newSplits + datasetInfos = append(datasetInfos, newInfo) + } + cardData.Configs = uploadReq.DownloadCard.Configs + cardData.DatasetInfos = datasetInfos + return &cardData, nil +} + +func (dva *dataViewerActivityImpl) uploadToRepo(ctx context.Context, req types.UpdateViewerReq, uploadFile *dvCom.FileObject, newBranch string) error { + f, err := os.Open(uploadFile.ConvertPath) + if err != nil { + return fmt.Errorf("open file %s, cause: %w", uploadFile.ConvertPath, err) + } + defer f.Close() + + pointer, err := gitea.GeneratePointer(f) + if err != nil { + return fmt.Errorf("fail to get lfs file %s point, cause: %w", uploadFile.ConvertPath, err) + } + encodingLfsContent := base64.StdEncoding.EncodeToString([]byte(pointer.StringContent())) + + _, err = f.Seek(0, 0) + if err != nil { + return fmt.Errorf("seek to beginning of file %s, cause: %w", uploadFile.ConvertPath, err) + } + + uploadFile.LfsRelativePath = pointer.RelativePath() + objectKey := filepath.Join("lfs", pointer.RelativePath()) + uploadInfo, err := dva.s3Client.PutObject(ctx, dva.cfg.S3.Bucket, objectKey, f, pointer.Size, minio.PutObjectOptions{}) + if err != nil { + return fmt.Errorf("upload file %s to S3, cause: %w", uploadFile.ConvertPath, err) + } + + if uploadInfo.Size != pointer.Size { + return fmt.Errorf("uploaded S3 file %s size does not match expected size: %d != %d", uploadFile.ConvertPath, uploadInfo.Size, pointer.Size) + } + + createReq := &types.CreateFileReq{ + Username: GitDefaultUserName, + Email: GitDefaultUserEmail, + Message: "upload parquet file", + FilePath: uploadFile.RepoFile, + Content: encodingLfsContent, + Namespace: req.Namespace, + Name: req.Name, + RepoType: req.RepoType, + Branch: newBranch, + } + + err = dva.gitServer.CreateRepoFile(createReq) + if err != nil { + return fmt.Errorf("failed to create lfs file %s in repo %s/%s branch %s, cause: %w", uploadFile.RepoFile, req.Namespace, req.Name, newBranch, err) + } + return nil +} + +func (dva *dataViewerActivityImpl) UpdateCardData(ctx context.Context, cardReq dvCom.UpdateCardReq) error { + wfCtx := activity.GetInfo(ctx) + workflowID := wfCtx.WorkflowExecution.ID + + job, err := dva.viewerStore.GetJob(ctx, workflowID) + if err != nil { + return fmt.Errorf("get job by workflow id %s for update card, cause: %w", workflowID, err) + } + + finalCardDataJson, err := json.Marshal(cardReq.FinalCardData) + if err != nil { + slog.Error("failed to marshal final card data", slog.Any("req", cardReq.Req), + slog.Any("finalCardData", cardReq.FinalCardData), slog.Any("error", err)) + return fmt.Errorf("marshal final card data to json, cause: %w", err) + } + + job.AutoCard = (cardReq.OriginCardData.Configs == nil) + job.CardData = string(finalCardDataJson) + job.CardMD5 = GetCardDataMD5(cardReq.FinalCardData) + + _, err = dva.viewerStore.UpdateJob(ctx, *job) + if err != nil { + return fmt.Errorf("update job by id %d for update card, cause: %w", job.ID, err) + } + return nil +} + +func (dva *dataViewerActivityImpl) CleanUp(ctx context.Context, req types.UpdateViewerReq) error { + cacheRepoPath := GetCacheRepoPath(ctx, dva.cfg.DataViewer.CacheDir, req) + if _, err := os.Stat(cacheRepoPath); !os.IsNotExist(err) { + err := os.RemoveAll(cacheRepoPath) + if err != nil { + slog.Warn("clean up cache repo path %s, error: %w", cacheRepoPath, err) + } + } + return nil +} + +func (dva *dataViewerActivityImpl) UpdateWorkflowStatus(ctx context.Context, status dvCom.UpdateWorkflowStatusReq) error { + wfCtx := activity.GetInfo(ctx) + workflowID := wfCtx.WorkflowExecution.ID + runID := wfCtx.WorkflowExecution.RunID + + if status.WorkflowErr != nil { + slog.Error("run data viewer workflow error", slog.Any("workflowID", workflowID), slog.Any("runID", runID), + slog.Any("status", status), slog.Any("workflowErr", status.WorkflowErr)) + } + + job, err := dva.viewerStore.GetJob(ctx, workflowID) + if err != nil { + slog.Error("get workflow for ending", slog.Any("workflowID", workflowID), slog.Any("err", err)) + return nil + } + + if status.WorkflowErr != nil { + job.Status = types.WorkflowFailed + job.Logs = status.WorkflowErr.Error() + } else { + job.Status = types.WorkflowDone + job.Logs = types.WorkflowMsgDone + } + + job.EndTime = time.Now() + + _, err = dva.viewerStore.UpdateJob(ctx, *job) + if err != nil { + slog.Error("update workflow result for ending", slog.Any("workflowID", workflowID), slog.Any("job", job), slog.Any("error", err)) + } + + if status.WorkflowErr != nil || !status.ShouldUpdateViewer { + return nil + } + + viewer, err := dva.viewerStore.GetViewerByRepoID(ctx, status.Req.RepoID) + if err != nil { + slog.Error("get viewer workflow for ending", slog.Any("status", status), slog.Any("err", err)) + return nil + } + + viewer.WorkflowID = workflowID + _, err = dva.viewerStore.UpdateViewer(ctx, *viewer) + if err != nil { + slog.Error("update viewer for workflow ending", slog.Any("status", status), slog.Any("viewer", viewer), slog.Any("error", err)) + } + return nil +} diff --git a/dataviewer/workflows/activity_test.go b/dataviewer/workflows/activity_test.go new file mode 100644 index 00000000..a142b2a3 --- /dev/null +++ b/dataviewer/workflows/activity_test.go @@ -0,0 +1,262 @@ +package workflows + +import ( + "context" + "encoding/base64" + "testing" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/builder/store/s3" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" + + mockGit "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/git/gitserver" + mockdb "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/store/database" + mockS3 "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/store/s3" +) + +func NewTestDataViewerActivity(cfg *config.Config, gs gitserver.GitServer, s3Client s3.Client, viewerStore database.DataviewerStore) (DataViewerActivity, error) { + return &dataViewerActivityImpl{ + gitServer: gs, + s3Client: s3Client, + cfg: cfg, + viewerStore: viewerStore, + }, nil +} + +func TestActivity_GetCardFromReadme(t *testing.T) { + ctx := context.TODO() + + config := &config.Config{} + dvstore := mockdb.NewMockDataviewerStore(t) + mockGitServer := mockGit.NewMockGitServer(t) + s3Client := mockS3.NewMockClient(t) + + req := types.UpdateViewerReq{ + Namespace: "testns", + Name: "testname", + Branch: "main", + RepoType: types.DatasetRepo, + RepoID: int64(1), + } + + // configs: + // - config_name: "foo" + // data_files: + // - split: train + // path: foo/.. + // - config_name: "bar" + // data_files: + // - split: train + // path: bar/.. + + mockGitServer.EXPECT().GetRepoFileContents(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: req.Namespace, + Name: req.Name, + Ref: req.Branch, + Path: types.REPOCARD_FILENAME, + RepoType: req.RepoType, + }).Return(&types.File{ + LfsRelativePath: "a/b", + Content: "LS0tCmNvbmZpZ3M6Ci0gY29uZmlnX25hbWU6ICJmb28iCiAgZGF0YV9maWxlczoKICAtIHNwbGl0OiB0cmFpbgogICAgcGF0aDogZm9vLy4qCi0gY29uZmlnX25hbWU6ICJiYXIiCiAgZGF0YV9maWxlczoKICAtIHNwbGl0OiB0cmFpbgpwYXRoOiBiYXIvLioKLS0tCg==", + }, nil) + + dvActivity, err := NewTestDataViewerActivity(config, mockGitServer, s3Client, dvstore) + require.Nil(t, err) + + card, err := dvActivity.GetCardFromReadme(ctx, req) + require.Nil(t, err) + require.NotNil(t, card) + require.Equal(t, "foo", card.Configs[0].ConfigName) + require.Equal(t, "bar", card.Configs[1].ConfigName) +} + +func TestActivity_ScanRepoFiles(t *testing.T) { + ctx := context.TODO() + + config := &config.Config{} + dvstore := mockdb.NewMockDataviewerStore(t) + mockGitServer := mockGit.NewMockGitServer(t) + s3Client := mockS3.NewMockClient(t) + + req := types.UpdateViewerReq{ + Namespace: "testns", + Name: "testname", + Branch: "main", + RepoType: types.DatasetRepo, + RepoID: int64(1), + } + + mockGitServer.EXPECT().GetRepoFileTree(mock.Anything, gitserver.GetRepoInfoByPathReq{ + Namespace: req.Namespace, + Name: req.Name, + Ref: req.Branch, + RepoType: req.RepoType, + }).Return( + []*types.File{ + {Name: "foobar.parquet", Path: "foo/foobar.parquet"}, + }, nil, + ) + + dvActivity, err := NewTestDataViewerActivity(config, mockGitServer, s3Client, dvstore) + require.Nil(t, err) + + cls, err := dvActivity.ScanRepoFiles(ctx, dvCom.ScanRepoFileReq{ + Req: req, + MaxFileSize: config.DataViewer.MaxFileSize, + }) + require.Nil(t, err) + require.NotNil(t, cls) + require.Equal(t, 1, len(cls.AllFiles)) + require.Equal(t, 1, len(cls.ParquetFiles)) + require.Equal(t, 0, len(cls.JsonlFiles)) + require.Equal(t, 0, len(cls.CsvFiles)) +} + +func TestActivity_DetermineCardData(t *testing.T) { + ctx := context.TODO() + + config := &config.Config{} + dvstore := mockdb.NewMockDataviewerStore(t) + mockGitServer := mockGit.NewMockGitServer(t) + s3Client := mockS3.NewMockClient(t) + + card := dvCom.CardData{} + + repoFileClass := dvCom.RepoFilesClass{ + AllFiles: map[string]*types.File{ + "foo.parquet": {Name: "foo.parquet", Path: "train/foo.parquet"}, + }, + ParquetFiles: map[string]*types.File{ + "foo.parquet": {Name: "foo.parquet", Path: "train/foo.parquet"}, + }, + JsonlFiles: map[string]*types.File{}, + CsvFiles: map[string]*types.File{}, + } + + dvActivity, err := NewTestDataViewerActivity(config, mockGitServer, s3Client, dvstore) + require.Nil(t, err) + + res, err := dvActivity.DetermineCardData(ctx, + dvCom.DetermineCardReq{ + Card: card, + Class: repoFileClass, + RepoDataType: RepoParquetData, + }) + require.Nil(t, err) + require.NotNil(t, res) + require.Equal(t, 1, len(res.Configs)) + require.Equal(t, "default", res.Configs[0].ConfigName) +} + +func TestActivity_CheckIfNeedRebuild(t *testing.T) { + ctx := context.TODO() + + config := &config.Config{} + dvstore := mockdb.NewMockDataviewerStore(t) + mockGitServer := mockGit.NewMockGitServer(t) + s3Client := mockS3.NewMockClient(t) + + req := types.UpdateViewerReq{ + Namespace: "testns", + Name: "testname", + Branch: "main", + RepoType: types.DatasetRepo, + RepoID: int64(1), + } + + card := dvCom.CardData{ + Configs: []dvCom.ConfigData{ + { + ConfigName: "default", + DataFiles: []dvCom.DataFiles{ + { + Split: "train", + Path: "train/foo.parquet", + }, + }, + }, + }, + DatasetInfos: []dvCom.DatasetInfo{ + { + ConfigName: "default", + Splits: []dvCom.Split{ + { + Name: "train", + Origins: []dvCom.FileObject{ + { + RepoFile: "foo.parquet", + LastCommit: "abcdefg", + }, + }, + }, + }, + }, + }, + } + + dvstore.EXPECT().GetViewerByRepoID(ctx, int64(1)).Return(&database.Dataviewer{ + DataviewerJob: &database.DataviewerJob{ + CardMD5: "123456", + }, + }, nil) + + dvActivity, err := NewTestDataViewerActivity(config, mockGitServer, s3Client, dvstore) + require.Nil(t, err) + + res, err := dvActivity.CheckIfNeedRebuild(ctx, + dvCom.CheckBuildReq{ + Req: req, + Card: card, + }) + require.Nil(t, err) + require.True(t, res) +} + +func TestActivity_CreateParquetBranch(t *testing.T) { + ctx := context.TODO() + + config := &config.Config{} + dvstore := mockdb.NewMockDataviewerStore(t) + mockGitServer := mockGit.NewMockGitServer(t) + s3Client := mockS3.NewMockClient(t) + + dvActivity, err := NewTestDataViewerActivity(config, mockGitServer, s3Client, dvstore) + require.Nil(t, err) + + req := types.UpdateViewerReq{ + Namespace: "testns", + Name: "testname", + Branch: "main", + RepoType: types.DatasetRepo, + RepoID: int64(1), + } + + mockGitServer.EXPECT().GetRepoBranchByName(ctx, gitserver.GetBranchReq{ + Namespace: req.Namespace, + Name: req.Name, + Ref: dvCom.ParquetBranch, + RepoType: req.RepoType, + }, + ).Return(nil, nil) + + mockGitServer.EXPECT().CreateRepoFile(&types.CreateFileReq{ + Username: GitDefaultUserName, + Email: GitDefaultUserEmail, + Message: "create branch", + Content: base64.StdEncoding.EncodeToString([]byte(types.DatasetGitattributesContent)), + NewBranch: dvCom.ParquetBranch, + Namespace: req.Namespace, + Name: req.Name, + FilePath: types.GitattributesFileName, + RepoType: req.RepoType, + }).Return(nil) + + res, err := dvActivity.CreateParquetBranch(ctx, req) + require.Nil(t, err) + require.Equal(t, dvCom.ParquetBranch, res) +} diff --git a/dataviewer/workflows/repo_files.go b/dataviewer/workflows/repo_files.go new file mode 100644 index 00000000..77ce2443 --- /dev/null +++ b/dataviewer/workflows/repo_files.go @@ -0,0 +1,124 @@ +package workflows + +import ( + "context" + "fmt" + "strings" + + "opencsg.com/csghub-server/builder/git/gitserver" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +const ( + RepoParquetData dvCom.RepoDataType = "parquet" + RepoJsonData dvCom.RepoDataType = "json" + RepoCsvData dvCom.RepoDataType = "csv" +) + +var ( + GitDefaultUserName = "admin" + GitDefaultUserEmail = "admin@csghub.com" + DefaultSubsetName = "default" + TrainSplitName = "train" + TestSplitName = "test" + ValSplitName = "validation" + OtherSplitName = "others" +) + +func IsValidParquetFile(entryName string) bool { + return strings.HasSuffix(strings.ToLower(entryName), ".parquet") +} + +func IsValidJsonFile(entryName string) bool { + return strings.HasSuffix(strings.ToLower(entryName), ".jsonl") || strings.HasSuffix(strings.ToLower(entryName), ".json") +} + +func IsValidCSVFile(entryName string) bool { + return strings.HasSuffix(strings.ToLower(entryName), ".csv") +} + +func IsTrainFile(fileName string) bool { + fileName = strings.ToLower(fileName) + if strings.Contains(fileName, "train") || strings.Contains(fileName, "training") { + return true + } + return false +} + +func IsTestFile(fileName string) bool { + fileName = strings.ToLower(fileName) + if strings.Contains(fileName, "test") || strings.Contains(fileName, "testing") { + return true + } + if strings.Contains(fileName, "eval") || strings.Contains(fileName, "evaluation") { + return true + } + return false +} + +func IsValidationFile(fileName string) bool { + fileName = strings.ToLower(fileName) + if strings.Contains(fileName, "val") || strings.Contains(fileName, "valid") || strings.Contains(fileName, "validation") { + return true + } + if strings.Contains(fileName, "dev") { + return true + } + return false +} + +func GetFilePaths(req dvCom.RepoFilesReq, fileClass *dvCom.RepoFilesClass, maxFileSize int64) error { + err := getAllFiles(req, fileClass, maxFileSize) + if err != nil { + return fmt.Errorf("get repo all files error: %w", err) + } + return nil +} + +func getAllFiles(req dvCom.RepoFilesReq, fileClass *dvCom.RepoFilesClass, maxFileSize int64) error { + getRepoFileTree := gitserver.GetRepoInfoByPathReq{ + Namespace: req.Namespace, + Name: req.RepoName, + Ref: req.Ref, + Path: req.Folder, + RepoType: req.RepoType, + } + gitFiles, err := req.GSTree(context.Background(), getRepoFileTree) + if err != nil { + return fmt.Errorf("get repo file tree error: %w", err) + } + for _, file := range gitFiles { + if file.Type == "dir" { + err := getAllFiles(dvCom.RepoFilesReq{ + Namespace: req.Namespace, + RepoName: req.RepoName, + Folder: file.Path, + RepoType: req.RepoType, + Ref: req.Ref, + GSTree: req.GSTree, + }, fileClass, maxFileSize) + if err != nil { + return fmt.Errorf("list folder %s files error: %w", file.Path, err) + } + } else { + appendFile(file, fileClass, maxFileSize) + } + } + return nil +} + +func appendFile(file *types.File, fileClass *dvCom.RepoFilesClass, maxFileSize int64) { + fileClass.AllFiles[file.Path] = file + if IsValidParquetFile(file.Name) { + fileClass.ParquetFiles[file.Path] = file + } else if IsValidJsonFile(file.Name) { + if file.Size <= maxFileSize { + fileClass.JsonlFiles[file.Path] = file + } + } else if IsValidCSVFile(file.Name) { + if file.Size <= maxFileSize { + fileClass.CsvFiles[file.Path] = file + } + } +} diff --git a/dataviewer/workflows/repo_files_test.go b/dataviewer/workflows/repo_files_test.go new file mode 100644 index 00000000..b24662d3 --- /dev/null +++ b/dataviewer/workflows/repo_files_test.go @@ -0,0 +1,28 @@ +package workflows + +import ( + "testing" + + "github.com/stretchr/testify/require" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +func TestRepoFiles_appendFile(t *testing.T) { + file := &types.File{ + Name: "test.jsonl", + Size: 101, + } + + fileClass := dvCom.RepoFilesClass{ + AllFiles: make(map[string]*types.File), + ParquetFiles: make(map[string]*types.File), + JsonlFiles: make(map[string]*types.File), + CsvFiles: make(map[string]*types.File), + } + + appendFile(file, &fileClass, 100) + + require.Equal(t, 1, len(fileClass.AllFiles)) + require.Equal(t, 0, len(fileClass.JsonlFiles)) +} diff --git a/dataviewer/workflows/utils.go b/dataviewer/workflows/utils.go new file mode 100644 index 00000000..f3a24663 --- /dev/null +++ b/dataviewer/workflows/utils.go @@ -0,0 +1,106 @@ +package workflows + +import ( + "context" + "crypto/md5" + "encoding/hex" + "fmt" + "log/slog" + "regexp" + "strings" + "time" + + "go.temporal.io/sdk/activity" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +func TransferFileObject(file *types.File, subsetName, splitName string) dvCom.FileObject { + return dvCom.FileObject{ + RepoFile: file.Path, + Size: file.Size, + LastCommit: file.LastCommitSHA, + Lfs: file.Lfs, + LfsRelativePath: file.LfsRelativePath, + SubsetName: subsetName, + SplitName: splitName, + } +} + +func GetPatternFileList(path interface{}) []string { + if path == nil { + return []string{} + } + var ( + files []string + ) + if slice, ok := path.([]interface{}); ok { + for _, v := range slice { + files = append(files, v.(string)) + } + } else if slice, ok := path.([]string); ok { + files = slice + } else { + files = []string{path.(string)} + } + return files +} + +func ConvertRealFiles(splitFiles []string, sortKeys []string, targetFiles map[string]*types.File, subsetName, splitName string) []dvCom.FileObject { + var phyFiles []dvCom.FileObject + for _, filePattern := range splitFiles { + if !strings.Contains(filePattern, dvCom.WILDCARD) { + file, exists := targetFiles[filePattern] + if exists { + phyFiles = append(phyFiles, TransferFileObject(file, subsetName, splitName)) + } + continue + } + + fileReg, err := regexp.Compile(filePattern) + if err != nil { + slog.Warn("invalid regexp format of split file", slog.Any("filePattern", filePattern), slog.Any("err", err)) + file, exists := targetFiles[filePattern] + if exists { + phyFiles = append(phyFiles, TransferFileObject(file, subsetName, splitName)) + } + continue + } + for _, path := range sortKeys { + // repo file match like: test/test-* + if fileReg.MatchString(path) { + file, exists := targetFiles[path] + if exists { + phyFiles = append(phyFiles, TransferFileObject(file, subsetName, splitName)) + } + } + } + } + slog.Debug("convert real files", slog.Any("splitFiles", splitFiles), slog.Any("phyFiles", phyFiles)) + return phyFiles +} + +func GetCardDataMD5(finalCardData dvCom.CardData) string { + hasher := md5.New() + for _, info := range finalCardData.DatasetInfos { + for _, split := range info.Splits { + for _, file := range split.Origins { + hasher.Write([]byte(fmt.Sprintf("%s-%s", file.RepoFile, file.LastCommit))) + } + } + } + return hex.EncodeToString(hasher.Sum(nil)) +} + +func GenerateWorkFlowID(req types.UpdateViewerReq) string { + id := "dv-" + req.Namespace + "/" + req.Name + "-" + time.Now().Format("20060102.150405.000000000") + return id +} + +func GetCacheRepoPath(ctx context.Context, cacheDir string, req types.UpdateViewerReq) string { + wfCtx := activity.GetInfo(ctx) + workflowID := wfCtx.WorkflowExecution.ID + segments := strings.Split(workflowID, "-") + timeSeq := segments[len(segments)-1] + return fmt.Sprintf("%s/%s/%s/%s/%s", strings.TrimSuffix(cacheDir, "/"), req.RepoType, req.Namespace, req.Name, timeSeq) +} diff --git a/dataviewer/workflows/utils_test.go b/dataviewer/workflows/utils_test.go new file mode 100644 index 00000000..6da1c963 --- /dev/null +++ b/dataviewer/workflows/utils_test.go @@ -0,0 +1,67 @@ +package workflows + +import ( + "testing" + + "github.com/stretchr/testify/require" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +func TestUtils_GetPatternFileList(t *testing.T) { + path := interface{}([]string{"a", "b"}) + + output := GetPatternFileList(path) + + require.Equal(t, 2, len(output)) + + path = interface{}("c") + + output = GetPatternFileList(path) + + require.Equal(t, 1, len(output)) +} + +func TestUtils_ConvertRealFiles(t *testing.T) { + splitFiles := []string{"a/1.parquet", "b/2.parquet"} + sortKeys := []string{"a", "b"} + + targetFiles := map[string]*types.File{ + "a/1.parquet": { + Path: "a/1.parquet", + }, + "b/2.parquet": { + Path: "b/2.parquet", + }, + "c/3.parquet": { + Path: "c/3.parquet", + }, + } + + res := ConvertRealFiles(splitFiles, sortKeys, targetFiles, "default", "train") + require.Equal(t, 2, len(res)) +} + +func TestUtils_GetCardDataMD5(t *testing.T) { + card := dvCom.CardData{ + DatasetInfos: []dvCom.DatasetInfo{ + { + ConfigName: "train", + Splits: []dvCom.Split{ + { + Origins: []dvCom.FileObject{ + { + RepoFile: "a/1.parquet", + LastCommit: "abc", + }, + }, + }, + }, + }, + }, + } + + out := GetCardDataMD5(card) + + require.Equal(t, "e096cecdbd943760b46ac073b6fd8d24", out) +} diff --git a/dataviewer/workflows/workflow.go b/dataviewer/workflows/workflow.go new file mode 100644 index 00000000..98d4eeac --- /dev/null +++ b/dataviewer/workflows/workflow.go @@ -0,0 +1,234 @@ +package workflows + +import ( + "fmt" + "log/slog" + "time" + + sdktemporal "go.temporal.io/sdk/temporal" + "go.temporal.io/sdk/worker" + "go.temporal.io/sdk/workflow" + "opencsg.com/csghub-server/builder/temporal" + "opencsg.com/csghub-server/common/config" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +func BuildDataViewerRunWorker(tc temporal.Client, cfg *config.Config, act DataViewerActivity) error { + workerOptions := worker.Options{ + MaxConcurrentActivityExecutionSize: cfg.DataViewer.MaxConcurrentActivityExecutionSize, + MaxConcurrentLocalActivityExecutionSize: cfg.DataViewer.MaxConcurrentLocalActivityExecutionSize, + MaxConcurrentWorkflowTaskExecutionSize: cfg.DataViewer.MaxConcurrentWorkflowTaskExecutionSize, + EnableSessionWorker: true, + MaxConcurrentSessionExecutionSize: cfg.DataViewer.MaxConcurrentSessionExecutionSize, + } + slog.Info("run viewer worker", slog.Any("options", cfg.DataViewer)) + wr := tc.NewWorker(dvCom.TaskQueueDataViewerDatasetUpdate, workerOptions) + + wr.RegisterActivity(act.BeginViewerJob) + wr.RegisterActivity(act.GetCardFromReadme) + wr.RegisterActivity(act.ScanRepoFiles) + wr.RegisterActivity(act.DetermineCardData) + wr.RegisterActivity(act.CheckIfNeedRebuild) + wr.RegisterActivity(act.CreateParquetBranch) + wr.RegisterActivity(act.CopyParquetFiles) + wr.RegisterActivity(act.DownloadSplitFiles) + wr.RegisterActivity(act.ConvertToParquetFiles) + wr.RegisterActivity(act.UploadParquetFiles) + wr.RegisterActivity(act.UpdateCardData) + wr.RegisterActivity(act.CleanUp) + wr.RegisterActivity(act.UpdateWorkflowStatus) + + wr.RegisterWorkflow(DataViewerUpdateWorkflow) + + err := tc.Start() + if err != nil { + return fmt.Errorf("failed to start worker: %w", err) + } + return nil +} + +func DataViewerUpdateWorkflow(ctx workflow.Context, updateReq dvCom.WorkflowUpdateParams) error { + info := workflow.GetInfo(ctx) + workflowID := info.WorkflowExecution.ID + runID := info.WorkflowExecution.RunID + slog.Debug("start workflow", slog.Any("workflowID", workflowID), slog.Any("runID", runID), slog.Any("req", updateReq.Req)) + + retryPolicy := &sdktemporal.RetryPolicy{ + InitialInterval: 2 * time.Minute, + MaximumAttempts: updateReq.Config.DataViewer.ActivityMaximumAttempts, + } + + workflowActivityTimeout := time.Duration(updateReq.Config.DataViewer.ActivityStartToCloseTimeout) * time.Second + ao := workflow.ActivityOptions{ + StartToCloseTimeout: workflowActivityTimeout, + RetryPolicy: retryPolicy, + } + ctx = workflow.WithActivityOptions(ctx, ao) + + sessionExecTimeout := time.Duration(updateReq.Config.DataViewer.SessionExecutionTimeout) * time.Minute + so := &workflow.SessionOptions{ + CreationTimeout: 5 * time.Minute, + ExecutionTimeout: sessionExecTimeout, + } + + sessionCtx, err := workflow.CreateSession(ctx, so) + if err != nil { + return fmt.Errorf("create workflow session error: %w", err) + } + defer workflow.CompleteSession(sessionCtx) + + shouldUpdateViewer, err := runWorkFlow(sessionCtx, updateReq) + updateWorkflowStatus(sessionCtx, updateReq, err, shouldUpdateViewer) + if err != nil { + return fmt.Errorf("run data viewer workflow error: %w", err) + } + return nil +} + +func runWorkFlow(sessionCtx workflow.Context, updateWorkflow dvCom.WorkflowUpdateParams) (bool, error) { + var err error + + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.BeginViewerJob).Get(sessionCtx, nil) + if err != nil { + return false, fmt.Errorf("run data viewer activity BeginViewerJob error: %w", err) + } + + var definedCardData dvCom.CardData + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.GetCardFromReadme, updateWorkflow.Req).Get(sessionCtx, &definedCardData) + if err != nil { + return false, fmt.Errorf("run data viewer activity GetCardFromReadme error: %w", err) + } + + var repoFileClass dvCom.RepoFilesClass + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.ScanRepoFiles, + dvCom.ScanRepoFileReq{ + Req: updateWorkflow.Req, + MaxFileSize: updateWorkflow.Config.DataViewer.MaxFileSize}, + ).Get(sessionCtx, &repoFileClass) + if err != nil { + return false, fmt.Errorf("run data viewer activity GetCardFromReadme error: %w", err) + } + + var repoDataType dvCom.RepoDataType + + if len(repoFileClass.ParquetFiles) > 0 { + repoDataType = RepoParquetData + } else if len(repoFileClass.JsonlFiles) > 0 { + repoDataType = RepoJsonData + } else if len(repoFileClass.CsvFiles) > 0 { + repoDataType = RepoCsvData + } + + var computedCardData dvCom.CardData + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.DetermineCardData, dvCom.DetermineCardReq{ + Card: definedCardData, + Class: repoFileClass, + RepoDataType: repoDataType, + }).Get(sessionCtx, &computedCardData) + if err != nil { + return false, fmt.Errorf("run data viewer activity DetermineCardData error: %w", err) + } + + var needRebuild bool + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.CheckIfNeedRebuild, dvCom.CheckBuildReq{ + Req: updateWorkflow.Req, + Card: computedCardData, + }).Get(sessionCtx, &needRebuild) + if err != nil { + return false, fmt.Errorf("run data viewer activity CheckIfNeedRebuild error: %w", err) + } + + if !needRebuild { + return false, nil + } + + var newBranch string + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.CreateParquetBranch, updateWorkflow.Req).Get(sessionCtx, &newBranch) + if err != nil { + return false, fmt.Errorf("run data viewer activity CreateParquetBranch error: %w", err) + } + if len(newBranch) < 1 { + return false, fmt.Errorf("run data viewer activity CreateParquetBranch error and new branch is empty") + } + + var finalCardData dvCom.CardData + + if repoDataType == RepoParquetData { + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.CopyParquetFiles, dvCom.CopyParquetReq{ + Req: updateWorkflow.Req, + ComputedCardData: computedCardData, + NewBranch: newBranch, + }).Get(sessionCtx, &finalCardData) + if err != nil { + return false, fmt.Errorf("run data viewer activity CopyParquetFiles error: %w", err) + } + } else if repoDataType == RepoJsonData || repoDataType == RepoCsvData { + var downloadCard dvCom.DownloadCard + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.DownloadSplitFiles, + dvCom.DownloadFileReq{ + Req: updateWorkflow.Req, + Card: computedCardData, + }, + ).Get(sessionCtx, &downloadCard) + if err != nil { + return false, fmt.Errorf("run data viewer activity CopyParquetFiles error: %w", err) + } + + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.ConvertToParquetFiles, + dvCom.ConvertReq{ + Req: updateWorkflow.Req, + DownloadCard: downloadCard, + RepoDataType: repoDataType, + }, + ).Get(sessionCtx, nil) + if err != nil { + return false, fmt.Errorf("run data viewer activity ConvertToParquetFiles error: %w", err) + } + + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.UploadParquetFiles, + dvCom.UploadParquetReq{ + Req: updateWorkflow.Req, + DownloadCard: downloadCard, + NewBranch: newBranch, + }, + ).Get(sessionCtx, &finalCardData) + if err != nil { + return false, fmt.Errorf("run data viewer activity UploadParquetFiles error: %w", err) + } + } + + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.UpdateCardData, + dvCom.UpdateCardReq{ + Req: updateWorkflow.Req, + OriginCardData: definedCardData, + FinalCardData: finalCardData, + }, + ).Get(sessionCtx, nil) + if err != nil { + return false, fmt.Errorf("run data viewer activity UpdateCardData error: %w", err) + } + + err = workflow.ExecuteActivity(sessionCtx, DataViewerActivity.CleanUp, updateWorkflow.Req).Get(sessionCtx, nil) + if err != nil { + return false, fmt.Errorf("run data viewer activity CleanUp error: %w", err) + } + + return true, nil +} + +func updateWorkflowStatus(sessionCtx workflow.Context, + updateWorkflow dvCom.WorkflowUpdateParams, + wfErr error, + shouldUpdateViewer bool, +) { + err := workflow.ExecuteActivity(sessionCtx, DataViewerActivity.UpdateWorkflowStatus, + dvCom.UpdateWorkflowStatusReq{ + Req: updateWorkflow.Req, + WorkflowErr: wfErr, + ShouldUpdateViewer: shouldUpdateViewer, + }, + ).Get(sessionCtx, nil) + if err != nil { + slog.Error("run data viewer workflow update activity", slog.Any("error", err)) + } +} diff --git a/dataviewer/workflows/workflow_test.go b/dataviewer/workflows/workflow_test.go new file mode 100644 index 00000000..19609e71 --- /dev/null +++ b/dataviewer/workflows/workflow_test.go @@ -0,0 +1,222 @@ +package workflows + +import ( + "testing" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "go.temporal.io/sdk/testsuite" + "go.temporal.io/sdk/worker" + mock_temporal "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/temporal" + mock_activity "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/dataviewer/workflows" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" + dvCom "opencsg.com/csghub-server/dataviewer/common" +) + +type workflowTester struct { + env *testsuite.TestWorkflowEnvironment + mocks struct { + mockact *mock_activity.MockDataViewerActivity + } +} + +func newWorkflowTester(t *testing.T) (*workflowTester, error) { + suite := testsuite.WorkflowTestSuite{} + tester := &workflowTester{ + env: suite.NewTestWorkflowEnvironment(), + } + tester.env.SetWorkerOptions(worker.Options{ + EnableSessionWorker: true, + }) + + mockact := mock_activity.NewMockDataViewerActivity(t) + tester.mocks.mockact = mockact + + cfg, err := config.LoadConfig() + require.Nil(t, err) + + mtc := mock_temporal.NewMockClient(t) + mtc.EXPECT().NewWorker(dvCom.TaskQueueDataViewerDatasetUpdate, mock.Anything).Return(tester.env) + mtc.EXPECT().Start().Return(nil) + + err = BuildDataViewerRunWorker(mtc, cfg, mockact) + + if err != nil { + return nil, err + } + + return tester, nil +} + +func TestWorkflow_DataviewerWorkflow(t *testing.T) { + t.Run("json/csv", func(t *testing.T) { + tester, err := newWorkflowTester(t) + require.NoError(t, err) + + cfg, err := config.LoadConfig() + require.Nil(t, err) + + req := types.UpdateViewerReq{ + Namespace: "test", + Name: "test", + Branch: "test", + RepoType: types.DatasetRepo, + } + + tester.mocks.mockact.EXPECT().BeginViewerJob(mock.Anything).Return(nil) + tester.mocks.mockact.EXPECT().GetCardFromReadme(mock.Anything, req).Return(&dvCom.CardData{}, nil) + tester.mocks.mockact.EXPECT().ScanRepoFiles(mock.Anything, + dvCom.ScanRepoFileReq{ + Req: req, + MaxFileSize: cfg.DataViewer.MaxFileSize, + }).Return(&dvCom.RepoFilesClass{ + JsonlFiles: map[string]*types.File{ + "test": { + Path: "test", + Size: 1024, + }, + }, + }, nil) + tester.mocks.mockact.EXPECT().DetermineCardData(mock.Anything, + dvCom.DetermineCardReq{ + Card: dvCom.CardData{}, + Class: dvCom.RepoFilesClass{ + JsonlFiles: map[string]*types.File{ + "test": { + Path: "test", + Size: 1024, + }, + }, + }, + RepoDataType: RepoJsonData, + }).Return(&dvCom.CardData{}, nil) + + tester.mocks.mockact.EXPECT().CheckIfNeedRebuild(mock.Anything, dvCom.CheckBuildReq{ + Req: req, + Card: dvCom.CardData{}, + }).Return(true, nil) + + tester.mocks.mockact.EXPECT().CreateParquetBranch(mock.Anything, req).Return(dvCom.ParquetBranch, nil) + + tester.mocks.mockact.EXPECT().DownloadSplitFiles(mock.Anything, + dvCom.DownloadFileReq{ + Req: req, + Card: dvCom.CardData{}, + }, + ).Return(&dvCom.DownloadCard{}, nil) + + tester.mocks.mockact.EXPECT().ConvertToParquetFiles(mock.Anything, dvCom.ConvertReq{ + Req: req, + DownloadCard: dvCom.DownloadCard{}, + RepoDataType: RepoJsonData, + }).Return(nil) + + tester.mocks.mockact.EXPECT().UploadParquetFiles(mock.Anything, dvCom.UploadParquetReq{ + Req: req, + DownloadCard: dvCom.DownloadCard{}, + NewBranch: dvCom.ParquetBranch, + }).Return(&dvCom.CardData{}, nil) + + tester.mocks.mockact.EXPECT().UpdateCardData(mock.Anything, dvCom.UpdateCardReq{ + Req: req, + OriginCardData: dvCom.CardData{}, + FinalCardData: dvCom.CardData{}, + }).Return(nil) + + tester.mocks.mockact.EXPECT().CleanUp(mock.Anything, req).Return(nil) + + tester.mocks.mockact.EXPECT().UpdateWorkflowStatus(mock.Anything, dvCom.UpdateWorkflowStatusReq{ + Req: req, + WorkflowErr: nil, + ShouldUpdateViewer: true, + }).Return(nil) + + tester.env.ExecuteWorkflow(DataViewerUpdateWorkflow, dvCom.WorkflowUpdateParams{ + Req: req, + Config: cfg, + }) + + require.True(t, tester.env.IsWorkflowCompleted()) + require.NoError(t, tester.env.GetWorkflowError()) + }) + + t.Run("parquet", func(t *testing.T) { + tester, err := newWorkflowTester(t) + require.NoError(t, err) + + cfg, err := config.LoadConfig() + require.Nil(t, err) + + req := types.UpdateViewerReq{ + Namespace: "test", + Name: "test", + Branch: "test", + RepoType: types.DatasetRepo, + } + + tester.mocks.mockact.EXPECT().BeginViewerJob(mock.Anything).Return(nil) + tester.mocks.mockact.EXPECT().GetCardFromReadme(mock.Anything, req).Return(&dvCom.CardData{}, nil) + tester.mocks.mockact.EXPECT().ScanRepoFiles(mock.Anything, + dvCom.ScanRepoFileReq{ + Req: req, + MaxFileSize: cfg.DataViewer.MaxFileSize, + }).Return(&dvCom.RepoFilesClass{ + ParquetFiles: map[string]*types.File{ + "test": { + Path: "test", + Size: 1024, + }, + }, + }, nil) + tester.mocks.mockact.EXPECT().DetermineCardData(mock.Anything, + dvCom.DetermineCardReq{ + Card: dvCom.CardData{}, + Class: dvCom.RepoFilesClass{ + ParquetFiles: map[string]*types.File{ + "test": { + Path: "test", + Size: 1024, + }, + }, + }, + RepoDataType: RepoParquetData, + }).Return(&dvCom.CardData{}, nil) + + tester.mocks.mockact.EXPECT().CheckIfNeedRebuild(mock.Anything, dvCom.CheckBuildReq{ + Req: req, + Card: dvCom.CardData{}, + }).Return(true, nil) + + tester.mocks.mockact.EXPECT().CreateParquetBranch(mock.Anything, req).Return(dvCom.ParquetBranch, nil) + + tester.mocks.mockact.EXPECT().CopyParquetFiles(mock.Anything, dvCom.CopyParquetReq{ + Req: req, + ComputedCardData: dvCom.CardData{}, + NewBranch: dvCom.ParquetBranch, + }).Return(&dvCom.CardData{}, nil) + + tester.mocks.mockact.EXPECT().UpdateCardData(mock.Anything, dvCom.UpdateCardReq{ + Req: req, + OriginCardData: dvCom.CardData{}, + FinalCardData: dvCom.CardData{}, + }).Return(nil) + + tester.mocks.mockact.EXPECT().CleanUp(mock.Anything, req).Return(nil) + + tester.mocks.mockact.EXPECT().UpdateWorkflowStatus(mock.Anything, dvCom.UpdateWorkflowStatusReq{ + Req: req, + WorkflowErr: nil, + ShouldUpdateViewer: true, + }).Return(nil) + + tester.env.ExecuteWorkflow(DataViewerUpdateWorkflow, dvCom.WorkflowUpdateParams{ + Req: req, + Config: cfg, + }) + + require.True(t, tester.env.IsWorkflowCompleted()) + require.NoError(t, tester.env.GetWorkflowError()) + }) + +} diff --git a/docs/docs.go b/docs/docs.go index f9a21d12..fc9e0cb1 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1736,6 +1736,150 @@ const docTemplate = `{ } } }, + "/datasets/{namespace}/{name}/dataviewer/catalog": { + "get": { + "security": [ + { + "ApiKey": [] + } + ], + "description": "get catalog of the dataset", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Dataset" + ], + "summary": "Get catalog of the dataset", + "parameters": [ + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.Response" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/types.APIInternalServerError" + } + } + } + } + }, + "/datasets/{namespace}/{name}/dataviewer/rows": { + "get": { + "security": [ + { + "ApiKey": [] + } + ], + "description": "get catalog of the dataset", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Dataset" + ], + "summary": "Get catalog of the dataset", + "parameters": [ + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "config", + "name": "config", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "split", + "name": "split", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "search", + "name": "search", + "in": "query" + }, + { + "type": "string", + "description": "where", + "name": "where", + "in": "query" + }, + { + "type": "string", + "description": "orderby", + "name": "orderby", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.Response" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/types.APIInternalServerError" + } + } + } + } + }, "/datasets/{namespace}/{name}/relations": { "get": { "security": [ @@ -1809,6 +1953,76 @@ const docTemplate = `{ } } }, + "/datasets/{namespace}/{name}/viewer/{file_path}": { + "get": { + "security": [ + { + "ApiKey": [] + } + ], + "description": "get the demo data of the dataset", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Dataset" + ], + "summary": "Get the demo data of the dataset", + "parameters": [ + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "file_path", + "name": "file_path", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.Response" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/types.APIInternalServerError" + } + } + } + } + }, "/discussions/{id}": { "get": { "security": [ diff --git a/docs/swagger.json b/docs/swagger.json index 98ba9fbc..159a6f07 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -4,14 +4,14 @@ "contact": {} }, "paths": { - "/accounting/credit/balance": { + "/accounting/metering/{id}/statements": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get all users balance", + "description": "List meterings by user uuid and start time and end time", "consumes": [ "application/json" ], @@ -21,8 +21,49 @@ "tags": [ "Accounting" ], - "summary": "Get all users balance", + "summary": "List meterings by user uuid and start time and end time", "parameters": [ + { + "type": "string", + "description": "user uuid", + "name": "id", + "in": "path", + "required": true + }, + { + "enum": [ + 10, + 11, + 12, + 20 + ], + "type": "integer", + "default": 10, + "description": "scene", + "name": "scene", + "in": "query" + }, + { + "type": "string", + "description": "instance name", + "name": "instance_name", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "start_time, format: '2024-06-12 08:27:22'", + "name": "start_time", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "end_time, format: '2024-06-12 17:17:22'", + "name": "end_time", + "in": "query", + "required": true + }, { "type": "string", "description": "current_user", @@ -67,14 +108,14 @@ } } }, - "/accounting/credit/{id}/balance": { + "/cluster": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get user balance by user uuid", + "description": "Get cluster list", "consumes": [ "application/json" ], @@ -82,25 +123,49 @@ "application/json" ], "tags": [ - "Accounting" + "Cluster" ], - "summary": "Get user balance by user uuid", - "parameters": [ - { - "type": "string", - "description": "user uuid", - "name": "id", - "in": "path", - "required": true + "summary": "Get cluster list", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.Response" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/types.APIInternalServerError" + } + } + } + } + }, + "/cluster/{id}": { + "get": { + "security": [ { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true + "ApiKey": [] } ], + "description": "Get cluster by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Cluster" + ], + "summary": "Get cluster by id", "responses": { "200": { "description": "OK", @@ -123,14 +188,14 @@ } } }, - "/accounting/credit/{id}/bills": { + "/codes": { "get": { "security": [ { "ApiKey": [] } ], - "description": "List user bills by user uuid and start date and end date", + "description": "get visiable codes for current user", "consumes": [ "application/json" ], @@ -138,50 +203,62 @@ "application/json" ], "tags": [ - "Accounting" + "Code" ], - "summary": "List user bills by user uuid and start date and end date", + "summary": "Get Visiable codes for current user", "parameters": [ { "type": "string", - "description": "user uuid", - "name": "id", - "in": "path", - "required": true + "description": "current user", + "name": "current_user", + "in": "query" }, { - "enum": [ - 10, - 11, - 12, - 20 - ], - "type": "integer", - "default": 10, - "description": "scene", - "name": "scene", + "type": "string", + "description": "search text", + "name": "search", "in": "query" }, { "type": "string", - "description": "start_date, format: '2024-06-12'", - "name": "start_date", - "in": "query", - "required": true + "description": "filter by task tag", + "name": "task_tag", + "in": "query" }, { "type": "string", - "description": "end_date, format: '2024-07-12'", - "name": "end_date", - "in": "query", - "required": true + "description": "filter by framework tag", + "name": "framework_tag", + "in": "query" }, { "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true + "description": "filter by license tag", + "name": "license_tag", + "in": "query" + }, + { + "type": "string", + "description": "filter by language tag", + "name": "language_tag", + "in": "query" + }, + { + "type": "string", + "description": "sort by", + "name": "sort", + "in": "query" + }, + { + "enum": [ + "opencsg", + "huggingface", + "local" + ], + "type": "string", + "description": "source", + "name": "source", + "in": "query" }, { "type": "integer", @@ -202,7 +279,25 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Code" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -218,16 +313,14 @@ } } } - } - }, - "/accounting/credit/{id}/recharge": { - "put": { + }, + "post": { "security": [ { "ApiKey": [] } ], - "description": "Recharge fee for account", + "description": "create a new code", "consumes": [ "application/json" ], @@ -235,23 +328,15 @@ "application/json" ], "tags": [ - "Accounting" + "Code" ], - "summary": "Recharge fee for account", + "summary": "Create a new code", "parameters": [ { "type": "string", - "description": "user uuid", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", + "description": "current user, the owner", "name": "current_user", - "in": "query", - "required": true + "in": "query" }, { "description": "body", @@ -259,7 +344,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.RECHARGE_REQ" + "$ref": "#/definitions/types.CreateCodeReq" } } ], @@ -267,7 +352,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Code" + } + } + } + ] } }, "400": { @@ -285,14 +382,14 @@ } } }, - "/accounting/credit/{id}/statements": { + "/codes/{namespace}/{name}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "List statements by user uuid and start time and end time", + "description": "get code detail", "consumes": [ "application/json" ], @@ -300,78 +397,49 @@ "application/json" ], "tags": [ - "Accounting" + "Code" ], - "summary": "List statements by user uuid and start time and end time", + "summary": "Get code detail", "parameters": [ { "type": "string", - "description": "user uuid", - "name": "id", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, - { - "enum": [ - 10, - 11, - 12, - 20 - ], - "type": "integer", - "default": 10, - "description": "scene", - "name": "scene", - "in": "query" - }, { "type": "string", - "description": "instance name", - "name": "instance_name", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true }, { "type": "string", - "description": "start_time, format: '2024-06-12 08:27:22'", - "name": "start_time", + "description": "current_user", + "name": "current_user", "in": "query", "required": true - }, - { - "type": "string", - "description": "end_time, format: '2024-06-12 17:17:22'", - "name": "end_time", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Code" + } + } + } + ] } }, "400": { @@ -387,16 +455,14 @@ } } } - } - }, - "/accounting/metering/{id}/statements": { - "get": { + }, + "put": { "security": [ { "ApiKey": [] } ], - "description": "List meterings by user uuid and start time and end time", + "description": "update a exists code", "consumes": [ "application/json" ], @@ -404,78 +470,57 @@ "application/json" ], "tags": [ - "Accounting" + "Code" ], - "summary": "List meterings by user uuid and start time and end time", + "summary": "Update a exists code", "parameters": [ { "type": "string", - "description": "user uuid", - "name": "id", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, - { - "enum": [ - 10, - 11, - 12, - 20 - ], - "type": "integer", - "default": 10, - "description": "scene", - "name": "scene", - "in": "query" - }, - { - "type": "string", - "description": "instance name", - "name": "instance_name", - "in": "query", - "required": true - }, { "type": "string", - "description": "start_time, format: '2024-06-12 08:27:22'", - "name": "start_time", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "end_time, format: '2024-06-12 17:17:22'", - "name": "end_time", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true }, { "type": "string", - "description": "current_user", + "description": "current user, the owner", "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", "in": "query" }, { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateCodeReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.Code" + } + } + } + ] } }, "400": { @@ -491,16 +536,14 @@ } } } - } - }, - "/accounting/multisync/download": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] } ], - "description": "Get account quota statement", + "description": "delete a exists code", "consumes": [ "application/json" ], @@ -508,23 +551,29 @@ "application/json" ], "tags": [ - "Accounting" + "Code" ], - "summary": "Get account quota statement", + "summary": "Delete a exists code", "parameters": [ { "type": "string", - "description": "repo path", - "name": "repo_path", - "in": "query", + "description": "namespace", + "name": "namespace", + "in": "path", "required": true }, { "type": "string", - "description": "repo type", - "name": "repo_type", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true + }, + { + "type": "string", + "description": "current user, the owner", + "name": "current_user", + "in": "query" } ], "responses": { @@ -549,14 +598,13 @@ } } }, - "/accounting/multisync/downloads": { - "post": { + "/codes/{namespace}/{name}/relations": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Add download count", "consumes": [ "application/json" ], @@ -564,32 +612,48 @@ "application/json" ], "tags": [ - "Accounting" + "Code" ], - "summary": "Add download count", + "summary": "Get code related assets", "parameters": [ { "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", + "description": "namespace", + "name": "namespace", + "in": "path", "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ACCT_QUOTA_STATEMENT_REQ" - } + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current_user", + "name": "current_user", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Relations" + } + } + } + ] } }, "400": { @@ -607,14 +671,9 @@ } } }, - "/accounting/multisync/quota": { + "/collections": { "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get account quota by user id", + "description": "get all collections", "consumes": [ "application/json" ], @@ -622,23 +681,61 @@ "application/json" ], "tags": [ - "Accounting" + "Collection" ], - "summary": "Get account quota by user id", + "summary": "get all collections", "parameters": [ { "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true + "description": "search text", + "name": "search", + "in": "query" + }, + { + "type": "string", + "default": "\"trending\"", + "description": "sort by", + "name": "sort", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Collection" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -654,16 +751,14 @@ } } } - } - }, - "/accounting/multisync/quotas": { + }, "post": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "Add or update account quota", + "description": "create a collection", "consumes": [ "application/json" ], @@ -671,24 +766,17 @@ "application/json" ], "tags": [ - "Accounting" + "Collection" ], - "summary": "Add or update account quota", + "summary": "create a collection", "parameters": [ - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.ACCT_QUOTA_REQ" + "$ref": "#/definitions/types.CreateCollectionReq" } } ], @@ -696,7 +784,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Collection" + } + } + } + ] } }, "400": { @@ -714,14 +814,9 @@ } } }, - "/accounting/price": { + "/collections/{id}": { "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "List sku prices", + "description": "get a collection detail", "consumes": [ "application/json" ], @@ -729,63 +824,35 @@ "application/json" ], "tags": [ - "Accounting" + "Collection" ], - "summary": "List sku prices", + "summary": "get a collection detail", "parameters": [ - { - "enum": [ - "1", - "2" - ], - "type": "string", - "default": "1", - "description": "sku_type", - "name": "sku_type", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "sku_kind", - "name": "sku_kind", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "resource_id", - "name": "resource_id", - "in": "query", - "required": true - }, { "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", + "description": "id", + "name": "id", + "in": "path", "required": true - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Collection" + } + } + } + ] } }, "400": { @@ -802,13 +869,13 @@ } } }, - "post": { + "put": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "Add sku price", + "description": "update a collection", "consumes": [ "application/json" ], @@ -816,32 +883,44 @@ "application/json" ], "tags": [ - "Accounting" + "Collection" ], - "summary": "Add sku price", + "summary": "update a collection", "parameters": [ - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.AcctPriceCreateReq" + "$ref": "#/definitions/types.CreateCollectionReq" } + }, + { + "type": "string", + "description": "id", + "name": "id", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Collection" + } + } + } + ] } }, "400": { @@ -857,16 +936,14 @@ } } } - } - }, - "/accounting/price/{id}": { - "get": { + }, + "delete": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "Get price by id", + "description": "delete a exists collection", "consumes": [ "application/json" ], @@ -874,23 +951,16 @@ "application/json" ], "tags": [ - "Accounting" + "Collection" ], - "summary": "Get price by id", + "summary": "Delete a exists collection", "parameters": [ { - "type": "integer", + "type": "string", "description": "id", "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true } ], "responses": { @@ -913,14 +983,16 @@ } } } - }, - "put": { + } + }, + "/collections/{id}/repos": { + "post": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "Update sku price", + "description": "Add repos to a collection", "consumes": [ "application/json" ], @@ -928,39 +1000,44 @@ "application/json" ], "tags": [ - "Accounting" + "Collection" ], - "summary": "Update sku price", + "summary": "Add repos to a collection", "parameters": [ - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.AcctPriceCreateReq" + "$ref": "#/definitions/types.UpdateCollectionReposReq" } + }, + { + "type": "string", + "description": "id", + "name": "id", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.Collection" + } + } + } + ] } }, "400": { @@ -980,10 +1057,10 @@ "delete": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "Delete price by id", + "description": "remove repos from a collection", "consumes": [ "application/json" ], @@ -991,22 +1068,24 @@ "application/json" ], "tags": [ - "Accounting" + "Collection" ], - "summary": "Delete price by id", + "summary": "remove repos from a collection", "parameters": [ { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateCollectionReposReq" + } }, { "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", + "description": "id", + "name": "id", + "in": "path", "required": true } ], @@ -1014,7 +1093,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Collection" + } + } + } + ] } }, "400": { @@ -1032,14 +1123,14 @@ } } }, - "/accounting/recharge/create-pay-order": { - "post": { + "/comments/{id}": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "Create recharge order", + "description": "update a comment content by id", "consumes": [ "application/json" ], @@ -1047,17 +1138,31 @@ "application/json" ], "tags": [ - "Accounting" + "Discussion" ], - "summary": "Create recharge order", + "summary": "Update a comment content by id", "parameters": [ { - "description": "Recharge request payload", + "type": "string", + "description": "the comment id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user, the owner of the comment", + "name": "current_user", + "in": "query", + "required": true + }, + { + "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.AcctRechargeReq" + "$ref": "#/definitions/types.UpdateCommentRequest" } } ], @@ -1065,7 +1170,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.AcctRechargeResp" + "$ref": "#/definitions/types.Response" } }, "400": { @@ -1081,16 +1186,14 @@ } } } - } - }, - "/accounting/recharge/user-recharge-list": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] } ], - "description": "List current user recharge list by start_time and end_time and query", + "description": "delete a comment by id", "consumes": [ "application/json" ], @@ -1098,193 +1201,25 @@ "application/json" ], "tags": [ - "Accounting" + "Discussion" ], - "summary": "List current user recharge list by start_time and end_time and query", + "summary": "Delete a comment by id", "parameters": [ { "type": "string", - "description": "Recharge status, options: 'succeed, waitpay'", - "name": "recharge_status", - "in": "query" - }, - { - "type": "string", - "description": "Recharge payment type, options: 'wx_pub_qr, alipay_qr'", - "name": "recharge_payment_type", - "in": "query" - }, - { - "type": "string", - "description": "Query string against recharge uuid", - "name": "query", - "in": "query" - }, - { - "type": "string", - "description": "Start time, format: '2024-06-12 08:27:22'", - "name": "start_time", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "End time, format: '2024-06-12 17:17:22'", - "name": "end_time", - "in": "query", + "description": "the comment id", + "name": "id", + "in": "path", "required": true }, { "type": "string", - "description": "Current user identifier", + "description": "current user, the owner of the comment", "name": "current_user", "in": "query", "required": true - }, - { - "type": "integer", - "default": 50, - "description": "Items per page", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "Page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/accounting/recharge/{id}/status": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Fetch recharge order status by recharge id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Accounting" - ], - "summary": "Fetch recharge order status by recharge id", - "parameters": [ - { - "type": "string", - "description": "recharge uuid", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.RechargeStatusResp" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/cluster": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get cluster list", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Cluster" - ], - "summary": "Get cluster list", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/cluster/{id}": { - "get": { - "security": [ - { - "ApiKey": [] } ], - "description": "Get cluster by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Cluster" - ], - "summary": "Get cluster by id", "responses": { "200": { "description": "OK", @@ -1307,14 +1242,14 @@ } } }, - "/codes": { + "/datasets": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get visiable codes for current user", + "description": "get visiable datasets for current user", "consumes": [ "application/json" ], @@ -1322,9 +1257,9 @@ "application/json" ], "tags": [ - "Code" + "Dataset" ], - "summary": "Get Visiable codes for current user", + "summary": "Get Visiable datasets for current user", "parameters": [ { "type": "string", @@ -1408,7 +1343,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/types.Code" + "$ref": "#/definitions/types.Dataset" } }, "total": { @@ -1439,7 +1374,7 @@ "ApiKey": [] } ], - "description": "create a new code", + "description": "create a new dataset", "consumes": [ "application/json" ], @@ -1447,9 +1382,9 @@ "application/json" ], "tags": [ - "Code" + "Dataset" ], - "summary": "Create a new code", + "summary": "Create a new dataset", "parameters": [ { "type": "string", @@ -1463,7 +1398,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateCodeReq" + "$ref": "#/definitions/types.CreateDatasetReq" } } ], @@ -1479,7 +1414,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Code" + "$ref": "#/definitions/types.Dataset" } } } @@ -1501,14 +1436,14 @@ } } }, - "/codes/{namespace}/{name}": { + "/datasets/{namespace}/{name}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get code detail", + "description": "get dataset detail", "consumes": [ "application/json" ], @@ -1516,9 +1451,9 @@ "application/json" ], "tags": [ - "Code" + "Dataset" ], - "summary": "Get code detail", + "summary": "Get dataset detail", "parameters": [ { "type": "string", @@ -1554,7 +1489,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Code" + "$ref": "#/definitions/types.Dataset" } } } @@ -1581,7 +1516,7 @@ "ApiKey": [] } ], - "description": "update a exists code", + "description": "update a exists dataset", "consumes": [ "application/json" ], @@ -1589,9 +1524,9 @@ "application/json" ], "tags": [ - "Code" + "Dataset" ], - "summary": "Update a exists code", + "summary": "Update a exists dataset", "parameters": [ { "type": "string", @@ -1619,7 +1554,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateCodeReq" + "$ref": "#/definitions/types.UpdateDatasetReq" } } ], @@ -1635,7 +1570,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/database.Code" + "$ref": "#/definitions/database.Dataset" } } } @@ -1662,7 +1597,7 @@ "ApiKey": [] } ], - "description": "delete a exists code", + "description": "delete a exists dataset", "consumes": [ "application/json" ], @@ -1670,9 +1605,9 @@ "application/json" ], "tags": [ - "Code" + "Dataset" ], - "summary": "Delete a exists code", + "summary": "Delete a exists dataset", "parameters": [ { "type": "string", @@ -1717,7 +1652,7 @@ } } }, - "/codes/{namespace}/{name}/relations": { + "/datasets/{namespace}/{name}/all_files": { "get": { "security": [ { @@ -1731,9 +1666,9 @@ "application/json" ], "tags": [ - "Code" + "Dataset" ], - "summary": "Get code related assets", + "summary": "Get all files of a dataset", "parameters": [ { "type": "string", @@ -1751,7 +1686,7 @@ }, { "type": "string", - "description": "current_user", + "description": "current user", "name": "current_user", "in": "query" } @@ -1768,7 +1703,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Relations" + "$ref": "#/definitions/types.File" } } } @@ -1790,9 +1725,14 @@ } } }, - "/collections": { + "/datasets/{namespace}/{name}/dataviewer/catalog": { "get": { - "description": "get all collections", + "security": [ + { + "ApiKey": [] + } + ], + "description": "get catalog of the dataset", "consumes": [ "application/json" ], @@ -1800,61 +1740,23 @@ "application/json" ], "tags": [ - "Collection" + "Dataset" ], - "summary": "get all collections", + "summary": "Get catalog of the dataset", "parameters": [ { "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "default": "\"trending\"", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Collection" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -1870,14 +1772,16 @@ } } } - }, - "post": { + } + }, + "/datasets/{namespace}/{name}/dataviewer/rows": { + "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], - "description": "create a collection", + "description": "get catalog of the dataset", "consumes": [ "application/json" ], @@ -1885,93 +1789,69 @@ "application/json" ], "tags": [ - "Collection" + "Dataset" ], - "summary": "create a collection", + "summary": "Get catalog of the dataset", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCollectionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Collection" - } - } - } - ] - } + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + { + "type": "string", + "description": "config", + "name": "config", + "in": "query", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/collections/{id}": { - "get": { - "description": "get a collection detail", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Collection" - ], - "summary": "get a collection detail", - "parameters": [ { "type": "string", - "description": "id", - "name": "id", - "in": "path", + "description": "split", + "name": "split", + "in": "query", "required": true + }, + { + "type": "string", + "description": "search", + "name": "search", + "in": "query" + }, + { + "type": "string", + "description": "where", + "name": "where", + "in": "query" + }, + { + "type": "string", + "description": "orderby", + "name": "orderby", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Collection" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -1987,14 +1867,15 @@ } } } - }, - "put": { + } + }, + "/datasets/{namespace}/{name}/relations": { + "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], - "description": "update a collection", "consumes": [ "application/json" ], @@ -2002,25 +1883,29 @@ "application/json" ], "tags": [ - "Collection" + "Dataset" ], - "summary": "update a collection", + "summary": "Get dataset related assets", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCollectionReq" - } + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, { "type": "string", - "description": "id", - "name": "id", + "description": "name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "current_user", + "name": "current_user", + "in": "query" } ], "responses": { @@ -2035,7 +1920,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Collection" + "$ref": "#/definitions/types.Relations" } } } @@ -2055,14 +1940,16 @@ } } } - }, - "delete": { + } + }, + "/datasets/{namespace}/{name}/viewer/{file_path}": { + "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], - "description": "delete a exists collection", + "description": "get the demo data of the dataset", "consumes": [ "application/json" ], @@ -2070,16 +1957,37 @@ "application/json" ], "tags": [ - "Collection" + "Dataset" ], - "summary": "Delete a exists collection", + "summary": "Get the demo data of the dataset", "parameters": [ { "type": "string", - "description": "id", - "name": "id", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "file_path", + "name": "file_path", "in": "path", "required": true + }, + { + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" } ], "responses": { @@ -2104,14 +2012,14 @@ } } }, - "/collections/{id}/repos": { - "post": { + "/discussions/{id}": { + "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], - "description": "Add repos to a collection", + "description": "show a discussion", "consumes": [ "application/json" ], @@ -2119,22 +2027,13 @@ "application/json" ], "tags": [ - "Collection" + "Discussion" ], - "summary": "Add repos to a collection", + "summary": "Show a discussion and its comments", "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCollectionReposReq" - } - }, { "type": "string", - "description": "id", + "description": "the discussion id", "name": "id", "in": "path", "required": true @@ -2152,7 +2051,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/database.Collection" + "$ref": "#/definitions/types.ShowDiscussionResponse" } } } @@ -2173,13 +2072,13 @@ } } }, - "delete": { + "put": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], - "description": "remove repos from a collection", + "description": "update a discussion", "consumes": [ "application/json" ], @@ -2187,90 +2086,20 @@ "application/json" ], "tags": [ - "Collection" + "Discussion" ], - "summary": "remove repos from a collection", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCollectionReposReq" - } - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Collection" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/comments/{id}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a comment content by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Discussion" - ], - "summary": "Update a comment content by id", + "summary": "Update a discussion", "parameters": [ { "type": "string", - "description": "the comment id", + "description": "the discussion id", "name": "id", "in": "path", "required": true }, { "type": "string", - "description": "current user, the owner of the comment", + "description": "current user, the owner", "name": "current_user", "in": "query", "required": true @@ -2281,7 +2110,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateCommentRequest" + "$ref": "#/definitions/types.UpdateDiscussionRequest" } } ], @@ -2312,7 +2141,7 @@ "ApiKey": [] } ], - "description": "delete a comment by id", + "description": "delete a discussion", "consumes": [ "application/json" ], @@ -2322,18 +2151,18 @@ "tags": [ "Discussion" ], - "summary": "Delete a comment by id", + "summary": "Delete a discussion", "parameters": [ { "type": "string", - "description": "the comment id", + "description": "the discussion id", "name": "id", "in": "path", "required": true }, { "type": "string", - "description": "current user, the owner of the comment", + "description": "current user, the owner of the discussion", "name": "current_user", "in": "query", "required": true @@ -2361,14 +2190,14 @@ } } }, - "/datasets": { + "/discussions/{id}/comments": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get visiable datasets for current user", + "description": "list discussion comments", "consumes": [ "application/json" ], @@ -2376,76 +2205,16 @@ "application/json" ], "tags": [ - "Dataset" + "Discussion" ], - "summary": "Get Visiable datasets for current user", + "summary": "List discussion comments", "parameters": [ { "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "filter by task tag", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag", - "name": "language_tag", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "enum": [ - "opencsg", - "huggingface", - "local" - ], - "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" + "description": "the discussion id", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -2454,7 +2223,7 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", @@ -2462,11 +2231,8 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/types.Dataset" + "$ref": "#/definitions/types.DiscussionResponse_Comment" } - }, - "total": { - "type": "integer" } } } @@ -2493,7 +2259,7 @@ "ApiKey": [] } ], - "description": "create a new dataset", + "description": "create a new discussion comment", "consumes": [ "application/json" ], @@ -2501,15 +2267,16 @@ "application/json" ], "tags": [ - "Dataset" + "Discussion" ], - "summary": "Create a new dataset", + "summary": "Create a new discussion comment", "parameters": [ { "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" + "description": "the discussion id", + "name": "id", + "in": "path", + "required": true }, { "description": "body", @@ -2517,7 +2284,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateDatasetReq" + "$ref": "#/definitions/types.CreateCommentRequest" } } ], @@ -2533,7 +2300,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Dataset" + "$ref": "#/definitions/types.CreateCommentResponse" } } } @@ -2555,14 +2322,13 @@ } } }, - "/datasets/{namespace}/{name}": { - "get": { + "/evaluations": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "get dataset detail", "consumes": [ "application/json" ], @@ -2570,9 +2336,9 @@ "application/json" ], "tags": [ - "Dataset" + "Evaluation" ], - "summary": "Get dataset detail", + "summary": "run model evaluation", "parameters": [ { "type": "string", @@ -2589,30 +2355,20 @@ "required": true }, { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true + "description": "body setting of evaluation", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.EvaluationReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Dataset" - } - } - } - ] + "type": "string" } }, "400": { @@ -2628,14 +2384,15 @@ } } } - }, - "put": { + } + }, + "/evaluations/{id}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "update a exists dataset", "consumes": [ "application/json" ], @@ -2643,57 +2400,23 @@ "application/json" ], "tags": [ - "Dataset" + "Evaluation" ], - "summary": "Update a exists dataset", + "summary": "get model evaluation", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "id", + "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateDatasetReq" - } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Dataset" - } - } - } - ] + "$ref": "#/definitions/types.EvaluationRes" } }, "400": { @@ -2716,7 +2439,6 @@ "ApiKey": [] } ], - "description": "delete a exists dataset", "consumes": [ "application/json" ], @@ -2724,36 +2446,23 @@ "application/json" ], "tags": [ - "Dataset" + "Evaluation" ], - "summary": "Delete a exists dataset", + "summary": "delete model evaluation", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "id", + "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "type": "string" } }, "400": { @@ -2771,13 +2480,8 @@ } } }, - "/datasets/{namespace}/{name}/all_files": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], + "/events": { + "post": { "consumes": [ "application/json" ], @@ -2785,48 +2489,28 @@ "application/json" ], "tags": [ - "Dataset" + "Events" ], - "summary": "Get all files of a dataset", + "summary": "Report client events", "parameters": [ { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" + "description": "Events", + "name": "events", + "in": "body", + "required": true, + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Event" + } + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.File" - } - } - } - ] + "type": "object" } }, "400": { @@ -2844,8 +2528,8 @@ } } }, - "/datasets/{namespace}/{name}/relations": { - "get": { + "/jwt/token": { + "post": { "security": [ { "ApiKey": [] @@ -2858,48 +2542,25 @@ "application/json" ], "tags": [ - "Dataset" + "JWT" ], - "summary": "Get dataset related assets", + "summary": "generate jwt token for user", "parameters": [ { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateJWTReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Relations" - } - } - } - ] + "$ref": "#/definitions/types.CreateJWTResp" } }, "400": { @@ -2917,14 +2578,13 @@ } } }, - "/discussions/{id}": { + "/jwt/{token}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "show a discussion", "consumes": [ "application/json" ], @@ -2932,14 +2592,14 @@ "application/json" ], "tags": [ - "Discussion" + "JWT" ], - "summary": "Show a discussion and its comments", + "summary": "verify jwt token and return user info", "parameters": [ { "type": "string", - "description": "the discussion id", - "name": "id", + "description": "token", + "name": "token", "in": "path", "required": true } @@ -2948,19 +2608,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.ShowDiscussionResponse" - } - } - } - ] + "$ref": "#/definitions/types.User" } }, "400": { @@ -2976,14 +2624,16 @@ } } } - }, - "put": { + } + }, + "/list/datasets_by_path": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "update a discussion", + "description": "list datasets by paths", "consumes": [ "application/json" ], @@ -2991,31 +2641,17 @@ "application/json" ], "tags": [ - "Discussion" + "List" ], - "summary": "Update a discussion", + "summary": "List datasets by paths", "parameters": [ - { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateDiscussionRequest" + "$ref": "#/definitions/types.ListByPathReq" } } ], @@ -3023,7 +2659,22 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.DatasetResp" + } + } + } + } + ] } }, "400": { @@ -3039,14 +2690,16 @@ } } } - }, - "delete": { + } + }, + "/list/models_by_path": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "delete a discussion", + "description": "list models by paths", "consumes": [ "application/json" ], @@ -3054,30 +2707,40 @@ "application/json" ], "tags": [ - "Discussion" + "List" ], - "summary": "Delete a discussion", + "summary": "List models by paths", "parameters": [ { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner of the discussion", - "name": "current_user", - "in": "query", - "required": true + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.ListByPathReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.ModelResp" + } + } + } + } + ] } }, "400": { @@ -3095,14 +2758,13 @@ } } }, - "/discussions/{id}/comments": { - "get": { + "/list/spaces_by_path": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "list discussion comments", "consumes": [ "application/json" ], @@ -3110,16 +2772,18 @@ "application/json" ], "tags": [ - "Discussion" + "List" ], - "summary": "List discussion comments", + "summary": "List spaces by paths", "parameters": [ { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.ListByPathReq" + } } ], "responses": { @@ -3136,7 +2800,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/types.DiscussionResponse_Comment" + "$ref": "#/definitions/types.Space" } } } @@ -3157,14 +2821,15 @@ } } } - }, + } + }, + "/mirror/repo": { "post": { "security": [ { "ApiKey": [] } ], - "description": "create a new discussion comment", "consumes": [ "application/json" ], @@ -3172,24 +2837,17 @@ "application/json" ], "tags": [ - "Discussion" + "Mirror" ], - "summary": "Create a new discussion comment", + "summary": "Create mirror repo", "parameters": [ - { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateCommentRequest" + "$ref": "#/definitions/types.CreateMirrorRepoReq" } } ], @@ -3197,19 +2855,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CreateCommentResponse" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -3227,8 +2873,8 @@ } } }, - "/evaluations": { - "post": { + "/mirror/repos": { + "get": { "security": [ { "ApiKey": [] @@ -3241,39 +2887,48 @@ "application/json" ], "tags": [ - "Evaluation" + "Mirror" ], - "summary": "run model evaluation", + "summary": "Get mirror repos", "parameters": [ { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true + "type": "integer", + "default": 20, + "description": "per", + "name": "per", + "in": "query" }, { - "description": "body setting of evaluation", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.EvaluationReq" - } + "type": "integer", + "default": 1, + "description": "page", + "name": "page", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "type": "string" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.MirrorRepo" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -3291,7 +2946,7 @@ } } }, - "/evaluations/{id}": { + "/mirror/sources": { "get": { "security": [ { @@ -3305,23 +2960,29 @@ "application/json" ], "tags": [ - "Evaluation" - ], - "summary": "get model evaluation", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } + "Mirror" ], + "summary": "Get mirror sources", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.EvaluationRes" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/database.MirrorSource" + } + } + } + } + ] } }, "400": { @@ -3338,7 +2999,7 @@ } } }, - "delete": { + "post": { "security": [ { "ApiKey": [] @@ -3351,23 +3012,37 @@ "application/json" ], "tags": [ - "Evaluation" + "Mirror" ], - "summary": "delete model evaluation", + "summary": "Create mirror source", "parameters": [ { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateMirrorSourceReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "type": "string" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.MirrorSource" + } + } + } + ] } }, "400": { @@ -3385,8 +3060,13 @@ } } }, - "/events": { - "post": { + "/mirror/sources/{id}": { + "get": { + "security": [ + { + "ApiKey": [] + } + ], "consumes": [ "application/json" ], @@ -3394,28 +3074,35 @@ "application/json" ], "tags": [ - "Events" + "Mirror" ], - "summary": "Report client events", + "summary": "Get mirror source", "parameters": [ { - "description": "Events", - "name": "events", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Event" - } - } + "type": "string", + "description": "id", + "name": "id", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "type": "object" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.MirrorSource" + } + } + } + ] } }, "400": { @@ -3431,10 +3118,8 @@ } } } - } - }, - "/import/gitlab": { - "get": { + }, + "put": { "security": [ { "ApiKey": [] @@ -3447,43 +3132,25 @@ "application/json" ], "tags": [ - "Import" + "Mirror" ], - "summary": "Import all gitlab repository", + "summary": "Update mirror source", "parameters": [ { "type": "string", - "description": "gitlab instance url", - "name": "base_url", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "gitlab instance access token", - "name": "access_token", - "in": "query", + "description": "id", + "name": "id", + "in": "path", "required": true }, { - "type": "string", - "description": "search query", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateMirrorSourceReq" + } } ], "responses": { @@ -3498,10 +3165,7 @@ "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RemoteRepository" - } + "$ref": "#/definitions/database.MirrorSource" } } } @@ -3521,10 +3185,8 @@ } } } - } - }, - "/import/gitlab/import": { - "post": { + }, + "delete": { "security": [ { "ApiKey": [] @@ -3537,18 +3199,16 @@ "application/json" ], "tags": [ - "Import" + "Mirror" ], - "summary": "Import gitlab repository", + "summary": "Delete mirror source", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ImportReq" - } + "type": "string", + "description": "id", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -3573,7 +3233,7 @@ } } }, - "/import/gitlab/import_status": { + "/mirrors": { "get": { "security": [ { @@ -3587,9 +3247,9 @@ "application/json" ], "tags": [ - "Import" + "Mirror" ], - "summary": "Import all gitlab repository", + "summary": "Get mirrors", "parameters": [ { "type": "integer", @@ -3601,7 +3261,7 @@ { "type": "integer", "default": 1, - "description": "per page", + "description": "page", "name": "page", "in": "query" } @@ -3618,7 +3278,13 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.ImportStatusResp" + "type": "array", + "items": { + "$ref": "#/definitions/types.Mirror" + } + }, + "total": { + "type": "integer" } } } @@ -3640,13 +3306,14 @@ } } }, - "/jwt/token": { - "post": { + "/models": { + "get": { "security": [ { "ApiKey": [] } ], + "description": "get visiable models for current user", "consumes": [ "application/json" ], @@ -3654,133 +3321,88 @@ "application/json" ], "tags": [ - "JWT" + "Model" ], - "summary": "generate jwt token for user", + "summary": "Get Visiable models for current user", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateJWTReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.CreateJWTResp" - } + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + { + "type": "string", + "description": "search text", + "name": "search", + "in": "query" }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/jwt/{token}": { - "get": { - "security": [ { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "JWT" - ], - "summary": "verify jwt token and return user info", - "parameters": [ + "type": "string", + "description": "filter by task tag, deprecated", + "name": "task_tag", + "in": "query" + }, { "type": "string", - "description": "token", - "name": "token", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.User" - } + "description": "filter by framework tag, deprecated", + "name": "framework_tag", + "in": "query" }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + { + "type": "string", + "description": "filter by license tag, deprecated", + "name": "license_tag", + "in": "query" }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/licenses": { - "get": { - "security": [ { - "ApiKey": [] - } - ], - "description": "List license", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "License" - ], - "summary": "List license", - "parameters": [ + "type": "string", + "description": "filter by language tag, deprecated", + "name": "language_tag", + "in": "query" + }, { "type": "string", - "description": "product", - "name": "product", + "description": "filter by tag category", + "name": "tag_category", "in": "query" }, { "type": "string", - "description": "edition", - "name": "edition", + "description": "filter by tag name", + "name": "tag_name", "in": "query" }, { "type": "string", - "description": "search", - "name": "search", + "description": "sort by", + "name": "sort", "in": "query" }, { + "enum": [ + "opencsg", + "huggingface", + "local" + ], "type": "string", - "description": "current user", - "name": "current_user", - "in": "query", - "required": true + "description": "source", + "name": "source", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" } ], "responses": { @@ -3789,7 +3411,7 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.Response" + "$ref": "#/definitions/types.ResponseWithTotal" }, { "type": "object", @@ -3797,7 +3419,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/database.License" + "$ref": "#/definitions/types.Model" } }, "total": { @@ -3828,7 +3450,7 @@ "ApiKey": [] } ], - "description": "Create a license", + "description": "create a new model", "consumes": [ "application/json" ], @@ -3836,16 +3458,15 @@ "application/json" ], "tags": [ - "License" + "Model" ], - "summary": "Create a license", + "summary": "Create a new model", "parameters": [ { "type": "string", "description": "current user", "name": "current_user", - "in": "query", - "required": true + "in": "query" }, { "description": "body", @@ -3853,7 +3474,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateLicenseReq" + "$ref": "#/definitions/types.CreateModelReq" } } ], @@ -3861,7 +3482,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.Model" + } + } + } + ] } }, "400": { @@ -3879,52 +3512,14 @@ } } }, - "/licenses/license": { + "/models/runtime_framework": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get active license status", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "License" - ], - "summary": "Get active license status", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Import a license", + "description": "List repo runtime framework", "consumes": [ "application/json" ], @@ -3932,88 +3527,58 @@ "application/json" ], "tags": [ - "License" + "Repository" ], - "summary": "Import a license", + "summary": "List repo runtime framework", "parameters": [ { + "enum": [ + "models" + ], "type": "string", - "description": "current user", - "name": "current_user", - "in": "query", - "required": true + "description": "models", + "name": "repo_type", + "in": "path", + "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ImportLicenseReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ { - "ApiKey": [] - } - ], - "description": "Verify a license", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "License" - ], - "summary": "Verify a license", - "parameters": [ + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, { "type": "string", "description": "current user", "name": "current_user", - "in": "query", - "required": true + "in": "query" }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ImportLicenseReq" - } + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "default": 1, + "description": "deploy_type", + "name": "deploy_type", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "type": "string" } }, "400": { @@ -4031,14 +3596,14 @@ } } }, - "/licenses/{id}": { + "/models/{namespace}/{name}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get a license by id", + "description": "get model detail", "consumes": [ "application/json" ], @@ -4046,27 +3611,27 @@ "application/json" ], "tags": [ - "License" + "Model" ], - "summary": "Get a license by id", + "summary": "Get model detail", "parameters": [ { "type": "string", - "description": "id", - "name": "id", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, { - "type": "boolean", - "default": false, - "description": "create license file", - "name": "create_license_file", - "in": "query" + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", "in": "query", "required": true @@ -4084,10 +3649,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/database.License" - }, - "license": { - "type": "string" + "$ref": "#/definitions/types.Model" } } } @@ -4114,7 +3676,7 @@ "ApiKey": [] } ], - "description": "Update a license by id", + "description": "update a exists model", "consumes": [ "application/json" ], @@ -4122,31 +3684,37 @@ "application/json" ], "tags": [ - "License" + "Model" ], - "summary": "Update a license by id", + "summary": "Update a exists model", "parameters": [ { "type": "string", - "description": "id", - "name": "id", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "current user", - "name": "current_user", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true }, + { + "type": "string", + "description": "current user, the model owner", + "name": "current_user", + "in": "query" + }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateLicenseReq" + "$ref": "#/definitions/types.UpdateModelReq" } } ], @@ -4154,7 +3722,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.Model" + } + } + } + ] } }, "400": { @@ -4177,7 +3757,7 @@ "ApiKey": [] } ], - "description": "Delete a license by id", + "description": "delete a exists model", "consumes": [ "application/json" ], @@ -4185,23 +3765,29 @@ "application/json" ], "tags": [ - "License" + "Model" ], - "summary": "Delete a license by id", + "summary": "Delete a exists model", "parameters": [ { "type": "string", - "description": "id", - "name": "id", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "current user", - "name": "current_user", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true + }, + { + "type": "string", + "description": "current user, the model owner", + "name": "current_user", + "in": "query" } ], "responses": { @@ -4226,14 +3812,13 @@ } } }, - "/list/datasets_by_path": { - "post": { + "/models/{namespace}/{name}/all_files": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "list datasets by paths", "consumes": [ "application/json" ], @@ -4241,18 +3826,29 @@ "application/json" ], "tags": [ - "List" + "Model" ], - "summary": "List datasets by paths", + "summary": "Get all files of a model", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ListByPathReq" - } + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" } ], "responses": { @@ -4267,10 +3863,7 @@ "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.DatasetResp" - } + "$ref": "#/definitions/types.File" } } } @@ -4292,14 +3885,13 @@ } } }, - "/list/models_by_path": { + "/models/{namespace}/{name}/finetune": { "post": { "security": [ { "ApiKey": [] } ], - "description": "list models by paths", "consumes": [ "application/json" ], @@ -4307,17 +3899,38 @@ "application/json" ], "tags": [ - "List" + "Model" ], - "summary": "List models by paths", + "summary": "create a finetune instance", "parameters": [ { - "description": "body", + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current_user", + "name": "current_user", + "in": "query", + "required": true + }, + { + "description": "deploy setting of instance", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.ListByPathReq" + "$ref": "#/definitions/types.InstanceRunReq" } } ], @@ -4325,22 +3938,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.ModelResp" - } - } - } - } - ] + "type": "string" } }, "400": { @@ -4358,13 +3956,14 @@ } } }, - "/list/spaces_by_path": { - "post": { + "/models/{namespace}/{name}/finetune/{id}": { + "delete": { "security": [ { "ApiKey": [] } ], + "description": "delete a finetune instance", "consumes": [ "application/json" ], @@ -4372,40 +3971,43 @@ "application/json" ], "tags": [ - "List" + "Model" ], - "summary": "List spaces by paths", + "summary": "Delete a finetune instance", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ListByPathReq" - } - } - ], + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" + } + ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -4423,13 +4025,14 @@ } } }, - "/mirror/repo": { - "post": { + "/models/{namespace}/{name}/finetune/{id}/start": { + "put": { "security": [ { "ApiKey": [] } ], + "description": "Start a finetune instance", "consumes": [ "application/json" ], @@ -4437,18 +4040,36 @@ "application/json" ], "tags": [ - "Mirror" + "Model" ], - "summary": "Create mirror repo", + "summary": "Start a finetune instance", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateMirrorRepoReq" - } + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "deploy id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" } ], "responses": { @@ -4473,13 +4094,14 @@ } } }, - "/mirror/repos": { - "get": { + "/models/{namespace}/{name}/finetune/{id}/stop": { + "put": { "security": [ { "ApiKey": [] } ], + "description": "Stop a finetune instance", "consumes": [ "application/json" ], @@ -4487,22 +4109,35 @@ "application/json" ], "tags": [ - "Mirror" + "Model" ], - "summary": "Get mirror repos", + "summary": "Stop a finetune instance", "parameters": [ { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true }, { "type": "integer", - "default": 1, - "description": "page", - "name": "page", + "description": "id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", "in": "query" } ], @@ -4510,25 +4145,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.MirrorRepo" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -4546,7 +4163,7 @@ } } }, - "/mirror/sources": { + "/models/{namespace}/{name}/relations": { "get": { "security": [ { @@ -4560,9 +4177,31 @@ "application/json" ], "tags": [ - "Mirror" + "Model" + ], + "summary": "Get model related assets", + "parameters": [ + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" + } ], - "summary": "Get mirror sources", "responses": { "200": { "description": "OK", @@ -4575,10 +4214,7 @@ "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.MirrorSource" - } + "$ref": "#/definitions/types.Relations" } } } @@ -4599,7 +4235,7 @@ } } }, - "post": { + "put": { "security": [ { "ApiKey": [] @@ -4612,17 +4248,37 @@ "application/json" ], "tags": [ - "Mirror" + "Model" ], - "summary": "Create mirror source", + "summary": "Set dataset relation for model", "parameters": [ { - "description": "body", - "name": "body", + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" + }, + { + "description": "set dataset relation", + "name": "req", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateMirrorSourceReq" + "$ref": "#/definitions/types.RelationDatasets" } } ], @@ -4638,7 +4294,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/database.MirrorSource" + "$ref": "#/definitions/types.Relations" } } } @@ -4660,8 +4316,8 @@ } } }, - "/mirror/sources/{id}": { - "get": { + "/models/{namespace}/{name}/relations/dataset": { + "post": { "security": [ { "ApiKey": [] @@ -4674,35 +4330,45 @@ "application/json" ], "tags": [ - "Mirror" + "Model" ], - "summary": "Get mirror source", + "summary": "add dataset relation for model", "parameters": [ { "type": "string", - "description": "id", - "name": "id", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" + }, + { + "description": "add dataset relation", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.RelationDataset" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.MirrorSource" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -4719,7 +4385,7 @@ } } }, - "put": { + "delete": { "security": [ { "ApiKey": [] @@ -4732,24 +4398,37 @@ "application/json" ], "tags": [ - "Mirror" + "Model" ], - "summary": "Update mirror source", + "summary": "delete dataset relation for model", "parameters": [ { "type": "string", - "description": "id", - "name": "id", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, { - "description": "body", - "name": "body", + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" + }, + { + "description": "delelet dataset relation", + "name": "req", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateMirrorSourceReq" + "$ref": "#/definitions/types.RelationDataset" } } ], @@ -4757,19 +4436,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.MirrorSource" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -4785,8 +4452,10 @@ } } } - }, - "delete": { + } + }, + "/models/{namespace}/{name}/run": { + "post": { "security": [ { "ApiKey": [] @@ -4799,23 +4468,46 @@ "application/json" ], "tags": [ - "Mirror" + "Model" ], - "summary": "Delete mirror source", + "summary": "run model as inference", "parameters": [ { "type": "string", - "description": "id", - "name": "id", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "current_user", + "name": "current_user", + "in": "query", + "required": true + }, + { + "description": "deploy setting of inference", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.ModelRunReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "type": "string" } }, "400": { @@ -4833,13 +4525,14 @@ } } }, - "/mirror/statistics": { - "get": { + "/models/{namespace}/{name}/run/{id}": { + "delete": { "security": [ { "ApiKey": [] } ], + "description": "delete a model inference", "consumes": [ "application/json" ], @@ -4847,29 +4540,43 @@ "application/json" ], "tags": [ - "Mirror" + "Model" + ], + "summary": "Delete a model inference", + "parameters": [ + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" + } ], - "summary": "Get mirror status counts", "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.MirrorStatusCount" - } - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -4887,13 +4594,14 @@ } } }, - "/mirrors": { - "get": { + "/models/{namespace}/{name}/run/{id}/start": { + "put": { "security": [ { "ApiKey": [] } ], + "description": "Start a model inference", "consumes": [ "application/json" ], @@ -4901,22 +4609,35 @@ "application/json" ], "tags": [ - "Mirror" + "Model" ], - "summary": "Get mirrors", + "summary": "Start a model inference", "parameters": [ { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true }, { "type": "integer", - "default": 1, - "description": "page", - "name": "page", + "description": "deploy id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", "in": "query" } ], @@ -4924,25 +4645,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Mirror" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -4960,14 +4663,14 @@ } } }, - "/models": { - "get": { + "/models/{namespace}/{name}/run/{id}/stop": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "get visiable models for current user", + "description": "Stop a model inference", "consumes": [ "application/json" ], @@ -4977,131 +4680,48 @@ "tags": [ "Model" ], - "summary": "Get Visiable models for current user", + "summary": "Stop a model inference", "parameters": [ { "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, { "type": "string", - "description": "filter by task tag, deprecated", - "name": "task_tag", - "in": "query" + "description": "name", + "name": "name", + "in": "path", + "required": true }, { - "type": "string", - "description": "filter by framework tag, deprecated", - "name": "framework_tag", - "in": "query" + "type": "integer", + "description": "id", + "name": "id", + "in": "path", + "required": true }, { "type": "string", - "description": "filter by license tag, deprecated", - "name": "license_tag", + "description": "current user", + "name": "current_user", "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.Response" + } }, - { - "type": "string", - "description": "filter by language tag, deprecated", - "name": "language_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by tag category", - "name": "tag_category", - "in": "query" - }, - { - "type": "string", - "description": "filter by tag name", - "name": "tag_name", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "need op weight", - "name": "need_op_weight", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "enum": [ - "opencsg", - "huggingface", - "local" - ], - "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - }, - { - "type": "string", - "description": "example: base_model:finetune:1", - "name": "model_tree", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } }, "500": { "description": "Internal server error", @@ -5110,14 +4730,15 @@ } } } - }, - "post": { + } + }, + "/models/{namespace}/{name}/serverless": { + "get": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "create a new model", "consumes": [ "application/json" ], @@ -5127,41 +4748,28 @@ "tags": [ "Model" ], - "summary": "Create a new model", + "summary": "get model serverless", "parameters": [ { "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateModelReq" - } + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Model" - } - } - } - ] + "type": "string" } }, "400": { @@ -5177,16 +4785,13 @@ } } } - } - }, - "/models/runtime_framework": { - "get": { + }, + "post": { "security": [ { "ApiKey": [] } ], - "description": "List repo runtime framework", "consumes": [ "application/json" ], @@ -5194,20 +4799,10 @@ "application/json" ], "tags": [ - "Repository" + "Model" ], - "summary": "List repo runtime framework", + "summary": "run model as serverless service", "parameters": [ - { - "enum": [ - "models" - ], - "type": "string", - "description": "models", - "name": "repo_type", - "in": "path", - "required": true - }, { "type": "string", "description": "namespace", @@ -5224,21 +4819,19 @@ }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", - "in": "query" + "in": "query", + "required": true }, { - "enum": [ - 0, - 1, - 2 - ], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" + "description": "deploy setting of serverless", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.ModelRunReq" + } } ], "responses": { @@ -5263,14 +4856,14 @@ } } }, - "/models/{namespace}/{name}": { + "/models/{namespace}/{name}/serverless/{id}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get model detail", + "description": "Get repo serverless detail", "consumes": [ "application/json" ], @@ -5280,7 +4873,7 @@ "tags": [ "Model" ], - "summary": "Get model detail", + "summary": "Get repo serverless detail", "parameters": [ { "type": "string", @@ -5298,16 +4891,15 @@ }, { "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", + "description": "id", + "name": "id", + "in": "path", "required": true }, { - "type": "boolean", - "default": false, - "description": "need op weight", - "name": "need_op_weight", + "type": "string", + "description": "current user", + "name": "current_user", "in": "query" } ], @@ -5315,19 +4907,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Model" - } - } - } - ] + "type": "string" } }, "400": { @@ -5350,7 +4930,6 @@ "ApiKey": [] } ], - "description": "update a exists model", "consumes": [ "application/json" ], @@ -5360,7 +4939,7 @@ "tags": [ "Model" ], - "summary": "Update a exists model", + "summary": "Update serverless parameters", "parameters": [ { "type": "string", @@ -5378,17 +4957,25 @@ }, { "type": "string", - "description": "current user, the model owner", + "description": "deploy id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current_user", "name": "current_user", - "in": "query" + "in": "query", + "required": true }, { - "description": "body", + "description": "deploy setting of Serverless", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateModelReq" + "$ref": "#/definitions/types.DeployUpdateReq" } } ], @@ -5396,19 +4983,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Model" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -5424,14 +4999,15 @@ } } } - }, - "delete": { + } + }, + "/models/{namespace}/{name}/serverless/{id}/logs/{instance}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "delete a exists model", "consumes": [ "application/json" ], @@ -5441,8 +5017,18 @@ "tags": [ "Model" ], - "summary": "Delete a exists model", + "summary": "get serverless logs", "parameters": [ + { + "enum": [ + "models" + ], + "type": "string", + "description": "models", + "name": "repo_type", + "in": "path", + "required": true + }, { "type": "string", "description": "namespace", @@ -5459,91 +5045,27 @@ }, { "type": "string", - "description": "current user, the model owner", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/all_files": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "Get all files of a model", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", + "description": "id", + "name": "id", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", + "description": "instance", + "name": "instance", "in": "path", "required": true }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", - "in": "query" + "in": "query", + "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.File" - } - } - } - ] - } - }, "400": { "description": "Bad request", "schema": { @@ -5559,13 +5081,14 @@ } } }, - "/models/{namespace}/{name}/finetune": { - "post": { + "/models/{namespace}/{name}/serverless/{id}/start": { + "put": { "security": [ { "ApiKey": [] } ], + "description": "Start a model serverless", "consumes": [ "application/json" ], @@ -5575,7 +5098,7 @@ "tags": [ "Model" ], - "summary": "create a finetune instance", + "summary": "Start a model serverless", "parameters": [ { "type": "string", @@ -5592,27 +5115,24 @@ "required": true }, { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", + "type": "integer", + "description": "deploy id", + "name": "id", + "in": "path", "required": true }, { - "description": "deploy setting of instance", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.InstanceRunReq" - } + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/types.Response" } }, "400": { @@ -5630,14 +5150,13 @@ } } }, - "/models/{namespace}/{name}/finetune/{id}": { - "delete": { + "/models/{namespace}/{name}/serverless/{id}/status": { + "get": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "delete a finetune instance", "consumes": [ "application/json" ], @@ -5647,7 +5166,7 @@ "tags": [ "Model" ], - "summary": "Delete a finetune instance", + "summary": "get serverless status", "parameters": [ { "type": "string", @@ -5664,26 +5183,21 @@ "required": true }, { - "type": "integer", - "description": "id", + "type": "string", + "description": "deploy id", "name": "id", "in": "path", "required": true }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", - "in": "query" + "in": "query", + "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, "400": { "description": "Bad request", "schema": { @@ -5699,14 +5213,14 @@ } } }, - "/models/{namespace}/{name}/finetune/{id}/start": { + "/models/{namespace}/{name}/serverless/{id}/stop": { "put": { "security": [ { "ApiKey": [] } ], - "description": "Start a finetune instance", + "description": "Stop a model serverless", "consumes": [ "application/json" ], @@ -5716,7 +5230,7 @@ "tags": [ "Model" ], - "summary": "Start a finetune instance", + "summary": "Stop a model serverless", "parameters": [ { "type": "string", @@ -5734,7 +5248,7 @@ }, { "type": "integer", - "description": "deploy id", + "description": "id", "name": "id", "in": "path", "required": true @@ -5768,14 +5282,14 @@ } } }, - "/models/{namespace}/{name}/finetune/{id}/stop": { - "put": { + "/namespace/{path}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Stop a finetune instance", + "description": "get namespace info", "consumes": [ "application/json" ], @@ -5783,43 +5297,36 @@ "application/json" ], "tags": [ - "Model" + "Namespace", + "InternalOnly" ], - "summary": "Stop a finetune instance", + "summary": "Get namespace info [Internal Only].", "parameters": [ { "type": "string", "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", + "name": "path", "in": "path", "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Namespace" + } + } + } + ] } }, "400": { @@ -5837,7 +5344,7 @@ } } }, - "/models/{namespace}/{name}/relations": { + "/organization/{namespace}": { "get": { "security": [ { @@ -5851,29 +5358,22 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "Get model related assets", + "summary": "Get organization info", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true + "description": "the op user", + "name": "current_user", + "in": "query" }, { "type": "string", - "description": "name", - "name": "name", + "description": "namespace", + "name": "namespace", "in": "path", "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" } ], "responses": { @@ -5888,7 +5388,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Relations" + "$ref": "#/definitions/types.Organization" } } } @@ -5915,6 +5415,7 @@ "ApiKey": [] } ], + "description": "update organization", "consumes": [ "application/json" ], @@ -5922,9 +5423,9 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "Set dataset relation for model", + "summary": "Update organization", "parameters": [ { "type": "string", @@ -5935,24 +5436,17 @@ }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", + "description": "the op user", "name": "current_user", "in": "query" }, { - "description": "set dataset relation", - "name": "req", + "description": "body", + "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.RelationDatasets" + "$ref": "#/definitions/types.EditOrgReq" } } ], @@ -5968,7 +5462,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Relations" + "$ref": "#/definitions/database.Organization" } } } @@ -5988,15 +5482,14 @@ } } } - } - }, - "/models/{namespace}/{name}/relations/dataset": { - "post": { + }, + "delete": { "security": [ { "ApiKey": [] } ], + "description": "delete organization", "consumes": [ "application/json" ], @@ -6004,9 +5497,9 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "add dataset relation for model", + "summary": "Delete organization", "parameters": [ { "type": "string", @@ -6017,24 +5510,17 @@ }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", + "description": "the op user", "name": "current_user", "in": "query" }, { - "description": "add dataset relation", - "name": "req", + "description": "body", + "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.RelationDataset" + "$ref": "#/definitions/types.DeleteOrgReq" } } ], @@ -6045,12 +5531,6 @@ "$ref": "#/definitions/types.Response" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, "500": { "description": "Internal server error", "schema": { @@ -6058,8 +5538,10 @@ } } } - }, - "delete": { + } + }, + "/organization/{namespace}/codes": { + "get": { "security": [ { "ApiKey": [] @@ -6072,45 +5554,60 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "delete dataset relation for model", + "summary": "Get organization codes", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", + "description": "current user name", + "name": "current_user", + "in": "query", "required": true }, { - "type": "string", - "description": "current user", - "name": "current_user", + "type": "integer", + "description": "page size", + "name": "per", "in": "query" }, { - "description": "delelet dataset relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationDataset" - } + "type": "integer", + "description": "current page number", + "name": "page", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Code" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -6128,8 +5625,8 @@ } } }, - "/models/{namespace}/{name}/run": { - "post": { + "/organization/{namespace}/collections": { + "get": { "security": [ { "ApiKey": [] @@ -6142,46 +5639,60 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "run model as inference", + "summary": "Get organization Collections", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", + "description": "current user name", "name": "current_user", "in": "query", "required": true }, { - "description": "deploy setting of inference", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ModelRunReq" - } + "type": "integer", + "description": "page size", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "description": "current page number", + "name": "page", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "type": "string" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Collection" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -6199,14 +5710,14 @@ } } }, - "/models/{namespace}/{name}/run/{id}": { - "delete": { + "/organization/{namespace}/datasets": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "delete a model inference", + "description": "get organization datasets", "consumes": [ "application/json" ], @@ -6214,35 +5725,34 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "Delete a model inference", + "summary": "Get organization datasets", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", + "description": "current user name", + "name": "current_user", + "in": "query", "required": true }, { "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true + "description": "page size", + "name": "per", + "in": "query" }, { - "type": "string", - "description": "current user", - "name": "current_user", + "type": "integer", + "description": "current page number", + "name": "page", "in": "query" } ], @@ -6250,7 +5760,25 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Dataset" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -6268,14 +5796,13 @@ } } }, - "/models/{namespace}/{name}/run/{id}/start": { - "put": { + "/organization/{namespace}/members": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Start a model inference", "consumes": [ "application/json" ], @@ -6283,35 +5810,35 @@ "application/json" ], "tags": [ - "Model" + "Member" ], - "summary": "Start a model inference", + "summary": "Get organization members. Org member can get more details.", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true + "description": "the op user", + "name": "current_user", + "in": "query" }, { "type": "string", - "description": "name", - "name": "name", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, { "type": "integer", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true + "default": 50, + "description": "per", + "name": "per", + "in": "query" }, { - "type": "string", - "description": "current user", - "name": "current_user", + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", "in": "query" } ], @@ -6319,7 +5846,22 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + " total": { + "type": "integer" + }, + "data": { + "$ref": "#/definitions/types.Member" + } + } + } + ] } }, "400": { @@ -6335,16 +5877,14 @@ } } } - } - }, - "/models/{namespace}/{name}/run/{id}/stop": { - "put": { + }, + "post": { "security": [ { "ApiKey": [] } ], - "description": "Stop a model inference", + "description": "user will be added to org with a role", "consumes": [ "application/json" ], @@ -6352,36 +5892,31 @@ "application/json" ], "tags": [ - "Model" + "Member" ], - "summary": "Stop a model inference", + "summary": "Create new membership between org and user", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", + "description": "the op user", "name": "current_user", "in": "query" + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handler.Create.addMemberRequest" + } } ], "responses": { @@ -6406,11 +5941,11 @@ } } }, - "/models/{namespace}/{name}/serverless": { + "/organization/{namespace}/members/{username}": { "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], "consumes": [ @@ -6420,23 +5955,29 @@ "application/json" ], "tags": [ - "Model" + "Member" ], - "summary": "get model serverless", + "summary": "Get user's role in an org", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", + "description": "user name", + "name": "username", "in": "path", "required": true + }, + { + "type": "string", + "description": "the op user", + "name": "current_user", + "in": "query" } ], "responses": { @@ -6460,7 +6001,7 @@ } } }, - "post": { + "put": { "security": [ { "ApiKey": [] @@ -6473,38 +6014,37 @@ "application/json" ], "tags": [ - "Model" + "Member" ], - "summary": "run model as serverless service", + "summary": "update user membership", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", + "description": "user name", + "name": "username", "in": "path", "required": true }, { "type": "string", - "description": "current_user", + "description": "the op user", "name": "current_user", - "in": "query", - "required": true + "in": "query" }, { - "description": "deploy setting of serverless", + "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.ModelRunReq" + "$ref": "#/definitions/handler.Update.updateMemberRequest" } } ], @@ -6512,7 +6052,7 @@ "200": { "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/types.Response" } }, "400": { @@ -6528,16 +6068,14 @@ } } } - } - }, - "/models/{namespace}/{name}/serverless/{id}": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] } ], - "description": "Get repo serverless detail", + "description": "user's role will be remove from org", "consumes": [ "application/json" ], @@ -6545,43 +6083,45 @@ "application/json" ], "tags": [ - "Model" + "Member" ], - "summary": "Get repo serverless detail", + "summary": "Remove membership between org and user", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", + "description": "user name", + "name": "username", "in": "path", "required": true }, { "type": "string", - "description": "current user", + "description": "the op user", "name": "current_user", "in": "query" + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handler.Delete.removeMemberRequest" + } } ], "responses": { "200": { "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/types.Response" } }, "400": { @@ -6597,13 +6137,16 @@ } } } - }, - "put": { + } + }, + "/organization/{namespace}/models": { + "get": { "security": [ { "ApiKey": [] } ], + "description": "get organization models", "consumes": [ "application/json" ], @@ -6611,53 +6154,60 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "Update serverless parameters", + "summary": "Get organization models", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", + "description": "current user name", "name": "current_user", "in": "query", "required": true }, { - "description": "deploy setting of Serverless", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.DeployUpdateReq" - } + "type": "integer", + "description": "page size", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "description": "current page number", + "name": "page", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Model" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -6675,13 +6225,14 @@ } } }, - "/models/{namespace}/{name}/serverless/{id}/logs/{instance}": { + "/organization/{namespace}/prompts": { "get": { "security": [ { "ApiKey": [] } ], + "description": "get organization prompts", "consumes": [ "application/json" ], @@ -6689,57 +6240,62 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "get serverless logs", + "summary": "Get organization prompts", "parameters": [ - { - "enum": [ - "models" - ], - "type": "string", - "description": "models", - "name": "repo_type", - "in": "path", - "required": true - }, { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", + "description": "current user name", + "name": "current_user", + "in": "query", "required": true }, { - "type": "string", - "description": "instance", - "name": "instance", - "in": "path", - "required": true + "type": "integer", + "description": "page size", + "name": "per", + "in": "query" }, { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true + "type": "integer", + "description": "current page number", + "name": "page", + "in": "query" } ], "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.PromptRes" + } + }, + "total": { + "type": "integer" + } + } + } + ] + } + }, "400": { "description": "Bad request", "schema": { @@ -6755,14 +6311,13 @@ } } }, - "/models/{namespace}/{name}/serverless/{id}/start": { - "put": { + "/organization/{namespace}/spaces": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Start a model serverless", "consumes": [ "application/json" ], @@ -6770,35 +6325,34 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "Start a model serverless", + "summary": "Get organization Spaces", "parameters": [ { "type": "string", - "description": "namespace", + "description": "org name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", + "description": "current user name", + "name": "current_user", + "in": "query", "required": true }, { "type": "integer", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true + "description": "page size", + "name": "per", + "in": "query" }, { - "type": "string", - "description": "current user", - "name": "current_user", + "type": "integer", + "description": "current page number", + "name": "page", "in": "query" } ], @@ -6806,16 +6360,34 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Space" + } + }, + "total": { + "type": "integer" + } + } + } + ] + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } + }, + "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/types.APIInternalServerError" @@ -6824,13 +6396,14 @@ } } }, - "/models/{namespace}/{name}/serverless/{id}/status": { + "/organizations": { "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], + "description": "get organizations", "consumes": [ "application/json" ], @@ -6838,40 +6411,92 @@ "application/json" ], "tags": [ - "Model" + "Organization" ], - "summary": "get serverless status", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true + "summary": "Get organizations", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Organization" + } + } + } + } + ] + } }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/types.APIInternalServerError" + } + } + } + }, + "post": { + "security": [ { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, + "ApiKey": [] + } + ], + "description": "create a new organization", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Organization" + ], + "summary": "Create a new organization", + "parameters": [ { "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true + "description": "the op user", + "name": "current_user", + "in": "query" }, { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateOrgReq" + } } ], "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Organization" + } + } + } + ] + } + }, "400": { "description": "Bad request", "schema": { @@ -6887,14 +6512,14 @@ } } }, - "/models/{namespace}/{name}/serverless/{id}/stop": { - "put": { + "/prompts": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Stop a model serverless", + "description": "get visiable Prompt repos for current user", "consumes": [ "application/json" ], @@ -6902,35 +6527,75 @@ "application/json" ], "tags": [ - "Model" + "Prompt" ], - "summary": "Stop a model serverless", + "summary": "Get Visiable Prompt repos for current user", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true + "description": "current user", + "name": "current_user", + "in": "query" }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true + "description": "search text", + "name": "search", + "in": "query" }, { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true + "type": "string", + "description": "filter by task tag", + "name": "task_tag", + "in": "query" }, { "type": "string", - "description": "current user", - "name": "current_user", + "description": "filter by framework tag", + "name": "framework_tag", + "in": "query" + }, + { + "type": "string", + "description": "filter by license tag", + "name": "license_tag", + "in": "query" + }, + { + "type": "string", + "description": "filter by language tag", + "name": "language_tag", + "in": "query" + }, + { + "type": "string", + "description": "sort by", + "name": "sort", + "in": "query" + }, + { + "enum": [ + "opencsg", + "huggingface", + "local" + ], + "type": "string", + "description": "source", + "name": "source", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", "in": "query" } ], @@ -6938,7 +6603,25 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.PromptRes" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -6954,16 +6637,14 @@ } } } - } - }, - "/modeltrees/scan": { + }, "post": { "security": [ { "ApiKey": [] } ], - "description": "scan model tree", + "description": "create a new prompt repo", "consumes": [ "application/json" ], @@ -6971,16 +6652,23 @@ "application/json" ], "tags": [ - "Model" + "Prompt" ], - "summary": "scan model tree", + "summary": "Create a new prompt repo", "parameters": [ + { + "type": "string", + "description": "current user, the owner", + "name": "current_user", + "in": "query" + }, { "description": "body", "name": "body", "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/types.ScanModels" + "$ref": "#/definitions/types.CreatePromptRepoReq" } } ], @@ -7006,9 +6694,14 @@ } } }, - "/modeltrees/{namespace}/{name}/lineage": { + "/prompts/{namespace}/{name}": { "get": { - "description": "get model tree", + "security": [ + { + "ApiKey": [] + } + ], + "description": "List prompts", "consumes": [ "application/json" ], @@ -7016,14 +6709,30 @@ "application/json" ], "tags": [ - "Model" + "Prompt" + ], + "summary": "List prompts", + "parameters": [ + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + } ], - "summary": "Get model tree", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.ModelTree" + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7039,16 +6748,14 @@ } } } - } - }, - "/namespace/{path}": { - "get": { + }, + "put": { "security": [ { "ApiKey": [] } ], - "description": "get namespace info", + "description": "update a exists prompt repo", "consumes": [ "application/json" ], @@ -7056,36 +6763,45 @@ "application/json" ], "tags": [ - "Namespace", - "InternalOnly" + "Prompt" ], - "summary": "Get namespace info [Internal Only].", + "summary": "Update a exists prompt repo", "parameters": [ { "type": "string", "description": "namespace", - "name": "path", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "current user, the owner", + "name": "current_user", + "in": "query" + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdatePromptRepoReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Namespace" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7101,15 +6817,14 @@ } } } - } - }, - "/organization/{namespace}": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] } ], + "description": "delete a exists prompt repo", "consumes": [ "application/json" ], @@ -7117,41 +6832,36 @@ "application/json" ], "tags": [ - "Organization" + "Prompt" ], - "summary": "Get organization info", + "summary": "Delete a exists prompt repo", "parameters": [ { "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, { "type": "string", - "description": "namespace", - "name": "namespace", + "description": "name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "current user, the owner", + "name": "current_user", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Organization" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7167,14 +6877,15 @@ } } } - }, - "put": { + } + }, + "/prompts/{namespace}/{name}/branches": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "update organization", "consumes": [ "application/json" ], @@ -7182,31 +6893,36 @@ "application/json" ], "tags": [ - "Organization" + "Prompt" ], - "summary": "Update organization", + "summary": "Get the branches of prompt repository", "parameters": [ { "type": "string", - "description": "namespace", + "description": "repo owner name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" + "description": "repo name", + "name": "name", + "in": "path", + "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.EditOrgReq" - } + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" } ], "responses": { @@ -7215,13 +6931,16 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.Response" + "$ref": "#/definitions/types.ResponseWithTotal" }, { "type": "object", "properties": { "data": { - "$ref": "#/definitions/database.Organization" + "type": "array", + "items": { + "$ref": "#/definitions/types.Branch" + } } } } @@ -7241,14 +6960,16 @@ } } } - }, - "delete": { + } + }, + "/prompts/{namespace}/{name}/prompt/file": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "delete organization", + "description": "Create prompt in repo", "consumes": [ "application/json" ], @@ -7256,9 +6977,9 @@ "application/json" ], "tags": [ - "Organization" + "Prompt" ], - "summary": "Delete organization", + "summary": "Create prompt in repo", "parameters": [ { "type": "string", @@ -7269,7 +6990,14 @@ }, { "type": "string", - "description": "the op user", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user name", "name": "current_user", "in": "query" } @@ -7281,6 +7009,12 @@ "$ref": "#/definitions/types.Response" } }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } + }, "500": { "description": "Internal server error", "schema": { @@ -7290,13 +7024,14 @@ } } }, - "/organization/{namespace}/codes": { - "get": { + "/prompts/{namespace}/{name}/prompt/file/{file_path}": { + "put": { "security": [ { "ApiKey": [] } ], + "description": "Update prompt in repo", "consumes": [ "application/json" ], @@ -7304,34 +7039,35 @@ "application/json" ], "tags": [ - "Organization" + "Prompt" ], - "summary": "Get organization codes", + "summary": "Update prompt in repo", "parameters": [ { "type": "string", - "description": "org name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true }, { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" + "type": "string", + "description": "the file relative path", + "name": "file_path", + "in": "path", + "required": true }, { - "type": "integer", - "description": "current page number", - "name": "page", + "type": "string", + "description": "current user name", + "name": "current_user", "in": "query" } ], @@ -7339,25 +7075,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7373,15 +7091,14 @@ } } } - } - }, - "/organization/{namespace}/collections": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] } ], + "description": "Delete prompt in repo", "consumes": [ "application/json" ], @@ -7389,34 +7106,35 @@ "application/json" ], "tags": [ - "Organization" + "Prompt" ], - "summary": "Get organization Collections", + "summary": "Delete prompt in repo", "parameters": [ { "type": "string", - "description": "org name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true }, { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" + "type": "string", + "description": "the file relative path", + "name": "file_path", + "in": "path", + "required": true }, { - "type": "integer", - "description": "current page number", - "name": "page", + "type": "string", + "description": "current user name", + "name": "current_user", "in": "query" } ], @@ -7424,25 +7142,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Collection" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7460,14 +7160,14 @@ } } }, - "/organization/{namespace}/datasets": { + "/prompts/{namespace}/{name}/prompt/view/{file_path}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get organization datasets", + "description": "Get prompts by file", "consumes": [ "application/json" ], @@ -7475,34 +7175,35 @@ "application/json" ], "tags": [ - "Organization" + "Prompt" ], - "summary": "Get organization datasets", + "summary": "Get prompts by file", "parameters": [ { "type": "string", - "description": "org name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true }, { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" + "type": "string", + "description": "the file relative path", + "name": "file_path", + "in": "path", + "required": true }, { - "type": "integer", - "description": "current page number", - "name": "page", + "type": "string", + "description": "current user name", + "name": "current_user", "in": "query" } ], @@ -7510,25 +7211,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7546,7 +7229,7 @@ } } }, - "/organization/{namespace}/members": { + "/prompts/{namespace}/{name}/relations": { "get": { "security": [ { @@ -7560,16 +7243,10 @@ "application/json" ], "tags": [ - "Member" + "Prompt" ], - "summary": "Get organization members. Org member can get more details.", + "summary": "Get prompt related assets", "parameters": [ - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, { "type": "string", "description": "namespace", @@ -7578,17 +7255,16 @@ "required": true }, { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true }, { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", + "type": "string", + "description": "current user", + "name": "current_user", "in": "query" } ], @@ -7598,16 +7274,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { - " total": { - "type": "integer" - }, "data": { - "$ref": "#/definitions/types.Member" + "$ref": "#/definitions/types.Relations" } } } @@ -7628,13 +7301,12 @@ } } }, - "post": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "user will be added to org with a role", "consumes": [ "application/json" ], @@ -7642,30 +7314,37 @@ "application/json" ], "tags": [ - "Member" + "Prompt" ], - "summary": "Create new membership between org and user", + "summary": "Set model relation for prompt", "parameters": [ { "type": "string", - "description": "org name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "the op user", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", "name": "current_user", "in": "query" }, { - "description": "body", - "name": "body", + "description": "set model relation", + "name": "req", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/handler.Create.addMemberRequest" + "$ref": "#/definitions/types.RelationModels" } } ], @@ -7691,8 +7370,8 @@ } } }, - "/organization/{namespace}/members/{username}": { - "get": { + "/prompts/{namespace}/{name}/relations/model": { + "post": { "security": [ { "ApiKey": [] @@ -7705,36 +7384,45 @@ "application/json" ], "tags": [ - "Member" + "Prompt" ], - "summary": "Get user's role in an org", + "summary": "add model relation for prompt", "parameters": [ { "type": "string", - "description": "org name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "user name", - "name": "username", + "description": "name", + "name": "name", "in": "path", "required": true }, { "type": "string", - "description": "the op user", + "description": "current user", "name": "current_user", "in": "query" + }, + { + "description": "add model relation", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.RelationModel" + } } ], "responses": { "200": { "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7751,7 +7439,7 @@ } } }, - "put": { + "delete": { "security": [ { "ApiKey": [] @@ -7764,37 +7452,37 @@ "application/json" ], "tags": [ - "Member" + "Prompt" ], - "summary": "update user membership", + "summary": "delete model relation for prompt", "parameters": [ { "type": "string", - "description": "org name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "user name", - "name": "username", + "description": "name", + "name": "name", "in": "path", "required": true }, { "type": "string", - "description": "the op user", + "description": "current user", "name": "current_user", "in": "query" }, { - "description": "body", - "name": "body", + "description": "delelet model relation", + "name": "req", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/handler.Update.updateMemberRequest" + "$ref": "#/definitions/types.RelationModel" } } ], @@ -7818,14 +7506,15 @@ } } } - }, - "delete": { + } + }, + "/prompts/{namespace}/{name}/tags": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "user's role will be remove from org", "consumes": [ "application/json" ], @@ -7833,45 +7522,51 @@ "application/json" ], "tags": [ - "Member" + "Prompt" ], - "summary": "Remove membership between org and user", + "summary": "Get the tags of prompt repository", "parameters": [ { "type": "string", - "description": "org name", + "description": "repo owner name", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "user name", - "name": "username", + "description": "repo name", + "name": "name", "in": "path", "required": true }, { "type": "string", - "description": "the op user", + "description": "current user name", "name": "current_user", "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.Delete.removeMemberRequest" - } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/database.Tag" + } + } + } + } + ] } }, "400": { @@ -7889,14 +7584,13 @@ } } }, - "/organization/{namespace}/models": { - "get": { + "/prompts/{namespace}/{name}/tags/{category}": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "get organization models", "consumes": [ "application/json" ], @@ -7904,17 +7598,24 @@ "application/json" ], "tags": [ - "Organization" + "Prompt" ], - "summary": "Get organization models", + "summary": "update the tags of a certain category", "parameters": [ { "type": "string", - "description": "org name", + "description": "repo owner name", "name": "namespace", "in": "path", "required": true }, + { + "type": "string", + "description": "repo name", + "name": "name", + "in": "path", + "required": true + }, { "type": "string", "description": "current user name", @@ -7923,41 +7624,37 @@ "required": true }, { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" + "enum": [ + "task", + "license", + "framework", + "language", + "industry" + ], + "type": "string", + "description": "tag category", + "name": "category", + "in": "path", + "required": true }, { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" + "description": "tag names in array", + "name": "tags", + "in": "body", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -7975,14 +7672,13 @@ } } }, - "/organization/{namespace}/prompts": { - "get": { + "/recom/opweight": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "get organization prompts", "consumes": [ "application/json" ], @@ -7990,60 +7686,25 @@ "application/json" ], "tags": [ - "Organization" + "Recommendation" ], - "summary": "Get organization prompts", + "summary": "set op weight for repo recommendation", "parameters": [ { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" + "description": "json request body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handler.SetOpWeight.SetOpWeightReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.PromptRes" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -8061,13 +7722,14 @@ } } }, - "/organization/{namespace}/spaces": { + "/runtime_framework": { "get": { "security": [ { "ApiKey": [] } ], + "description": "get all runtime frameworks for current user", "consumes": [ "application/json" ], @@ -8075,34 +7737,14 @@ "application/json" ], "tags": [ - "Organization" + "RuntimeFramework" ], - "summary": "Get organization Spaces", + "summary": "Get all runtime frameworks for current user", "parameters": [ { "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", + "description": "current user", "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", "in": "query" } ], @@ -8110,25 +7752,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -8144,55 +7768,6 @@ } } } - } - }, - "/organizations": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get organizations", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Organization" - ], - "summary": "Get organizations", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Organization" - } - } - } - } - ] - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } }, "post": { "security": [ @@ -8200,7 +7775,7 @@ "ApiKey": [] } ], - "description": "create a new organization", + "description": "create runtime framework", "consumes": [ "application/json" ], @@ -8208,13 +7783,38 @@ "application/json" ], "tags": [ - "Organization" + "RuntimeFramework" ], - "summary": "Create a new organization", + "summary": "Create runtime framework", "parameters": [ { + "enum": [ + "models", + "spaces" + ], "type": "string", - "description": "the op user", + "description": "models,spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", "name": "current_user", "in": "query" }, @@ -8224,7 +7824,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateOrgReq" + "$ref": "#/definitions/types.RuntimeFrameworkReq" } } ], @@ -8232,19 +7832,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Organization" - } - } - } - ] + "$ref": "#/definitions/types.RuntimeFramework" } }, "400": { @@ -8262,14 +7850,14 @@ } } }, - "/prompts": { + "/runtime_framework/models": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get visiable Prompt repos for current user", + "description": "get visible models for all runtime frameworks for current user", "consumes": [ "application/json" ], @@ -8277,46 +7865,16 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Get Visiable Prompt repos for current user", + "summary": "Get Visible models for all runtime frameworks for current user", "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, { "type": "string", "description": "search text", "name": "search", "in": "query" }, - { - "type": "string", - "description": "filter by task tag", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag", - "name": "language_tag", - "in": "query" - }, { "type": "string", "description": "sort by", @@ -8324,14 +7882,9 @@ "in": "query" }, { - "enum": [ - "opencsg", - "huggingface", - "local" - ], "type": "string", - "description": "source", - "name": "source", + "description": "current user", + "name": "current_user", "in": "query" }, { @@ -8347,31 +7900,24 @@ "description": "per page", "name": "page", "in": "query" + }, + { + "enum": [ + 1, + 2 + ], + "type": "integer", + "default": 1, + "description": "deploy_type", + "name": "deploy_type", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.PromptRes" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -8387,14 +7933,16 @@ } } } - }, - "post": { + } + }, + "/runtime_framework/{id}": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "create a new prompt repo", + "description": "Update runtime framework", "consumes": [ "application/json" ], @@ -8402,13 +7950,45 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Create a new prompt repo", + "summary": "Update runtime framework", "parameters": [ { + "enum": [ + "models", + "spaces" + ], "type": "string", - "description": "current user, the owner", + "description": "models,spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", "name": "current_user", "in": "query" }, @@ -8418,7 +7998,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreatePromptRepoReq" + "$ref": "#/definitions/types.RuntimeFrameworkReq" } } ], @@ -8426,7 +8006,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "$ref": "#/definitions/types.RuntimeFramework" } }, "400": { @@ -8442,16 +8022,14 @@ } } } - } - }, - "/prompts/conversations": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] } ], - "description": "List conversations of user", + "description": "delete a exist RuntimeFramework", "consumes": [ "application/json" ], @@ -8459,56 +8037,47 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "List conversations of user", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } + "summary": "Delete a exist RuntimeFramework", + "parameters": [ + { + "enum": [ + "models", + "spaces" + ], + "type": "string", + "description": "models,spaces", + "name": "repo_type", + "in": "path", + "required": true }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ { - "ApiKey": [] - } - ], - "description": "Create new conversation", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Prompt" - ], - "summary": "Create new conversation", - "parameters": [ + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.Conversation" - } + "type": "integer", + "description": "id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" } ], "responses": { @@ -8533,14 +8102,14 @@ } } }, - "/prompts/conversations/{id}": { + "/runtime_framework/{id}/architecture": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get a conversation by uuid", + "description": "get runtime framework architectures", "consumes": [ "application/json" ], @@ -8548,13 +8117,13 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Get a conversation by uuid", + "summary": "Get runtime framework architectures", "parameters": [ { - "type": "string", - "description": "conversation uuid", + "type": "integer", + "description": "runtime framework id", "name": "id", "in": "path", "required": true @@ -8587,7 +8156,7 @@ "ApiKey": [] } ], - "description": "Update a conversation title", + "description": "set runtime framework architectures", "consumes": [ "application/json" ], @@ -8595,13 +8164,13 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Update a conversation title", + "summary": "Set runtime framework architectures", "parameters": [ { - "type": "string", - "description": "conversation uuid", + "type": "integer", + "description": "runtime framework id", "name": "id", "in": "path", "required": true @@ -8612,7 +8181,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.ConversationTitle" + "$ref": "#/definitions/types.RuntimeArchitecture" } } ], @@ -8637,13 +8206,13 @@ } } }, - "post": { + "delete": { "security": [ { "ApiKey": [] } ], - "description": "Submit a conversation message", + "description": "Delete runtime framework architectures", "consumes": [ "application/json" ], @@ -8651,13 +8220,13 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Submit a conversation message", + "summary": "Delete runtime framework architectures", "parameters": [ { - "type": "string", - "description": "conversation uuid", + "type": "integer", + "description": "runtime framework id", "name": "id", "in": "path", "required": true @@ -8668,7 +8237,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.Conversation" + "$ref": "#/definitions/types.RuntimeArchitecture" } } ], @@ -8692,14 +8261,16 @@ } } } - }, - "delete": { + } + }, + "/runtime_framework/{id}/models": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Delete a conversation", + "description": "get visible models by runtime framework for current user", "consumes": [ "application/json" ], @@ -8707,22 +8278,54 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Delete a conversation", + "summary": "Get Visible models by runtime framework for current user", "parameters": [ { - "type": "string", - "description": "conversation uuid", + "type": "integer", + "description": "runtime framework id", "name": "id", "in": "path", "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" + }, + { + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "default": 1, + "description": "deploy_type", + "name": "deploy_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/types.Response" } }, @@ -8739,16 +8342,14 @@ } } } - } - }, - "/prompts/conversations/{id}/message/{msgid}/hate": { + }, "put": { "security": [ { "ApiKey": [] } ], - "description": "Hate a conversation message", + "description": "set model runtime frameworks", "consumes": [ "application/json" ], @@ -8756,23 +8357,43 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Hate a conversation message", + "summary": "Set model runtime frameworks", "parameters": [ { - "type": "string", - "description": "conversation uuid", - "name": "uuid", + "type": "integer", + "description": "runtime framework id", + "name": "id", "in": "path", "required": true }, + { + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "default": 1, + "description": "deploy_type", + "name": "deploy_type", + "in": "query" + }, { "type": "string", - "description": "message id", - "name": "id", - "in": "path", - "required": true + "description": "current user", + "name": "current_user", + "in": "query" + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.RuntimeFrameworkModels" + } } ], "responses": { @@ -8788,6 +8409,12 @@ "$ref": "#/definitions/types.APIBadRequest" } }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/types.APIForbidden" + } + }, "500": { "description": "Internal server error", "schema": { @@ -8795,16 +8422,14 @@ } } } - } - }, - "/prompts/conversations/{id}/message/{msgid}/like": { - "put": { + }, + "delete": { "security": [ { "ApiKey": [] } ], - "description": "Like a conversation message", + "description": "set model runtime frameworks", "consumes": [ "application/json" ], @@ -8812,23 +8437,37 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Like a conversation message", + "summary": "Set model runtime frameworks", "parameters": [ { - "type": "string", - "description": "conversation uuid", - "name": "uuid", + "type": "integer", + "description": "runtime framework id", + "name": "id", "in": "path", "required": true }, { - "type": "string", - "description": "message id", - "name": "id", - "in": "path", - "required": true + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "default": 1, + "description": "deploy_type", + "name": "deploy_type", + "in": "query" + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.RuntimeFrameworkModels" + } } ], "responses": { @@ -8844,6 +8483,12 @@ "$ref": "#/definitions/types.APIBadRequest" } }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/types.APIForbidden" + } + }, "500": { "description": "Internal server error", "schema": { @@ -8853,14 +8498,14 @@ } } }, - "/prompts/conversations/{id}/summary": { - "put": { + "/runtime_framework/{id}/scan": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "Summarize a conversation title", + "description": "Scan runtime architecture", "consumes": [ "application/json" ], @@ -8868,16 +8513,36 @@ "application/json" ], "tags": [ - "Prompt" + "RuntimeFramework" ], - "summary": "Summarize a conversation title", + "summary": "Scan runtime architecture", "parameters": [ { - "type": "string", - "description": "conversation uuid", + "type": "integer", + "description": "runtime framework id", "name": "id", "in": "path", "required": true + }, + { + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "description": "scan_type(0:all models, 1:new models, 2:old models)", + "name": "scan_type", + "in": "query" + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.RuntimeFrameworkModels" + } } ], "responses": { @@ -8902,14 +8567,14 @@ } } }, - "/prompts/{namespace}/{name}": { + "/space_resources": { "get": { "security": [ { "ApiKey": [] } ], - "description": "List prompts", + "description": "get space resources", "consumes": [ "application/json" ], @@ -8917,30 +8582,52 @@ "application/json" ], "tags": [ - "Prompt" + "SpaceReource" ], - "summary": "List prompts", + "summary": "Get space resources", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true + "description": "cluster_id", + "name": "cluster_id", + "in": "query" }, { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "default": 1, + "description": "deploy type(0-space,1-inference,2-finetune)", + "name": "deploy_type", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.SpaceResource" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -8957,13 +8644,13 @@ } } }, - "put": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "update a exists prompt repo", + "description": "create space resource", "consumes": [ "application/json" ], @@ -8971,37 +8658,17 @@ "application/json" ], "tags": [ - "Prompt" + "SpaceReource" ], - "summary": "Update a exists prompt repo", + "summary": "Create space resource", "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdatePromptRepoReq" + "$ref": "#/definitions/types.CreateSpaceResourceReq" } } ], @@ -9009,7 +8676,22 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.SpaceResource" + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -9025,14 +8707,16 @@ } } } - }, - "delete": { - "security": [ - { - "ApiKey": [] + } + }, + "/space_resources/{id}": { + "put": { + "security": [ + { + "ApiKey": [] } ], - "description": "delete a exists prompt repo", + "description": "update a exist space resource", "consumes": [ "application/json" ], @@ -9040,36 +8724,47 @@ "application/json" ], "tags": [ - "Prompt" + "SpaceReource" ], - "summary": "Delete a exists prompt repo", + "summary": "Update a exist space resource", "parameters": [ { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "type": "integer", + "description": "id", + "name": "id", "in": "path", "required": true }, { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateSpaceResourceReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.SpaceResource" + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -9085,15 +8780,14 @@ } } } - } - }, - "/prompts/{namespace}/{name}/branches": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] } ], + "description": "delete a exist space resource", "consumes": [ "application/json" ], @@ -9101,38 +8795,58 @@ "application/json" ], "tags": [ - "Prompt" + "SpaceReource" ], - "summary": "Get the branches of prompt repository", + "summary": "Delete a exist space resource", "parameters": [ { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", + "type": "integer", + "description": "id", + "name": "id", "in": "path", "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.Response" + } }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/types.APIBadRequest" + } }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/types.APIInternalServerError" + } + } + } + } + }, + "/space_sdks": { + "get": { + "security": [ { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" + "ApiKey": [] } ], + "description": "get space sdks", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SpaceSdk" + ], + "summary": "Get space sdks", "responses": { "200": { "description": "OK", @@ -9147,8 +8861,11 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/types.Branch" + "$ref": "#/definitions/types.SpaceSdk" } + }, + "total": { + "type": "integer" } } } @@ -9168,16 +8885,14 @@ } } } - } - }, - "/prompts/{namespace}/{name}/prompt/file": { + }, "post": { "security": [ { "ApiKey": [] } ], - "description": "Create prompt in repo", + "description": "create space sdk", "consumes": [ "application/json" ], @@ -9185,36 +8900,40 @@ "application/json" ], "tags": [ - "Prompt" + "SpaceSdk" ], - "summary": "Create prompt in repo", + "summary": "Create space sdk", "parameters": [ { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateSpaceSdkReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.SpaceSdk" + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -9232,14 +8951,14 @@ } } }, - "/prompts/{namespace}/{name}/prompt/file/{file_path}": { + "/space_sdks/{id}": { "put": { "security": [ { "ApiKey": [] } ], - "description": "Update prompt in repo", + "description": "update a exist space sdk", "consumes": [ "application/json" ], @@ -9247,43 +8966,47 @@ "application/json" ], "tags": [ - "Prompt" + "SpaceSdk" ], - "summary": "Update prompt in repo", + "summary": "Update a exist space sdk", "parameters": [ { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the file relative path", - "name": "file_path", + "type": "integer", + "description": "id", + "name": "id", "in": "path", "required": true }, { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateSpaceSdkReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.SpaceSdk" + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -9306,7 +9029,7 @@ "ApiKey": [] } ], - "description": "Delete prompt in repo", + "description": "delete a exist space sdk", "consumes": [ "application/json" ], @@ -9314,36 +9037,16 @@ "application/json" ], "tags": [ - "Prompt" + "SpaceSdk" ], - "summary": "Delete prompt in repo", + "summary": "Delete a exist space sdk", "parameters": [ { - "type": "string", - "description": "namespace", - "name": "namespace", + "type": "integer", + "description": "id", + "name": "写id", "in": "path", "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" } ], "responses": { @@ -9368,14 +9071,14 @@ } } }, - "/prompts/{namespace}/{name}/prompt/view/{file_path}": { + "/spaces": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get prompts by file", + "description": "get spaces visible to current user", "consumes": [ "application/json" ], @@ -9383,35 +9086,75 @@ "application/json" ], "tags": [ - "Prompt" + "Space" ], - "summary": "Get prompts by file", + "summary": "Get spaces visible to current user", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true + "description": "current user", + "name": "current_user", + "in": "query" }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true + "description": "search text", + "name": "search", + "in": "query" }, { "type": "string", - "description": "the file relative path", - "name": "file_path", - "in": "path", - "required": true + "description": "filter by task tag", + "name": "task_tag", + "in": "query" }, { "type": "string", - "description": "current user name", - "name": "current_user", + "description": "filter by framework tag", + "name": "framework_tag", + "in": "query" + }, + { + "type": "string", + "description": "filter by license tag", + "name": "license_tag", + "in": "query" + }, + { + "type": "string", + "description": "filter by language tag", + "name": "language_tag", + "in": "query" + }, + { + "type": "string", + "description": "sort by", + "name": "sort", + "in": "query" + }, + { + "enum": [ + "opencsg", + "huggingface", + "local" + ], + "type": "string", + "description": "source", + "name": "source", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", "in": "query" } ], @@ -9419,7 +9162,25 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Space" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -9435,15 +9196,14 @@ } } } - } - }, - "/prompts/{namespace}/{name}/relations": { - "get": { + }, + "post": { "security": [ { "ApiKey": [] } ], + "description": "create a new space", "consumes": [ "application/json" ], @@ -9451,29 +9211,25 @@ "application/json" ], "tags": [ - "Prompt" + "Space" ], - "summary": "Get prompt related assets", + "summary": "Create a new space", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", + "description": "current_user", + "name": "current_user", + "in": "query", "required": true }, { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateSpaceReq" + } } ], "responses": { @@ -9488,7 +9244,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Relations" + "$ref": "#/definitions/types.Space" } } } @@ -9508,8 +9264,10 @@ } } } - }, - "put": { + } + }, + "/spaces/{namespace}/{name}": { + "get": { "security": [ { "ApiKey": [] @@ -9522,9 +9280,9 @@ "application/json" ], "tags": [ - "Prompt" + "Space" ], - "summary": "Set model relation for prompt", + "summary": "show space detail", "parameters": [ { "type": "string", @@ -9542,25 +9300,29 @@ }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", - "in": "query" - }, - { - "description": "set model relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationModels" - } + "in": "query", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Space" + } + } + } + ] } }, "400": { @@ -9576,15 +9338,14 @@ } } } - } - }, - "/prompts/{namespace}/{name}/relations/model": { - "post": { + }, + "put": { "security": [ { "ApiKey": [] } ], + "description": "update a exists space", "consumes": [ "application/json" ], @@ -9592,9 +9353,9 @@ "application/json" ], "tags": [ - "Prompt" + "Space" ], - "summary": "add model relation for prompt", + "summary": "Update a exists space", "parameters": [ { "type": "string", @@ -9612,17 +9373,18 @@ }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", - "in": "query" + "in": "query", + "required": true }, { - "description": "add model relation", - "name": "req", + "description": "body", + "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.RelationModel" + "$ref": "#/definitions/types.UpdateSpaceReq" } } ], @@ -9630,7 +9392,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Space" + } + } + } + ] } }, "400": { @@ -9653,6 +9427,7 @@ "ApiKey": [] } ], + "description": "delete a exists space", "consumes": [ "application/json" ], @@ -9660,9 +9435,9 @@ "application/json" ], "tags": [ - "Prompt" + "Space" ], - "summary": "delete model relation for prompt", + "summary": "Delete a exists space", "parameters": [ { "type": "string", @@ -9680,18 +9455,10 @@ }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", - "in": "query" - }, - { - "description": "delelet model relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationModel" - } + "in": "query", + "required": true } ], "responses": { @@ -9716,11 +9483,11 @@ } } }, - "/prompts/{namespace}/{name}/tags": { + "/spaces/{namespace}/{name}/logs": { "get": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], "consumes": [ @@ -9730,53 +9497,33 @@ "application/json" ], "tags": [ - "Prompt" + "Space" ], - "summary": "Get the tags of prompt repository", + "summary": "get space logs", "parameters": [ { "type": "string", - "description": "repo owner name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "repo name", + "description": "name", "name": "name", "in": "path", "required": true }, { "type": "string", - "description": "current user name", + "description": "current_user", "name": "current_user", - "in": "query" - } + "in": "query", + "required": true + } ], "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Tag" - } - } - } - } - ] - } - }, "400": { "description": "Bad request", "schema": { @@ -9792,11 +9539,11 @@ } } }, - "/prompts/{namespace}/{name}/tags/{category}": { + "/spaces/{namespace}/{name}/run": { "post": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], "consumes": [ @@ -9806,63 +9553,37 @@ "application/json" ], "tags": [ - "Prompt" + "Space" ], - "summary": "update the tags of a certain category", + "summary": "run space app", "parameters": [ { "type": "string", - "description": "repo owner name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "repo name", + "description": "name", "name": "name", "in": "path", "required": true }, { "type": "string", - "description": "current user name", + "description": "current_user", "name": "current_user", "in": "query", "required": true - }, - { - "enum": [ - "task", - "license", - "framework", - "language", - "industry" - ], - "type": "string", - "description": "tag category", - "name": "category", - "in": "path", - "required": true - }, - { - "description": "tag names in array", - "name": "tags", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "type": "string" } }, "400": { @@ -9880,11 +9601,11 @@ } } }, - "/recom/opweight": { - "post": { + "/spaces/{namespace}/{name}/status": { + "get": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], "consumes": [ @@ -9894,34 +9615,33 @@ "application/json" ], "tags": [ - "Recommendation" + "Space" ], - "summary": "set op weight for repo recommendation", + "summary": "get space status", "parameters": [ { - "description": "json request body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.SetOpWeight.SetOpWeightReq" - } + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, { "type": "string", - "description": "current user", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current_user", "name": "current_user", "in": "query", "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, "400": { "description": "Bad request", "schema": { @@ -9937,14 +9657,13 @@ } } }, - "/runtime_framework": { - "get": { + "/spaces/{namespace}/{name}/stop": { + "post": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "get all runtime frameworks for current user", "consumes": [ "application/json" ], @@ -9952,24 +9671,33 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Space" ], - "summary": "Get all runtime frameworks for current user", + "summary": "stop space app", "parameters": [ { "type": "string", - "description": "current user", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current_user", "name": "current_user", - "in": "query" + "in": "query", + "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, "400": { "description": "Bad request", "schema": { @@ -9983,14 +9711,15 @@ } } } - }, + } + }, + "/spaces/{namespace}/{name}/wakeup": { "post": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], - "description": "create runtime framework", "consumes": [ "application/json" ], @@ -9998,21 +9727,10 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Space" ], - "summary": "Create runtime framework", + "summary": "wake up space app", "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, { "type": "string", "description": "namespace", @@ -10026,30 +9744,9 @@ "name": "name", "in": "path", "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkReq" - } } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.RuntimeFramework" - } - }, "400": { "description": "Bad request", "schema": { @@ -10065,14 +9762,14 @@ } } }, - "/runtime_framework/models": { + "/sync/client_setting": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get visible models for all runtime frameworks for current user", + "description": "Get sync client setting", "consumes": [ "application/json" ], @@ -10080,59 +9777,26 @@ "application/json" ], "tags": [ - "RuntimeFramework" - ], - "summary": "Get Visible models for all runtime frameworks for current user", - "parameters": [ - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - }, - { - "enum": [ - 1, - 2 - ], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - } + "Sync" ], + "summary": "Get sync client setting", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.SyncClientSetting" + } + } + } + ] } }, "400": { @@ -10148,16 +9812,14 @@ } } } - } - }, - "/runtime_framework/{id}": { - "put": { + }, + "post": { "security": [ { "ApiKey": [] } ], - "description": "Update runtime framework", + "description": "Create sync client setting or update an existing sync client setting", "consumes": [ "application/json" ], @@ -10165,55 +9827,17 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Sync" ], - "summary": "Update runtime framework", + "summary": "Create sync client setting or update an existing sync client setting", "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkReq" + "$ref": "#/definitions/types.CreateSyncClientSettingReq" } } ], @@ -10221,7 +9845,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.RuntimeFramework" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.SyncClientSetting" + } + } + } + ] } }, "400": { @@ -10237,69 +9873,55 @@ } } } - }, - "delete": { + } + }, + "/sync/version/latest": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "delete a exist RuntimeFramework", - "consumes": [ - "application/json" - ], "produces": [ "application/json" ], "tags": [ - "RuntimeFramework" + "Sync" ], - "summary": "Delete a exist RuntimeFramework", + "summary": "Get latest version", "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, { "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", + "description": "current version", + "name": "cur", + "in": "query", "required": true }, { "type": "string", - "description": "current user", + "description": "current_user", "name": "current_user", - "in": "query" + "in": "query", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.SyncVersionResponse" + } + } + } + ] } }, "400": { @@ -10317,14 +9939,14 @@ } } }, - "/runtime_framework/{id}/architecture": { + "/tags": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get runtime framework architectures", + "description": "Get all tags", "consumes": [ "application/json" ], @@ -10332,23 +9954,47 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Tag" ], - "summary": "Get runtime framework architectures", + "summary": "Get all tags", "parameters": [ { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true + "type": "string", + "description": "category name", + "name": "category", + "in": "query" + }, + { + "enum": [ + "model", + "dataset" + ], + "type": "string", + "description": "scope name", + "name": "scope", + "in": "query" } ], "responses": { "200": { - "description": "OK", + "description": "tags", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/database.Tag" + } + } + } + } + ] } }, "400": { @@ -10365,13 +10011,13 @@ } } }, - "put": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "set runtime framework architectures", + "description": "Create new tag", "consumes": [ "application/json" ], @@ -10379,24 +10025,17 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Tag" ], - "summary": "Set runtime framework architectures", + "summary": "Create new tag", "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.RuntimeArchitecture" + "$ref": "#/definitions/types.CreateTag" } } ], @@ -10420,14 +10059,16 @@ } } } - }, - "delete": { + } + }, + "/tags/categories": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Delete runtime framework architectures", + "description": "Get all Categories", "consumes": [ "application/json" ], @@ -10435,32 +10076,29 @@ "application/json" ], "tags": [ - "RuntimeFramework" - ], - "summary": "Delete runtime framework architectures", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeArchitecture" - } - } + "Tag" ], + "summary": "Get all Categories", "responses": { "200": { - "description": "OK", + "description": "categores", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/database.TagCategory" + } + } + } + } + ] } }, "400": { @@ -10476,16 +10114,14 @@ } } } - } - }, - "/runtime_framework/{id}/models": { - "get": { + }, + "post": { "security": [ { "ApiKey": [] } ], - "description": "get visible models by runtime framework for current user", + "description": "Create new category", "consumes": [ "application/json" ], @@ -10493,48 +10129,18 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Tag" ], - "summary": "Get Visible models by runtime framework for current user", + "summary": "Create new category", "parameters": [ { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - }, - { - "enum": [ - 0, - 1, - 2 - ], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateCategory" + } } ], "responses": { @@ -10557,14 +10163,16 @@ } } } - }, + } + }, + "/tags/categories/id": { "put": { "security": [ { "ApiKey": [] } ], - "description": "set model runtime frameworks", + "description": "Create new category", "consumes": [ "application/json" ], @@ -10572,42 +10180,17 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Tag" ], - "summary": "Set model runtime frameworks", + "summary": "Create new category", "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "enum": [ - 0, - 1, - 2 - ], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkModels" + "$ref": "#/definitions/types.UpdateCategory" } } ], @@ -10624,12 +10207,6 @@ "$ref": "#/definitions/types.APIBadRequest" } }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/types.APIForbidden" - } - }, "500": { "description": "Internal server error", "schema": { @@ -10644,7 +10221,7 @@ "ApiKey": [] } ], - "description": "set model runtime frameworks", + "description": "Delete a category by id", "consumes": [ "application/json" ], @@ -10652,39 +10229,9 @@ "application/json" ], "tags": [ - "RuntimeFramework" - ], - "summary": "Set model runtime frameworks", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "enum": [ - 0, - 1, - 2 - ], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkModels" - } - } + "Tag" ], + "summary": "Delete a category by id", "responses": { "200": { "description": "OK", @@ -10698,12 +10245,6 @@ "$ref": "#/definitions/types.APIBadRequest" } }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/types.APIForbidden" - } - }, "500": { "description": "Internal server error", "schema": { @@ -10713,14 +10254,14 @@ } } }, - "/runtime_framework/{id}/scan": { - "post": { + "/tags/{id}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Scan runtime architecture", + "description": "Get a tag by id", "consumes": [ "application/json" ], @@ -10728,36 +10269,16 @@ "application/json" ], "tags": [ - "RuntimeFramework" + "Tag" ], - "summary": "Scan runtime architecture", + "summary": "Get a tag by id", "parameters": [ { - "type": "integer", - "description": "runtime framework id", + "type": "string", + "description": "id of the tag", "name": "id", "in": "path", "required": true - }, - { - "enum": [ - 0, - 1, - 2 - ], - "type": "integer", - "description": "scan_type(0:all models, 1:new models, 2:old models)", - "name": "scan_type", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkModels" - } } ], "responses": { @@ -10780,16 +10301,14 @@ } } } - } - }, - "/space_resources": { - "get": { + }, + "put": { "security": [ { "ApiKey": [] } ], - "description": "get space resources", + "description": "Update a tag by id", "consumes": [ "application/json" ], @@ -10797,52 +10316,32 @@ "application/json" ], "tags": [ - "SpaceReource" + "Tag" ], - "summary": "Get space resources", + "summary": "Update a tag by id", "parameters": [ { "type": "string", - "description": "cluster_id", - "name": "cluster_id", - "in": "query" + "description": "id of the tag", + "name": "id", + "in": "path", + "required": true }, { - "enum": [ - 0, - 1, - 2 - ], - "type": "integer", - "default": 1, - "description": "deploy type(0-space,1-inference,2-finetune)", - "name": "deploy_type", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateTag" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.SpaceResource" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -10859,13 +10358,13 @@ } } }, - "post": { + "delete": { "security": [ { "ApiKey": [] } ], - "description": "create space resource", + "description": "Delete a tag by id", "consumes": [ "application/json" ], @@ -10873,40 +10372,23 @@ "application/json" ], "tags": [ - "SpaceReource" + "Tag" ], - "summary": "Create space resource", + "summary": "Delete a tag by id", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSpaceResourceReq" - } + "type": "string", + "description": "id of the tag", + "name": "id", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SpaceResource" - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -10924,14 +10406,13 @@ } } }, - "/space_resources/{id}": { - "put": { + "/telemetry/usage": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "update a exist space resource", "consumes": [ "application/json" ], @@ -10939,24 +10420,17 @@ "application/json" ], "tags": [ - "SpaceReource" + "Telemetry" ], - "summary": "Update a exist space resource", + "summary": "Submit telemetry data for a client", "parameters": [ - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateSpaceResourceReq" + "$ref": "#/definitions/telemetry.Usage" } } ], @@ -10964,22 +10438,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SpaceResource" - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -10995,14 +10454,15 @@ } } } - }, - "delete": { + } + }, + "/token/{app}/{token_name}": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "delete a exist space resource", "consumes": [ "application/json" ], @@ -11010,81 +10470,47 @@ "application/json" ], "tags": [ - "SpaceReource" + "Access token" ], - "summary": "Delete a exist space resource", + "summary": "Refresh a access token for a user", "parameters": [ { - "type": "integer", - "description": "id", - "name": "id", + "enum": [ + "git", + "starship" + ], + "type": "string", + "description": "application", + "name": "app", "in": "path", "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + { + "type": "string", + "description": "token_name", + "name": "token_name", + "in": "path", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/space_sdks": { - "get": { - "security": [ { - "ApiKey": [] + "type": "string", + "description": "current user, the owner", + "name": "current_user", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "new expire time, in format RFC3339, like 2006-01-02T15:04:05Z07:00", + "name": "expired_at", + "in": "query" } ], - "description": "get space sdks", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SpaceSdk" - ], - "summary": "Get space sdks", "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.SpaceSdk" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -11107,7 +10533,6 @@ "ApiKey": [] } ], - "description": "create space sdk", "consumes": [ "application/json" ], @@ -11115,17 +10540,42 @@ "application/json" ], "tags": [ - "SpaceSdk" + "Access token" ], - "summary": "Create space sdk", + "summary": "Create access token for an special application", "parameters": [ + { + "type": "string", + "description": "token name", + "name": "token_name", + "in": "path", + "required": true + }, + { + "enum": [ + "git", + "starship" + ], + "type": "string", + "description": "application", + "name": "app", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user, the owner", + "name": "current_user", + "in": "query", + "required": true + }, { "description": "body", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateSpaceSdkReq" + "$ref": "#/definitions/types.CreateUserTokenRequest" } } ], @@ -11135,16 +10585,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.SpaceSdk" - }, - "total": { - "type": "integer" + "$ref": "#/definitions/database.AccessToken" } } } @@ -11164,16 +10611,13 @@ } } } - } - }, - "/space_sdks/{id}": { - "put": { + }, + "delete": { "security": [ { "ApiKey": [] } ], - "description": "update a exist space sdk", "consumes": [ "application/json" ], @@ -11181,47 +10625,41 @@ "application/json" ], "tags": [ - "SpaceSdk" + "Access token" ], - "summary": "Update a exist space sdk", + "summary": "Delete access token of a app", "parameters": [ { - "type": "integer", - "description": "id", - "name": "id", + "enum": [ + "git", + "starship" + ], + "type": "string", + "description": "application", + "name": "app", "in": "path", "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateSpaceSdkReq" - } + "type": "string", + "description": "token_name", + "name": "token_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user, the owner", + "name": "current_user", + "in": "query", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SpaceSdk" - }, - "total": { - "type": "integer" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -11237,14 +10675,15 @@ } } } - }, - "delete": { + } + }, + "/token/{token_value}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "delete a exist space sdk", "consumes": [ "application/json" ], @@ -11252,16 +10691,26 @@ "application/json" ], "tags": [ - "SpaceSdk" + "Access token" ], - "summary": "Delete a exist space sdk", + "summary": "Get token and owner's detail by the token value", "parameters": [ { - "type": "integer", - "description": "id", - "name": "写id", + "type": "string", + "description": "token_value", + "name": "token_value", "in": "path", "required": true + }, + { + "enum": [ + "git", + "starship" + ], + "type": "string", + "description": "application", + "name": "app", + "in": "query" } ], "responses": { @@ -11286,14 +10735,13 @@ } } }, - "/spaces": { + "/user/{username}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get spaces visible to current user", "consumes": [ "application/json" ], @@ -11301,75 +10749,31 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "Get spaces visible to current user", + "summary": "Get user info. Admin and the user self can see full info, other users can only see basic info.", "parameters": [ { "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "filter by task tag", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag", - "name": "language_tag", - "in": "query" + "description": "username or uuid, defined by the query string 'type'", + "name": "username", + "in": "path", + "required": true }, { "type": "string", - "description": "sort by", - "name": "sort", + "description": "current user", + "name": "current_user", "in": "query" }, { "enum": [ - "opencsg", - "huggingface", - "local" + "username", + "uuid" ], "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", + "description": "path param is usernam or uuid, default to username", + "name": "type", "in": "query" } ], @@ -11379,19 +10783,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/types.User" } } } @@ -11412,13 +10810,13 @@ } } }, - "post": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "create a new space", + "description": "update user", "consumes": [ "application/json" ], @@ -11426,13 +10824,20 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "Create a new space", + "summary": "Update user. If change user name, should only send 'new_username' in the request body.", "parameters": [ { "type": "string", - "description": "current_user", + "description": "username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user", "name": "current_user", "in": "query", "required": true @@ -11443,7 +10848,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateSpaceReq" + "$ref": "#/definitions/types.UpdateUserRequest" } } ], @@ -11451,19 +10856,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Space" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -11479,10 +10872,8 @@ } } } - } - }, - "/spaces/{namespace}/{name}": { - "get": { + }, + "delete": { "security": [ { "ApiKey": [] @@ -11495,49 +10886,39 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "show space detail", + "summary": "Delete user", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "username", + "name": "username", "in": "path", "required": true }, { "type": "string", - "description": "current_user", + "description": "current user", "name": "current_user", "in": "query", "required": true + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateUserRequest" + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Space" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -11553,14 +10934,16 @@ } } } - }, - "put": { + } + }, + "/user/{username}/codes": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "update a exists space", + "description": "get user codes", "consumes": [ "application/json" ], @@ -11568,39 +10951,16 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "Update a exists space", + "summary": "Get user codes", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "username", + "name": "username", "in": "path", "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateSpaceReq" - } } ], "responses": { @@ -11609,13 +10969,19 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.Response" + "$ref": "#/definitions/types.ResponseWithTotal" }, { "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.Space" + "type": "array", + "items": { + "$ref": "#/definitions/types.Code" + } + }, + "total": { + "type": "integer" } } } @@ -11635,14 +11001,15 @@ } } } - }, - "delete": { + } + }, + "/user/{username}/collections": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "delete a exists space", "consumes": [ "application/json" ], @@ -11650,37 +11017,41 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "Delete a exists space", + "summary": "Get user's collections", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "username", + "name": "username", "in": "path", "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Collection" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -11698,13 +11069,14 @@ } } }, - "/spaces/{namespace}/{name}/logs": { + "/user/{username}/datasets": { "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], + "description": "get user datasets", "consumes": [ "application/json" ], @@ -11712,33 +11084,43 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "get space logs", + "summary": "Get user datasets", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "username", + "name": "username", "in": "path", "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true } ], "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Dataset" + } + }, + "total": { + "type": "integer" + } + } + } + ] + } + }, "400": { "description": "Bad request", "schema": { @@ -11754,13 +11136,14 @@ } } }, - "/spaces/{namespace}/{name}/run": { - "post": { + "/user/{username}/evaluations": { + "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], + "description": "get user evaluations", "consumes": [ "application/json" ], @@ -11768,37 +11151,37 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "run space app", + "summary": "Get user evaluations", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", + "description": "username", + "name": "username", "in": "path", "required": true }, { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true + "type": "integer", + "default": 20, + "description": "per", + "name": "per", + "in": "query" }, { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "type": "string" + "$ref": "#/definitions/types.Response" } }, "400": { @@ -11816,13 +11199,14 @@ } } }, - "/spaces/{namespace}/{name}/status": { + "/user/{username}/finetune/instances": { "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], + "description": "Get user running notebook instances", "consumes": [ "application/json" ], @@ -11830,33 +11214,45 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "get space status", + "summary": "Get user running notebook instances", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", + "description": "username", + "name": "username", "in": "path", "required": true }, { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "page index", + "name": "page", + "in": "query" }, { "type": "string", - "description": "current_user", + "description": "current user", "name": "current_user", - "in": "query", - "required": true + "in": "query" } ], "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.Response" + } + }, "400": { "description": "Bad request", "schema": { @@ -11872,13 +11268,14 @@ } } }, - "/spaces/{namespace}/{name}/stop": { - "post": { + "/user/{username}/likes/codes": { + "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], + "description": "get user likes codes", "consumes": [ "application/json" ], @@ -11886,33 +11283,43 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "stop space app", + "summary": "Get user likes codes", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "username", + "name": "username", "in": "path", "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true } ], "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Code" + } + }, + "total": { + "type": "integer" + } + } + } + ] + } + }, "400": { "description": "Bad request", "schema": { @@ -11928,11 +11335,11 @@ } } }, - "/spaces/{namespace}/{name}/wakeup": { - "post": { + "/user/{username}/likes/collections": { + "get": { "security": [ { - "JWT token": [] + "ApiKey": [] } ], "consumes": [ @@ -11942,26 +11349,43 @@ "application/json" ], "tags": [ - "Space" + "User" ], - "summary": "wake up space app", + "summary": "Get user likes collections", "parameters": [ { "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", + "description": "username", + "name": "username", "in": "path", "required": true } ], "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Collection" + } + }, + "total": { + "type": "integer" + } + } + } + ] + } + }, "400": { "description": "Bad request", "schema": { @@ -11977,14 +11401,13 @@ } } }, - "/sync/client_setting": { - "get": { + "/user/{username}/likes/collections/{id}": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "Get sync client setting", "consumes": [ "application/json" ], @@ -11992,26 +11415,30 @@ "application/json" ], "tags": [ - "Sync" + "User" + ], + "summary": "Add collection likes", + "parameters": [ + { + "type": "string", + "description": "username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "collection id", + "name": "id", + "in": "path", + "required": true + } ], - "summary": "Get sync client setting", "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.SyncClientSetting" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -12028,13 +11455,12 @@ } } }, - "post": { + "delete": { "security": [ { "ApiKey": [] } ], - "description": "Create sync client setting or update an existing sync client setting", "consumes": [ "application/json" ], @@ -12042,37 +11468,30 @@ "application/json" ], "tags": [ - "Sync" + "User" ], - "summary": "Create sync client setting or update an existing sync client setting", + "summary": "delete collection likes", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSyncClientSettingReq" - } + "type": "string", + "description": "username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "collection id", + "name": "id", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.SyncClientSetting" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -12090,33 +11509,30 @@ } } }, - "/sync/version/latest": { + "/user/{username}/likes/datasets": { "get": { "security": [ { "ApiKey": [] } ], + "description": "get user likes datasets", + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], "tags": [ - "Sync" + "User" ], - "summary": "Get latest version", + "summary": "Get user likes datasets", "parameters": [ { "type": "string", - "description": "current version", - "name": "cur", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", + "description": "username", + "name": "username", + "in": "path", "required": true } ], @@ -12126,13 +11542,19 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.Response" + "$ref": "#/definitions/types.ResponseWithTotal" }, { "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.SyncVersionResponse" + "type": "array", + "items": { + "$ref": "#/definitions/types.Dataset" + } + }, + "total": { + "type": "integer" } } } @@ -12154,14 +11576,14 @@ } } }, - "/tags": { + "/user/{username}/likes/models": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get all tags", + "description": "get user likes models", "consumes": [ "application/json" ], @@ -12169,30 +11591,21 @@ "application/json" ], "tags": [ - "Tag" + "User" ], - "summary": "Get all tags", + "summary": "Get user likes models", "parameters": [ { "type": "string", - "description": "category name", - "name": "category", - "in": "query" - }, - { - "enum": [ - "model", - "dataset" - ], - "type": "string", - "description": "scope name", - "name": "scope", - "in": "query" + "description": "username", + "name": "username", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "tags", + "description": "OK", "schema": { "allOf": [ { @@ -12204,8 +11617,11 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/database.Tag" + "$ref": "#/definitions/types.Model" } + }, + "total": { + "type": "integer" } } } @@ -12225,14 +11641,15 @@ } } } - }, - "post": { + } + }, + "/user/{username}/likes/spaces": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Create new tag", "consumes": [ "application/json" ], @@ -12240,63 +11657,21 @@ "application/json" ], "tags": [ - "Tag" + "User" ], - "summary": "Create new tag", + "summary": "Get user likes spaces", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateTag" - } + "type": "string", + "description": "username", + "name": "username", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/tags/categories": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get all Categories", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Tag" - ], - "summary": "Get all Categories", - "responses": { - "200": { - "description": "categores", "schema": { "allOf": [ { @@ -12308,8 +11683,11 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/database.TagCategory" + "$ref": "#/definitions/types.Space" } + }, + "total": { + "type": "integer" } } } @@ -12329,14 +11707,15 @@ } } } - }, - "post": { + } + }, + "/user/{username}/likes/{repoid}": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "Create new category", "consumes": [ "application/json" ], @@ -12344,18 +11723,23 @@ "application/json" ], "tags": [ - "Tag" + "User" ], - "summary": "Create new category", + "summary": "Add user likes", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCategory" - } + "type": "string", + "description": "username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo id", + "name": "repo_id", + "in": "path", + "required": true } ], "responses": { @@ -12378,16 +11762,14 @@ } } } - } - }, - "/tags/categories/id": { - "put": { + }, + "delete": { "security": [ { "ApiKey": [] } ], - "description": "Create new category", + "description": "Delete user likes", "consumes": [ "application/json" ], @@ -12395,18 +11777,23 @@ "application/json" ], "tags": [ - "Tag" + "User" ], - "summary": "Create new category", + "summary": "Delete user likes", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCategory" - } + "type": "string", + "description": "username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo id", + "name": "repo_id", + "in": "path", + "required": true } ], "responses": { @@ -12429,14 +11816,16 @@ } } } - }, - "delete": { + } + }, + "/user/{username}/models": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Delete a category by id", + "description": "get user models", "consumes": [ "application/json" ], @@ -12444,14 +11833,41 @@ "application/json" ], "tags": [ - "Tag" + "User" + ], + "summary": "Get user models", + "parameters": [ + { + "type": "string", + "description": "username", + "name": "username", + "in": "path", + "required": true + } ], - "summary": "Delete a category by id", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Model" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -12469,14 +11885,14 @@ } } }, - "/tags/{id}": { + "/user/{username}/prompts": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get a tag by id", + "description": "get user prompts", "consumes": [ "application/json" ], @@ -12484,16 +11900,30 @@ "application/json" ], "tags": [ - "Tag" + "User" ], - "summary": "Get a tag by id", + "summary": "Get user prompts", "parameters": [ { "type": "string", - "description": "id of the tag", - "name": "id", + "description": "username", + "name": "username", "in": "path", "required": true + }, + { + "type": "integer", + "default": 20, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "per page", + "name": "page", + "in": "query" } ], "responses": { @@ -12516,14 +11946,16 @@ } } } - }, - "put": { + } + }, + "/user/{username}/run/serverless": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Update a tag by id", + "description": "Get serverless deploys", "consumes": [ "application/json" ], @@ -12531,25 +11963,36 @@ "application/json" ], "tags": [ - "Tag" + "User" ], - "summary": "Update a tag by id", + "summary": "Get serverless deploys", "parameters": [ { "type": "string", - "description": "id of the tag", - "name": "id", + "description": "username", + "name": "username", "in": "path", "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateTag" - } + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "page index", + "name": "page", + "in": "query" + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" } ], "responses": { @@ -12572,14 +12015,16 @@ } } } - }, - "delete": { + } + }, + "/user/{username}/run/{repo_type}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "Delete a tag by id", + "description": "Get user running deploys", "consumes": [ "application/json" ], @@ -12587,16 +12032,59 @@ "application/json" ], "tags": [ - "Tag" + "User" ], - "summary": "Delete a tag by id", + "summary": "Get user running deploys", "parameters": [ { "type": "string", - "description": "id of the tag", - "name": "id", + "description": "username", + "name": "username", + "in": "path", + "required": true + }, + { + "enum": [ + "model", + "space" + ], + "type": "string", + "description": "model,space", + "name": "repo_type", "in": "path", "required": true + }, + { + "enum": [ + 0, + 1, + 2 + ], + "type": "integer", + "default": 1, + "description": "deploy type(0-space,1-inference,2-finetune)", + "name": "deploy_type", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "per", + "name": "per", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "page index", + "name": "page", + "in": "query" + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" } ], "responses": { @@ -12621,8 +12109,8 @@ } } }, - "/telemetry/usage": { - "post": { + "/user/{username}/spaces": { + "get": { "security": [ { "ApiKey": [] @@ -12635,25 +12123,41 @@ "application/json" ], "tags": [ - "Telemetry" + "User" ], - "summary": "Submit telemetry data for a client", + "summary": "Get user spaces", "parameters": [ { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/telemetry.Usage" - } + "type": "string", + "description": "username", + "name": "username", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Space" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -12671,13 +12175,14 @@ } } }, - "/token/{app}/{token_name}": { - "put": { + "/user/{username}/ssh_key/{name}": { + "delete": { "security": [ { "ApiKey": [] } ], + "description": "delete specific SSH key for the given user", "consumes": [ "application/json" ], @@ -12685,40 +12190,23 @@ "application/json" ], "tags": [ - "Access token" + "SSH Key" ], - "summary": "Refresh a access token for a user", + "summary": "Delete specific SSH key for the given user", "parameters": [ { - "enum": [ - "git", - "starship" - ], "type": "string", - "description": "application", - "name": "app", + "description": "username", + "name": "username", "in": "path", "required": true }, { "type": "string", - "description": "token_name", - "name": "token_name", + "description": "key name", + "name": "name", "in": "path", "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "new expire time, in format RFC3339, like 2006-01-02T15:04:05Z07:00", - "name": "expired_at", - "in": "query" } ], "responses": { @@ -12741,13 +12229,16 @@ } } } - }, - "post": { + } + }, + "/user/{username}/ssh_keys": { + "get": { "security": [ { "ApiKey": [] } ], + "description": "get all SSH keys for the given user", "consumes": [ "application/json" ], @@ -12755,43 +12246,16 @@ "application/json" ], "tags": [ - "Access token" + "SSH Key" ], - "summary": "Create access token for an special application", + "summary": "Get all SSH keys for the given user", "parameters": [ { "type": "string", - "description": "token name", - "name": "token_name", - "in": "path", - "required": true - }, - { - "enum": [ - "git", - "starship" - ], - "type": "string", - "description": "application", - "name": "app", + "description": "username", + "name": "username", "in": "path", "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateUserTokenRequest" - } } ], "responses": { @@ -12800,13 +12264,19 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.Response" + "$ref": "#/definitions/types.ResponseWithTotal" }, { "type": "object", "properties": { "data": { - "$ref": "#/definitions/database.AccessToken" + "type": "array", + "items": { + "$ref": "#/definitions/database.SSHKey" + } + }, + "total": { + "type": "integer" } } } @@ -12827,12 +12297,13 @@ } } }, - "delete": { + "post": { "security": [ { "ApiKey": [] } ], + "description": "create a new SSH key for the given user", "consumes": [ "application/json" ], @@ -12840,41 +12311,44 @@ "application/json" ], "tags": [ - "Access token" + "SSH Key" ], - "summary": "Delete access token of a app", + "summary": "Create a new SSH key for the given user", "parameters": [ - { - "enum": [ - "git", - "starship" - ], - "type": "string", - "description": "application", - "name": "app", - "in": "path", - "required": true - }, { "type": "string", - "description": "token_name", - "name": "token_name", + "description": "username", + "name": "username", "in": "path", "required": true }, { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateSSHKeyRequest" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/database.SSHKey" + } + } + } + ] } }, "400": { @@ -12892,7 +12366,7 @@ } } }, - "/token/{token_value}": { + "/user/{username}/tokens": { "get": { "security": [ { @@ -12908,15 +12382,21 @@ "tags": [ "Access token" ], - "summary": "Get token and owner's detail by the token value", + "summary": "Get all access tokens for a user", "parameters": [ { "type": "string", - "description": "token_value", - "name": "token_value", + "description": "username", + "name": "username", "in": "path", "required": true }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" + }, { "enum": [ "git", @@ -12948,15 +12428,14 @@ } } } - } - }, - "/user/{username}": { - "get": { + }, + "post": { "security": [ { "ApiKey": [] } ], + "description": "create access token for a user", "consumes": [ "application/json" ], @@ -12964,32 +12443,32 @@ "application/json" ], "tags": [ - "User" + "Access token" ], - "summary": "Get user info. Admin and the user self can see full info, other users can only see basic info.", + "summary": "[Deprecated: use POST:/token/{app}/{username} instead]", "parameters": [ { "type": "string", - "description": "username or uuid, defined by the query string 'type'", + "description": "username", "name": "username", "in": "path", "required": true }, { "type": "string", - "description": "current user", + "description": "current user, the owner", "name": "current_user", - "in": "query" + "in": "query", + "required": true }, { - "enum": [ - "username", - "uuid" - ], - "type": "string", - "description": "path param is usernam or uuid, default to username", - "name": "type", - "in": "query" + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateUserTokenRequest" + } } ], "responses": { @@ -13004,7 +12483,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/types.User" + "$ref": "#/definitions/database.AccessToken" } } } @@ -13024,14 +12503,15 @@ } } } - }, - "put": { + } + }, + "/user/{username}/tokens/{token_name}": { + "delete": { "security": [ { "ApiKey": [] } ], - "description": "update user", "consumes": [ "application/json" ], @@ -13039,9 +12519,9 @@ "application/json" ], "tags": [ - "User" + "Access token" ], - "summary": "Update user. If change user name, should only send 'new_username' in the request body.", + "summary": "[Deprecated: use DELETE:/token/{app}/{token_name} instead]", "parameters": [ { "type": "string", @@ -13052,7 +12532,14 @@ }, { "type": "string", - "description": "current user", + "description": "token_name", + "name": "token_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user, the owner", "name": "current_user", "in": "query", "required": true @@ -13063,7 +12550,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.UpdateUserRequest" + "$ref": "#/definitions/types.DeleteUserTokenRequest" } } ], @@ -13087,8 +12574,10 @@ } } } - }, - "delete": { + } + }, + "/users": { + "get": { "security": [ { "ApiKey": [] @@ -13103,37 +12592,39 @@ "tags": [ "User" ], - "summary": "Delete user", + "summary": "Get users info. Only Admin", "parameters": [ { "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", + "description": "search", + "name": "search", "in": "query", "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateUserRequest" - } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.User" + } + }, + "total": { + "type": "integer" + } + } + } + ] } }, "400": { @@ -13151,14 +12642,13 @@ } } }, - "/user/{username}/codes": { + "/{repo_type}/{namespace}/{name}/blob/{file_path}": { "get": { "security": [ { - "ApiKey": [] + "ApiKey or JWT": [] } ], - "description": "get user codes", "consumes": [ "application/json" ], @@ -13166,16 +12656,56 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user codes", + "summary": "Get the repo file information like size, content, sha etc", "parameters": [ + { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, { "type": "string", - "description": "username", - "name": "username", + "description": "repo owner name", + "name": "namespace", "in": "path", "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "file path", + "name": "file_path", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" } ], "responses": { @@ -13190,13 +12720,7 @@ "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/types.File" } } } @@ -13218,7 +12742,7 @@ } } }, - "/user/{username}/collections": { + "/{repo_type}/{namespace}/{name}/branches": { "get": { "security": [ { @@ -13232,16 +12756,49 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user's collections", + "summary": "Get the branches of repository", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" } ], "responses": { @@ -13258,11 +12815,8 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/types.Collection" + "$ref": "#/definitions/types.Branch" } - }, - "total": { - "type": "integer" } } } @@ -13284,14 +12838,13 @@ } } }, - "/user/{username}/datasets": { + "/{repo_type}/{namespace}/{name}/commit/{commit_id}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get user datasets", "consumes": [ "application/json" ], @@ -13299,16 +12852,49 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user datasets", + "summary": "Get commit diff of repository and data field of response need to be decode with base64", "parameters": [ + { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "models,datasets,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, { "type": "string", - "description": "username", - "name": "username", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "commit id", + "name": "commit_id", "in": "path", "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" } ], "responses": { @@ -13317,19 +12903,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/types.CommitResponse" } } } @@ -13351,14 +12931,13 @@ } } }, - "/user/{username}/evaluations": { + "/{repo_type}/{namespace}/{name}/commits": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get user evaluations", "consumes": [ "application/json" ], @@ -13366,17 +12945,50 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user evaluations", + "summary": "Get all commits of repository", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" + }, { "type": "integer", "default": 20, @@ -13396,7 +13008,22 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Commit" + } + } + } + } + ] } }, "400": { @@ -13414,14 +13041,14 @@ } } }, - "/user/{username}/finetune/instances": { + "/{repo_type}/{namespace}/{name}/discussions": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get user running notebook instances", + "description": "list repo discussions", "consumes": [ "application/json" ], @@ -13429,43 +13056,61 @@ "application/json" ], "tags": [ - "User" + "Discussion" ], - "summary": "Get user running notebook instances", + "summary": "List repo discussions", "parameters": [ { "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true + "description": "current user", + "name": "current_user", + "in": "query" }, { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "repository type", + "name": "repo_type", + "in": "path", + "required": true }, { - "type": "integer", - "default": 1, - "description": "page index", - "name": "page", - "in": "query" + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, { "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" + "description": "name", + "name": "name", + "in": "query", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.ListRepoDiscussionResponse" + } + } + } + ] } }, "400": { @@ -13481,16 +13126,14 @@ } } } - } - }, - "/user/{username}/likes/codes": { - "get": { + }, + "post": { "security": [ { "ApiKey": [] } ], - "description": "get user likes codes", + "description": "create a new repo discussion", "consumes": [ "application/json" ], @@ -13498,42 +13141,72 @@ "application/json" ], "tags": [ - "User" + "Discussion" ], - "summary": "Get user likes codes", + "summary": "Create a new repo discussion", "parameters": [ { "type": "string", - "description": "username", - "name": "username", - "in": "path", + "description": "current user, the owner", + "name": "current_user", + "in": "query", "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } + }, + { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "repository type", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateRepoDiscussionRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/types.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.CreateDiscussionResponse" + } + } + } + ] + } }, "400": { "description": "Bad request", @@ -13550,11 +13223,11 @@ } } }, - "/user/{username}/likes/collections": { + "/{repo_type}/{namespace}/{name}/download/{file_path}": { "get": { "security": [ { - "ApiKey": [] + "ApiKey or JWT": [] } ], "consumes": [ @@ -13564,16 +13237,61 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user likes collections", + "summary": "Download a repo file [Depricated: use 'resolve' api instead]", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "file path", + "name": "file_path", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query" + }, + { + "type": "string", + "description": "file name to save as", + "name": "save_as", + "in": "query" + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" } ], "responses": { @@ -13588,13 +13306,7 @@ "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Collection" - } - }, - "total": { - "type": "integer" + "type": "object" } } } @@ -13616,7 +13328,7 @@ } } }, - "/user/{username}/likes/collections/{id}": { + "/{repo_type}/{namespace}/{name}/incr_downloads": { "put": { "security": [ { @@ -13630,21 +13342,34 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Add collection likes", + "summary": "Increase repo download count by 1", "parameters": [ + { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, { "type": "string", - "description": "username", - "name": "username", + "description": "repo owner name", + "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "collection id", - "name": "id", + "description": "repo name", + "name": "name", "in": "path", "required": true } @@ -13669,8 +13394,10 @@ } } } - }, - "delete": { + } + }, + "/{repo_type}/{namespace}/{name}/last_commit": { + "get": { "security": [ { "ApiKey": [] @@ -13683,30 +13410,68 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "delete collection likes", + "summary": "Get the last commit of repository", "parameters": [ + { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, { "type": "string", - "description": "username", - "name": "username", + "description": "repo owner name", + "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "collection id", - "name": "id", + "description": "repo name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.Commit" + } + } + } + ] } }, "400": { @@ -13724,14 +13489,13 @@ } } }, - "/user/{username}/likes/datasets": { + "/{repo_type}/{namespace}/{name}/mirror": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get user likes datasets", "consumes": [ "application/json" ], @@ -13739,16 +13503,43 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user likes datasets", + "summary": "Get a mirror", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,datasets,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "current_user", + "name": "current_user", + "in": "query", + "required": true } ], "responses": { @@ -13757,19 +13548,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/database.Mirror" } } } @@ -13789,16 +13574,13 @@ } } } - } - }, - "/user/{username}/likes/models": { - "get": { + }, + "put": { "security": [ { "ApiKey": [] } ], - "description": "get user likes models", "consumes": [ "application/json" ], @@ -13806,16 +13588,45 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user likes models", + "summary": "Update a mirror for a existing repository", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,datasets,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateMirrorParams" + } } ], "responses": { @@ -13824,19 +13635,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/database.Mirror" } } } @@ -13856,10 +13661,8 @@ } } } - } - }, - "/user/{username}/likes/spaces": { - "get": { + }, + "post": { "security": [ { "ApiKey": [] @@ -13872,16 +13675,45 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user likes spaces", + "summary": "Create mirror for a existing repository", "parameters": [ + { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "models,datasets,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, { "type": "string", - "description": "username", - "name": "username", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true + }, + { + "description": "body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateMirrorParams" + } } ], "responses": { @@ -13890,19 +13722,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/database.Mirror" } } } @@ -13922,10 +13748,8 @@ } } } - } - }, - "/user/{username}/likes/{repoid}": { - "put": { + }, + "delete": { "security": [ { "ApiKey": [] @@ -13938,21 +13762,34 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Add user likes", + "summary": "Delete a mirror", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,datasets,codes or spaces", + "name": "repo_type", "in": "path", "required": true }, { "type": "string", - "description": "repo id", - "name": "repo_id", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true } @@ -13977,14 +13814,15 @@ } } } - }, - "delete": { + } + }, + "/{repo_type}/{namespace}/{name}/mirror/sync": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "Delete user likes", "consumes": [ "application/json" ], @@ -13992,21 +13830,34 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Delete user likes", + "summary": "Triggers the mirror synchronization", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,datasets,codes or spaces", + "name": "repo_type", "in": "path", "required": true }, { "type": "string", - "description": "repo id", - "name": "repo_id", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true } @@ -14033,14 +13884,13 @@ } } }, - "/user/{username}/models": { - "get": { + "/{repo_type}/{namespace}/{name}/mirror_from_saas": { + "post": { "security": [ { "ApiKey": [] } ], - "description": "get user models", "consumes": [ "application/json" ], @@ -14048,14 +13898,34 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user models", + "summary": "Mirror repo from OpenCSG Saas(only on-premises)", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,datasets,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true } @@ -14066,19 +13936,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/types.ResponseWithTotal" + "$ref": "#/definitions/types.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/database.Mirror" } } } @@ -14100,14 +13964,13 @@ } } }, - "/user/{username}/order/resource": { - "post": { + "/{repo_type}/{namespace}/{name}/raw/{file_path}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "create order for user's resource", "consumes": [ "application/json" ], @@ -14115,73 +13978,55 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "create order for user's resource", + "summary": "Get the last commit of repository", "parameters": [ { - "description": "create order request", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateUserResourceReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/order/resources": { - "get": { - "security": [ { - "ApiKey": [] - } - ], - "description": "get user's resource", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "get user's resource", - "parameters": [ + "type": "string", + "description": "repo name", + "name": "name", + "in": "path", + "required": true + }, { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" + "type": "string", + "description": "file path", + "name": "file_path", + "in": "path", + "required": true }, { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", "in": "query" } ], @@ -14197,13 +14042,7 @@ "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.UserResourcesResp" - } - }, - "total": { - "type": "integer" + "type": "string" } } } @@ -14223,16 +14062,13 @@ } } } - } - }, - "/user/{username}/order/resources/{id}": { - "delete": { + }, + "put": { "security": [ { "ApiKey": [] } ], - "description": "delete user's resource by order detail id", "consumes": [ "application/json" ], @@ -14240,77 +14076,77 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "delete user's resource by order detail id", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } + "summary": "Update existing file in repository", + "parameters": [ + { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], + "type": "string", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/prompts": { - "get": { - "security": [ { - "ApiKey": [] - } - ], - "description": "get user prompts", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "Get user prompts", - "parameters": [ + "type": "string", + "description": "repo name", + "name": "name", + "in": "path", + "required": true + }, { "type": "string", - "description": "username", - "name": "username", + "description": "the new file relative path", + "name": "file_path", "in": "path", "required": true }, { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", + "type": "string", + "description": "current user name", + "name": "current_user", "in": "query" }, { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" + "description": "create file request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.UpdateFileReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.UpdateFileResp" + } + } + } + ] } }, "400": { @@ -14326,16 +14162,13 @@ } } } - } - }, - "/user/{username}/run/serverless": { - "get": { + }, + "post": { "security": [ { "ApiKey": [] } ], - "description": "Get serverless deploys", "consumes": [ "application/json" ], @@ -14343,43 +14176,77 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get serverless deploys", + "summary": "Create a new file in repository", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,dataset,codes or spaces", + "name": "repo_type", "in": "path", "required": true }, { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true }, { - "type": "integer", - "default": 1, - "description": "page index", - "name": "page", - "in": "query" + "type": "string", + "description": "repo name", + "name": "name", + "in": "path", + "required": true }, { "type": "string", - "description": "current user", + "description": "the new file relative path", + "name": "file_path", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current user name", "name": "current_user", "in": "query" + }, + { + "description": "create file request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.CreateFileReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.CreateFileResp" + } + } + } + ] } }, "400": { @@ -14397,14 +14264,13 @@ } } }, - "/user/{username}/run/{repo_type}": { + "/{repo_type}/{namespace}/{name}/refs/{ref}/logs_tree/{path}": { "get": { "security": [ { "ApiKey": [] } ], - "description": "Get user running deploys", "consumes": [ "application/json" ], @@ -14412,58 +14278,59 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user running deploys", + "summary": "Get last commit for file tree", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,dataset,codes or spaces", + "name": "repo_type", "in": "path", "required": true }, { - "enum": [ - "model", - "space" - ], "type": "string", - "description": "model,space", - "name": "repo_type", + "description": "repo owner name", + "name": "namespace", "in": "path", "required": true }, { - "enum": [ - 0, - 1, - 2 - ], - "type": "integer", - "default": 1, - "description": "deploy type(0-space,1-inference,2-finetune)", - "name": "deploy_type", - "in": "query" + "type": "string", + "description": "repo name", + "name": "name", + "in": "path", + "required": true }, { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" + "type": "string", + "description": "dir to list", + "name": "path", + "in": "path" + }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "path" }, { "type": "integer", - "default": 1, - "description": "page index", - "name": "page", + "description": "limit of records return", + "name": "limit", "in": "query" }, { - "type": "string", - "description": "current user", - "name": "current_user", + "type": "integer", + "description": "pagination offset", + "name": "offset", "in": "query" } ], @@ -14471,7 +14338,19 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/types.LogsTreeResp" + } + } + } + ] } }, "400": { @@ -14489,7 +14368,7 @@ } } }, - "/user/{username}/spaces": { + "/{repo_type}/{namespace}/{name}/refs/{ref}/tree/{path}": { "get": { "security": [ { @@ -14503,16 +14382,60 @@ "application/json" ], "tags": [ - "User" + "Repository" ], - "summary": "Get user spaces", + "summary": "Get file tree", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,dataset,codes or spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "dir to list", + "name": "path", + "in": "path" + }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "path" + }, + { + "type": "integer", + "description": "limit of records return", + "name": "limit", + "in": "query" + }, + { + "type": "string", + "description": "pagination cursor", + "name": "cursor", + "in": "query" } ], "responses": { @@ -14527,13 +14450,7 @@ "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" + "$ref": "#/definitions/types.GetRepoFileTreeResp" } } } @@ -14555,14 +14472,13 @@ } } }, - "/user/{username}/ssh_key/{name}": { - "delete": { + "/{repo_type}/{namespace}/{name}/resolve/{file_path}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "delete specific SSH key for the given user", "consumes": [ "application/json" ], @@ -14570,30 +14486,75 @@ "application/json" ], "tags": [ - "SSH Key" + "Repository" ], - "summary": "Delete specific SSH key for the given user", + "summary": "Download a rep file", "parameters": [ { + "enum": [ + "models", + "datasets", + "codes", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,dataset,codes or spaces", + "name": "repo_type", "in": "path", "required": true }, { "type": "string", - "description": "key name", + "description": "repo owner name", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "repo name", "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "file path", + "name": "file_path", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "branch or tag", + "name": "ref", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "current user name", + "name": "current_user", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "allOf": [ + { + "$ref": "#/definitions/types.ResponseWithTotal" + }, + { + "type": "object", + "properties": { + "data": { + "type": "string" + } + } + } + ] } }, "400": { @@ -14611,14 +14572,14 @@ } } }, - "/user/{username}/ssh_keys": { + "/{repo_type}/{namespace}/{name}/run": { "get": { "security": [ { "ApiKey": [] } ], - "description": "get all SSH keys for the given user", + "description": "List repo deploys", "consumes": [ "application/json" ], @@ -14626,41 +14587,47 @@ "application/json" ], "tags": [ - "SSH Key" + "Repository" ], - "summary": "Get all SSH keys for the given user", + "summary": "List repo deploys", "parameters": [ { + "enum": [ + "models", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,spaces", + "name": "repo_type", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "current user", + "name": "current_user", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.SSHKey" - } - }, - "total": { - "type": "integer" - } - } - } - ] + "type": "string" } }, "400": { @@ -14676,14 +14643,16 @@ } } } - }, - "post": { + } + }, + "/{repo_type}/{namespace}/{name}/run/{id}": { + "get": { "security": [ { "ApiKey": [] } ], - "description": "create a new SSH key for the given user", + "description": "Get repo deploy detail", "consumes": [ "application/json" ], @@ -14691,100 +14660,46 @@ "application/json" ], "tags": [ - "SSH Key" + "Repository" ], - "summary": "Create a new SSH key for the given user", + "summary": "Get repo deploy detail", "parameters": [ { - "type": "string", - "description": "username", - "name": "username", + "enum": [ + "models", + "spaces" + ], + "type": "string", + "description": "models,spaces", + "name": "repo_type", "in": "path", "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSSHKeyRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.SSHKey" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + "type": "string", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/tokens": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Access token" - ], - "summary": "Get all access tokens for a user", - "parameters": [ { "type": "string", - "description": "username", - "name": "username", + "description": "name", + "name": "name", "in": "path", "required": true }, { "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" + "description": "id", + "name": "id", + "in": "path", + "required": true }, { - "enum": [ - "git", - "starship" - ], "type": "string", - "description": "application", - "name": "app", + "description": "current user", + "name": "current_user", "in": "query" } ], @@ -14792,7 +14707,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/types.Response" + "type": "string" } }, "400": { @@ -14801,6 +14716,12 @@ "$ref": "#/definitions/types.APIBadRequest" } }, + "401": { + "description": "Permission denied", + "schema": { + "$ref": "#/definitions/types.APIUnauthorized" + } + }, "500": { "description": "Internal server error", "schema": { @@ -14809,13 +14730,12 @@ } } }, - "post": { + "put": { "security": [ { "ApiKey": [] } ], - "description": "create access token for a user", "consumes": [ "application/json" ], @@ -14823,31 +14743,55 @@ "application/json" ], "tags": [ - "Access token" + "Repository" ], - "summary": "[Deprecated: use POST:/token/{app}/{username} instead]", + "summary": "Update deploy parameters", "parameters": [ { + "enum": [ + "models" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models", + "name": "repo_type", "in": "path", "required": true }, { "type": "string", - "description": "current user, the owner", + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "deploy id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current_user", "name": "current_user", "in": "query", "required": true }, { - "description": "body", + "description": "deploy setting of inference", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/types.CreateUserTokenRequest" + "$ref": "#/definitions/types.DeployUpdateReq" } } ], @@ -14855,19 +14799,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.AccessToken" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -14885,7 +14817,7 @@ } } }, - "/user/{username}/tokens/first": { + "/{repo_type}/{namespace}/{name}/run/{id}/logs/{instance}": { "get": { "security": [ { @@ -14899,53 +14831,70 @@ "application/json" ], "tags": [ - "Access token" + "Repository" ], - "summary": "Get or create first available access token for a user", + "summary": "get deploy instance logs", "parameters": [ { + "enum": [ + "models", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,spaces", + "name": "repo_type", "in": "path", "required": true }, { "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" + "description": "namespace", + "name": "namespace", + "in": "path", + "required": true }, { - "enum": [ - "git", - "starship" - ], "type": "string", - "description": "application", - "name": "app", - "in": "query" + "description": "name", + "name": "name", + "in": "path", + "required": true }, { "type": "string", - "description": "token name", - "name": "token_name", - "in": "query" + "description": "id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "instance", + "name": "instance", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "current_user", + "name": "current_user", + "in": "query", + "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/types.APIBadRequest" } }, + "401": { + "description": "Permission denied", + "schema": { + "$ref": "#/definitions/types.APIUnauthorized" + } + }, "500": { "description": "Internal server error", "schema": { @@ -14955,11 +14904,11 @@ } } }, - "/user/{username}/tokens/{token_name}": { - "delete": { + "/{repo_type}/{namespace}/{name}/run/{id}/status": { + "get": { "security": [ { - "ApiKey": [] + "JWT token": [] } ], "consumes": [ @@ -14969,120 +14918,63 @@ "application/json" ], "tags": [ - "Access token" + "Repository" ], - "summary": "[Deprecated: use DELETE:/token/{app}/{token_name} instead]", + "summary": "get deploy status", "parameters": [ { + "enum": [ + "models", + "spaces" + ], "type": "string", - "description": "username", - "name": "username", + "description": "models,spaces", + "name": "repo_type", "in": "path", "required": true }, { "type": "string", - "description": "token_name", - "name": "token_name", + "description": "namespace", + "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", + "description": "name", + "name": "name", + "in": "path", "required": true }, { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.DeleteUserTokenRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } + "type": "string", + "description": "deploy id", + "name": "id", + "in": "path", + "required": true }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/users": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "Get users info. Only Admin", - "parameters": [ { "type": "string", - "description": "search", - "name": "search", + "description": "current_user", + "name": "current_user", "in": "query", "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.User" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/types.APIBadRequest" } }, + "401": { + "description": "Permission denied", + "schema": { + "$ref": "#/definitions/types.APIUnauthorized" + } + }, "500": { "description": "Internal server error", "schema": { @@ -15092,13 +14984,14 @@ } } }, - "/{repo_type}/{namespace}/{name}/blob/{file_path}": { + "/{repo_type}/{namespace}/{name}/runtime_framework": { "get": { "security": [ { - "ApiKey or JWT": [] + "ApiKey": [] } ], + "description": "List repo runtime framework", "consumes": [ "application/json" ], @@ -15106,55 +14999,52 @@ "application/json" ], "tags": [ - "Repository" + "RuntimeFramework" ], - "summary": "Get the repo file information like size, content, sha etc", + "summary": "List repo runtime framework", "parameters": [ { "enum": [ "models", - "datasets", - "codes", "spaces" ], "type": "string", - "description": "models,dataset,codes or spaces", + "description": "models,spaces", "name": "repo_type", "in": "path", "required": true }, { "type": "string", - "description": "repo owner name", + "description": "namespace", "name": "namespace", "in": "path", "required": true }, { "type": "string", - "description": "repo name", + "description": "name", "name": "name", "in": "path", "required": true }, { "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true + "description": "current user", + "name": "current_user", + "in": "query" }, { - "type": "string", - "description": "current user name", - "name": "current_user", + "enum": [ + 0, + 1, + 2, + 4 + ], + "type": "integer", + "default": 1, + "description": "deploy_type", + "name": "deploy_type", "in": "query" } ], @@ -15162,19 +15052,7 @@ "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.File" - } - } - } - ] + "type": "string" } }, "400": { @@ -15192,7 +15070,7 @@ } } }, - "/{repo_type}/{namespace}/{name}/branches": { + "/{repo_type}/{namespace}/{name}/tags": { "get": { "security": [ { @@ -15208,7 +15086,7 @@ "tags": [ "Repository" ], - "summary": "Get the branches of repository", + "summary": "Get the tags of repository", "parameters": [ { "enum": [ @@ -15237,13 +15115,6 @@ "in": "path", "required": true }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, { "type": "string", "description": "current user name", @@ -15265,7 +15136,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/types.Branch" + "$ref": "#/definitions/database.Tag" } } } @@ -15288,8 +15159,8 @@ } } }, - "/{repo_type}/{namespace}/{name}/commit/{commit_id}": { - "get": { + "/{repo_type}/{namespace}/{name}/tags/{category}": { + "post": { "security": [ { "ApiKey": [] @@ -15304,7 +15175,7 @@ "tags": [ "Repository" ], - "summary": "Get commit diff of repository and data field of response need to be decode with base64", + "summary": "update the tags of a certain category", "parameters": [ { "enum": [ @@ -15314,7 +15185,7 @@ "spaces" ], "type": "string", - "description": "models,datasets,codes or spaces", + "description": "models,dataset,codes or spaces", "name": "repo_type", "in": "path", "required": true @@ -15335,35 +15206,43 @@ }, { "type": "string", - "description": "commit id", - "name": "commit_id", - "in": "path", + "description": "current user name", + "name": "current_user", + "in": "query", "required": true }, { + "enum": [ + "task", + "license", + "framework", + "language", + "industry" + ], "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" + "description": "tag category", + "name": "category", + "in": "path", + "required": true + }, + { + "description": "tag names in array", + "name": "tags", + "in": "body", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } } ], "responses": { "200": { "description": "OK", "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CommitResponse" - } - } - } - ] + "$ref": "#/definitions/types.Response" } }, "400": { @@ -15381,7 +15260,7 @@ } } }, - "/{repo_type}/{namespace}/{name}/commits": { + "/{repo_type}/{namespace}/{name}/tree": { "get": { "security": [ { @@ -15397,7 +15276,7 @@ "tags": [ "Repository" ], - "summary": "Get all commits of repository", + "summary": "Get repository file tree", "parameters": [ { "enum": [ @@ -15428,29 +15307,14 @@ }, { "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", + "description": "root dir", + "name": "path", "in": "query" }, { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", + "type": "string", + "description": "branch or tag", + "name": "ref", "in": "query" } ], @@ -15468,7 +15332,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/types.Commit" + "$ref": "#/definitions/types.File" } } } @@ -15490,19574 +15354,3729 @@ } } } + } + }, + "definitions": { + "database.AccessToken": { + "type": "object", + "properties": { + "application": { + "description": "example: csghub, starship", + "allOf": [ + { + "$ref": "#/definitions/types.AccessTokenApp" + } + ] + }, + "created_at": { + "type": "string" + }, + "expired_at": { + "type": "string" + }, + "git_id": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "is_active": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "permission": { + "type": "string" + }, + "token": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/database.User" + }, + "user_id": { + "type": "integer" + } + } }, - "/{repo_type}/{namespace}/{name}/discussions": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "list repo discussions", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Discussion" - ], - "summary": "List repo discussions", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "repository type", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.ListRepoDiscussionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new repo discussion", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Discussion" - ], - "summary": "Create a new repo discussion", - "parameters": [ - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "repository type", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateRepoDiscussionRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CreateDiscussionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/download/{file_path}": { - "get": { - "security": [ - { - "ApiKey or JWT": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Download a repo file [Depricated: use 'resolve' api instead]", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query" - }, - { - "type": "string", - "description": "file name to save as", - "name": "save_as", - "in": "query" - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "object" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/incr_downloads": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Increase repo download count by 1", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/last_commit": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get the last commit of repository", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Commit" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/mirror": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get a mirror", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Update a mirror for a existing repository", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateMirrorParams" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Create mirror for a existing repository", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateMirrorParams" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Delete a mirror", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/mirror/progress": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get Mirror sync progress", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.LFSSyncProgressResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/mirror/sync": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Triggers the mirror synchronization", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/mirror_from_saas": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Mirror repo from OpenCSG Saas(only on-premises)", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/raw/{file_path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get the last commit of repository", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Update existing file in repository", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the new file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - }, - { - "description": "create file request", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.UpdateFileResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Create a new file in repository", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the new file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - }, - { - "description": "create file request", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CreateFileResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/refs/{ref}/logs_tree/{path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get last commit for file tree", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "dir to list", - "name": "path", - "in": "path" - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "path" - }, - { - "type": "integer", - "description": "limit of records return", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "pagination offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.LogsTreeResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/refs/{ref}/tree/{path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get file tree", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "dir to list", - "name": "path", - "in": "path" - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "path" - }, - { - "type": "integer", - "description": "limit of records return", - "name": "limit", - "in": "query" - }, - { - "type": "string", - "description": "pagination cursor", - "name": "cursor", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.GetRepoFileTreeResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/resolve/{file_path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Download a rep file", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "List repo deploys", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "List repo deploys", - "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get repo deploy detail", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get repo deploy detail", - "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "401": { - "description": "Permission denied", - "schema": { - "$ref": "#/definitions/types.APIUnauthorized" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Update deploy parameters", - "parameters": [ - { - "enum": [ - "models" - ], - "type": "string", - "description": "models", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "deploy setting of inference", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.DeployUpdateReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run/{id}/logs/{instance}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "get deploy instance logs", - "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "instance", - "name": "instance", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "401": { - "description": "Permission denied", - "schema": { - "$ref": "#/definitions/types.APIUnauthorized" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run/{id}/status": { - "get": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "get deploy status", - "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "401": { - "description": "Permission denied", - "schema": { - "$ref": "#/definitions/types.APIUnauthorized" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/runtime_framework": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "List repo runtime framework", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "RuntimeFramework" - ], - "summary": "List repo runtime framework", - "parameters": [ - { - "enum": [ - "models", - "spaces" - ], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "enum": [ - 0, - 1, - 2, - 4 - ], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/tags": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get the tags of repository", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Tag" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/tags/{category}": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "update the tags of a certain category", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "enum": [ - "task", - "license", - "framework", - "language", - "industry" - ], - "type": "string", - "description": "tag category", - "name": "category", - "in": "path", - "required": true - }, - { - "description": "tag names in array", - "name": "tags", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/tree": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Repository" - ], - "summary": "Get repository file tree", - "parameters": [ - { - "enum": [ - "models", - "datasets", - "codes", - "spaces" - ], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "root dir", - "name": "path", - "in": "query" - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.File" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - } - } - }, - "/cluster": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get cluster list", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Cluster"], - "summary": "Get cluster list", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/cluster/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get cluster by id", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Cluster"], - "summary": "Get cluster by id", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/codes": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get visiable codes for current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Code"], - "summary": "Get Visiable codes for current user", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "filter by task tag", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag", - "name": "language_tag", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "enum": ["opencsg", "huggingface", "local"], - "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new code", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Code"], - "summary": "Create a new code", - "parameters": [ - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCodeReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Code" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/codes/{namespace}/{name}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get code detail", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Code"], - "summary": "Get code detail", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Code" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a exists code", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Code"], - "summary": "Update a exists code", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCodeReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Code" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exists code", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Code"], - "summary": "Delete a exists code", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/codes/{namespace}/{name}/relations": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Code"], - "summary": "Get code related assets", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Relations" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/collections": { - "get": { - "description": "get all collections", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Collection"], - "summary": "get all collections", - "parameters": [ - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "default": "\"trending\"", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Collection" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "JWT token": [] - } - ], - "description": "create a collection", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Collection"], - "summary": "create a collection", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCollectionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Collection" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/collections/{id}": { - "get": { - "description": "get a collection detail", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Collection"], - "summary": "get a collection detail", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Collection" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "JWT token": [] - } - ], - "description": "update a collection", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Collection"], - "summary": "update a collection", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCollectionReq" - } - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Collection" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "JWT token": [] - } - ], - "description": "delete a exists collection", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Collection"], - "summary": "Delete a exists collection", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/collections/{id}/repos": { - "post": { - "security": [ - { - "JWT token": [] - } - ], - "description": "Add repos to a collection", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Collection"], - "summary": "Add repos to a collection", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCollectionReposReq" - } - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Collection" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "JWT token": [] - } - ], - "description": "remove repos from a collection", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Collection"], - "summary": "remove repos from a collection", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCollectionReposReq" - } - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Collection" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/comments/{id}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a comment content by id", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "Update a comment content by id", - "parameters": [ - { - "type": "string", - "description": "the comment id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner of the comment", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCommentRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a comment by id", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "Delete a comment by id", - "parameters": [ - { - "type": "string", - "description": "the comment id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner of the comment", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/datasets": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get visiable datasets for current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Dataset"], - "summary": "Get Visiable datasets for current user", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "filter by task tag", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag", - "name": "language_tag", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "enum": ["opencsg", "huggingface", "local"], - "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new dataset", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Dataset"], - "summary": "Create a new dataset", - "parameters": [ - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateDatasetReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Dataset" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/datasets/{namespace}/{name}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get dataset detail", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Dataset"], - "summary": "Get dataset detail", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Dataset" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a exists dataset", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Dataset"], - "summary": "Update a exists dataset", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateDatasetReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Dataset" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exists dataset", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Dataset"], - "summary": "Delete a exists dataset", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/datasets/{namespace}/{name}/all_files": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Dataset"], - "summary": "Get all files of a dataset", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.File" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/datasets/{namespace}/{name}/relations": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Dataset"], - "summary": "Get dataset related assets", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Relations" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/discussions/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "show a discussion", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "Show a discussion and its comments", - "parameters": [ - { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.ShowDiscussionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a discussion", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "Update a discussion", - "parameters": [ - { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateDiscussionRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a discussion", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "Delete a discussion", - "parameters": [ - { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner of the discussion", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/discussions/{id}/comments": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "list discussion comments", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "List discussion comments", - "parameters": [ - { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.DiscussionResponse_Comment" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new discussion comment", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "Create a new discussion comment", - "parameters": [ - { - "type": "string", - "description": "the discussion id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCommentRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CreateCommentResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/evaluations": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Evaluation"], - "summary": "run model evaluation", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "description": "body setting of evaluation", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.EvaluationReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/evaluations/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Evaluation"], - "summary": "get model evaluation", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.EvaluationRes" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Evaluation"], - "summary": "delete model evaluation", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/events": { - "post": { - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Events"], - "summary": "Report client events", - "parameters": [ - { - "description": "Events", - "name": "events", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Event" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/jwt/token": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["JWT"], - "summary": "generate jwt token for user", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateJWTReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.CreateJWTResp" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/jwt/{token}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["JWT"], - "summary": "verify jwt token and return user info", - "parameters": [ - { - "type": "string", - "description": "token", - "name": "token", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.User" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/list/datasets_by_path": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "list datasets by paths", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["List"], - "summary": "List datasets by paths", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ListByPathReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.DatasetResp" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/list/models_by_path": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "list models by paths", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["List"], - "summary": "List models by paths", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ListByPathReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.ModelResp" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/list/spaces_by_path": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["List"], - "summary": "List spaces by paths", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ListByPathReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/mirror/repo": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Create mirror repo", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateMirrorRepoReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/mirror/repos": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Get mirror repos", - "parameters": [ - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.MirrorRepo" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/mirror/sources": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Get mirror sources", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.MirrorSource" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Create mirror source", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateMirrorSourceReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.MirrorSource" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/mirror/sources/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Get mirror source", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.MirrorSource" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Update mirror source", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateMirrorSourceReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.MirrorSource" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Delete mirror source", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/mirrors": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Mirror"], - "summary": "Get mirrors", - "parameters": [ - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Mirror" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get visiable models for current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Get Visiable models for current user", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "filter by task tag, deprecated", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag, deprecated", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag, deprecated", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag, deprecated", - "name": "language_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by tag category", - "name": "tag_category", - "in": "query" - }, - { - "type": "string", - "description": "filter by tag name", - "name": "tag_name", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "enum": ["opencsg", "huggingface", "local"], - "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new model", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Create a new model", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateModelReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Model" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/runtime_framework": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "List repo runtime framework", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "List repo runtime framework", - "parameters": [ - { - "enum": ["models"], - "type": "string", - "description": "models", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "enum": [0, 1, 2], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get model detail", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Get model detail", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Model" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a exists model", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Update a exists model", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the model owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateModelReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Model" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exists model", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Delete a exists model", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the model owner", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/all_files": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Get all files of a model", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.File" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/finetune": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "create a finetune instance", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "deploy setting of instance", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.InstanceRunReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/finetune/{id}": { - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a finetune instance", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Delete a finetune instance", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/finetune/{id}/start": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Start a finetune instance", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Start a finetune instance", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/finetune/{id}/stop": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Stop a finetune instance", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Stop a finetune instance", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/relations": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Get model related assets", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Relations" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Set dataset relation for model", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "set dataset relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationDatasets" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Relations" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/relations/dataset": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "add dataset relation for model", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "add dataset relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationDataset" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "delete dataset relation for model", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "delelet dataset relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationDataset" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/run": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "run model as inference", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "deploy setting of inference", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ModelRunReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/run/{id}": { - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a model inference", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Delete a model inference", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/run/{id}/start": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Start a model inference", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Start a model inference", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/run/{id}/stop": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Stop a model inference", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Stop a model inference", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/serverless": { - "get": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "get model serverless", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "run model as serverless service", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "deploy setting of serverless", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.ModelRunReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/serverless/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get repo serverless detail", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Get repo serverless detail", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Update serverless parameters", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "deploy setting of Serverless", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.DeployUpdateReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/serverless/{id}/logs/{instance}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "get serverless logs", - "parameters": [ - { - "enum": ["models"], - "type": "string", - "description": "models", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "instance", - "name": "instance", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/serverless/{id}/start": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Start a model serverless", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Start a model serverless", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/serverless/{id}/status": { - "get": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "get serverless status", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/models/{namespace}/{name}/serverless/{id}/stop": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Stop a model serverless", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Model"], - "summary": "Stop a model serverless", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/namespace/{path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get namespace info", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Namespace", "InternalOnly"], - "summary": "Get namespace info [Internal Only].", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "path", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Namespace" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organization info", - "parameters": [ - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Organization" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update organization", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Update organization", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.EditOrgReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Organization" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete organization", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Delete organization", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.DeleteOrgReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/codes": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organization codes", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/collections": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organization Collections", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Collection" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/datasets": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get organization datasets", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organization datasets", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/members": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Member"], - "summary": "Get organization members. Org member can get more details.", - "parameters": [ - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - " total": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/types.Member" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "user will be added to org with a role", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Member"], - "summary": "Create new membership between org and user", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.Create.addMemberRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/members/{username}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Member"], - "summary": "Get user's role in an org", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "user name", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Member"], - "summary": "update user membership", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "user name", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.Update.updateMemberRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "user's role will be remove from org", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Member"], - "summary": "Remove membership between org and user", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "user name", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.Delete.removeMemberRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/models": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get organization models", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organization models", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/prompts": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get organization prompts", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organization prompts", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.PromptRes" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organization/{namespace}/spaces": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organization Spaces", - "parameters": [ - { - "type": "string", - "description": "org name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page size", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "description": "current page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/organizations": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get organizations", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Get organizations", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Organization" - } - } - } - } - ] - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new organization", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Organization"], - "summary": "Create a new organization", - "parameters": [ - { - "type": "string", - "description": "the op user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateOrgReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Organization" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get visiable Prompt repos for current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Get Visiable Prompt repos for current user", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "filter by task tag", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag", - "name": "language_tag", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "enum": ["opencsg", "huggingface", "local"], - "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.PromptRes" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new prompt repo", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Create a new prompt repo", - "parameters": [ - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreatePromptRepoReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "List prompts", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "List prompts", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a exists prompt repo", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Update a exists prompt repo", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdatePromptRepoReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exists prompt repo", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Delete a exists prompt repo", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/branches": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Get the branches of prompt repository", - "parameters": [ - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Branch" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/prompt/file": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Create prompt in repo", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Create prompt in repo", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/prompt/file/{file_path}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Update prompt in repo", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Update prompt in repo", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Delete prompt in repo", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Delete prompt in repo", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/prompt/view/{file_path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get prompts by file", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Get prompts by file", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/relations": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Get prompt related assets", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Relations" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Set model relation for prompt", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "set model relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationModels" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/relations/model": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "add model relation for prompt", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "add model relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationModel" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "delete model relation for prompt", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "delelet model relation", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RelationModel" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/tags": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "Get the tags of prompt repository", - "parameters": [ - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Tag" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/prompts/{namespace}/{name}/tags/{category}": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Prompt"], - "summary": "update the tags of a certain category", - "parameters": [ - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "enum": ["task", "license", "framework", "language", "industry"], - "type": "string", - "description": "tag category", - "name": "category", - "in": "path", - "required": true - }, - { - "description": "tag names in array", - "name": "tags", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/recom/opweight": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Recommendation"], - "summary": "set op weight for repo recommendation", - "parameters": [ - { - "description": "json request body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handler.SetOpWeight.SetOpWeightReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/runtime_framework": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get all runtime frameworks for current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Get all runtime frameworks for current user", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create runtime framework", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Create runtime framework", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.RuntimeFramework" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/types.APIForbidden" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/runtime_framework/models": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get visible models for all runtime frameworks for current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Get Visible models for all runtime frameworks for current user", - "parameters": [ - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - }, - { - "enum": [1, 2], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/runtime_framework/{id}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "set model runtime frameworks", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Set model runtime frameworks", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "enum": [0, 1, 2], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkModels" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/types.APIForbidden" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "set model runtime frameworks", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Set model runtime frameworks", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "enum": [0, 1, 2], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkModels" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/types.APIForbidden" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/runtime_framework/{id}/architecture": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get runtime framework architectures", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Get runtime framework architectures", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "set runtime framework architectures", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Set runtime framework architectures", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeArchitecture" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Delete runtime framework architectures", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Delete runtime framework architectures", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeArchitecture" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/runtime_framework/{id}/models": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get visible models by runtime framework for current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Get Visible models by runtime framework for current user", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - }, - { - "enum": [0, 1, 2], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/runtime_framework/{id}/scan": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Scan runtime architecture", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["RuntimeFramework"], - "summary": "Scan runtime architecture", - "parameters": [ - { - "type": "integer", - "description": "runtime framework id", - "name": "id", - "in": "path", - "required": true - }, - { - "enum": [0, 1, 2], - "type": "integer", - "description": "scan_type(0:all models, 1:new models, 2:old models)", - "name": "scan_type", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkModels" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/space_resources": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get space resources", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceReource"], - "summary": "Get space resources", - "parameters": [ - { - "type": "string", - "description": "cluster_id", - "name": "cluster_id", - "in": "query" - }, - { - "enum": [0, 1, 2], - "type": "integer", - "default": 1, - "description": "deploy type(0-space,1-inference,2-finetune)", - "name": "deploy_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.SpaceResource" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create space resource", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceReource"], - "summary": "Create space resource", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSpaceResourceReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SpaceResource" - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/space_resources/{id}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a exist space resource", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceReource"], - "summary": "Update a exist space resource", - "parameters": [ - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateSpaceResourceReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SpaceResource" - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exist space resource", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceReource"], - "summary": "Delete a exist space resource", - "parameters": [ - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/space_sdks": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get space sdks", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceSdk"], - "summary": "Get space sdks", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.SpaceSdk" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create space sdk", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceSdk"], - "summary": "Create space sdk", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSpaceSdkReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SpaceSdk" - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/space_sdks/{id}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a exist space sdk", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceSdk"], - "summary": "Update a exist space sdk", - "parameters": [ - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateSpaceSdkReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SpaceSdk" - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exist space sdk", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SpaceSdk"], - "summary": "Delete a exist space sdk", - "parameters": [ - { - "type": "integer", - "description": "id", - "name": "写id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/spaces": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get spaces visible to current user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "Get spaces visible to current user", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "type": "string", - "description": "search text", - "name": "search", - "in": "query" - }, - { - "type": "string", - "description": "filter by task tag", - "name": "task_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by framework tag", - "name": "framework_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by license tag", - "name": "license_tag", - "in": "query" - }, - { - "type": "string", - "description": "filter by language tag", - "name": "language_tag", - "in": "query" - }, - { - "type": "string", - "description": "sort by", - "name": "sort", - "in": "query" - }, - { - "enum": ["opencsg", "huggingface", "local"], - "type": "string", - "description": "source", - "name": "source", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new space", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "Create a new space", - "parameters": [ - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSpaceReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Space" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/spaces/{namespace}/{name}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "show space detail", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Space" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update a exists space", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "Update a exists space", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateSpaceReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Space" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exists space", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "Delete a exists space", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/spaces/{namespace}/{name}/logs": { - "get": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "get space logs", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/spaces/{namespace}/{name}/run": { - "post": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "run space app", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/spaces/{namespace}/{name}/status": { - "get": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "get space status", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/spaces/{namespace}/{name}/stop": { - "post": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "stop space app", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/spaces/{namespace}/{name}/wakeup": { - "post": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Space"], - "summary": "wake up space app", - "parameters": [ - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/sync/client_setting": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get sync client setting", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Sync"], - "summary": "Get sync client setting", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.SyncClientSetting" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Create sync client setting or update an existing sync client setting", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Sync"], - "summary": "Create sync client setting or update an existing sync client setting", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSyncClientSettingReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.SyncClientSetting" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/sync/version/latest": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "produces": ["application/json"], - "tags": ["Sync"], - "summary": "Get latest version", - "parameters": [ - { - "type": "string", - "description": "current version", - "name": "cur", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.SyncVersionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/tags": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get all tags", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Get all tags", - "parameters": [ - { - "type": "string", - "description": "category name", - "name": "category", - "in": "query" - }, - { - "enum": ["model", "dataset"], - "type": "string", - "description": "scope name", - "name": "scope", - "in": "query" - } - ], - "responses": { - "200": { - "description": "tags", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Tag" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Create new tag", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Create new tag", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateTag" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/tags/categories": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get all Categories", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Get all Categories", - "responses": { - "200": { - "description": "categores", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.TagCategory" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Create new category", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Create new category", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateCategory" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/tags/categories/id": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Create new category", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Create new category", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateCategory" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Delete a category by id", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Delete a category by id", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/tags/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get a tag by id", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Get a tag by id", - "parameters": [ - { - "type": "string", - "description": "id of the tag", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Update a tag by id", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Update a tag by id", - "parameters": [ - { - "type": "string", - "description": "id of the tag", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateTag" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Delete a tag by id", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Tag"], - "summary": "Delete a tag by id", - "parameters": [ - { - "type": "string", - "description": "id of the tag", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/telemetry/usage": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Telemetry"], - "summary": "Submit telemetry data for a client", - "parameters": [ - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/telemetry.Usage" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/token/{app}/{token_name}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Access token"], - "summary": "Refresh a access token for a user", - "parameters": [ - { - "enum": ["git", "starship"], - "type": "string", - "description": "application", - "name": "app", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "token_name", - "name": "token_name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "new expire time, in format RFC3339, like 2006-01-02T15:04:05Z07:00", - "name": "expired_at", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Access token"], - "summary": "Create access token for an special application", - "parameters": [ - { - "type": "string", - "description": "token name", - "name": "token_name", - "in": "path", - "required": true - }, - { - "enum": ["git", "starship"], - "type": "string", - "description": "application", - "name": "app", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateUserTokenRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.AccessToken" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Access token"], - "summary": "Delete access token of a app", - "parameters": [ - { - "enum": ["git", "starship"], - "type": "string", - "description": "application", - "name": "app", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "token_name", - "name": "token_name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/token/{token_value}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Access token"], - "summary": "Get token and owner's detail by the token value", - "parameters": [ - { - "type": "string", - "description": "token_value", - "name": "token_value", - "in": "path", - "required": true - }, - { - "enum": ["git", "starship"], - "type": "string", - "description": "application", - "name": "app", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user info. Admin and the user self can see full info, other users can only see basic info.", - "parameters": [ - { - "type": "string", - "description": "username or uuid, defined by the query string 'type'", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "enum": ["username", "uuid"], - "type": "string", - "description": "path param is usernam or uuid, default to username", - "name": "type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.User" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "update user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Update user. If change user name, should only send 'new_username' in the request body.", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateUserRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Delete user", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateUserRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/codes": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user codes", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user codes", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/collections": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user's collections", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Collection" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/datasets": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user datasets", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user datasets", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/evaluations": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user evaluations", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user evaluations", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/finetune/instances": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get user running notebook instances", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user running notebook instances", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "page index", - "name": "page", - "in": "query" - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/likes/codes": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user likes codes", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user likes codes", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/likes/collections": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user likes collections", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Collection" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/likes/collections/{id}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Add collection likes", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "collection id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "delete collection likes", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "collection id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/likes/datasets": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user likes datasets", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user likes datasets", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/likes/models": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user likes models", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user likes models", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/likes/spaces": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user likes spaces", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/likes/{repoid}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Add user likes", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo id", - "name": "repo_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Delete user likes", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Delete user likes", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo id", - "name": "repo_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/models": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user models", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user models", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/prompts": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get user prompts", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user prompts", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/run/serverless": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get serverless deploys", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get serverless deploys", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "page index", - "name": "page", - "in": "query" - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/run/{repo_type}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get user running deploys", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user running deploys", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "enum": ["model", "space"], - "type": "string", - "description": "model,space", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "enum": [0, 1, 2], - "type": "integer", - "default": 1, - "description": "deploy type(0-space,1-inference,2-finetune)", - "name": "deploy_type", - "in": "query" - }, - { - "type": "integer", - "default": 50, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "page index", - "name": "page", - "in": "query" - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/spaces": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get user spaces", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/ssh_key/{name}": { - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete specific SSH key for the given user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SSH Key"], - "summary": "Delete specific SSH key for the given user", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "key name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/ssh_keys": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "get all SSH keys for the given user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SSH Key"], - "summary": "Get all SSH keys for the given user", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.SSHKey" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new SSH key for the given user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["SSH Key"], - "summary": "Create a new SSH key for the given user", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateSSHKeyRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.SSHKey" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/tokens": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Access token"], - "summary": "Get all access tokens for a user", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - }, - { - "enum": ["git", "starship"], - "type": "string", - "description": "application", - "name": "app", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create access token for a user", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Access token"], - "summary": "[Deprecated: use POST:/token/{app}/{username} instead]", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateUserTokenRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.AccessToken" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/user/{username}/tokens/{token_name}": { - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Access token"], - "summary": "[Deprecated: use DELETE:/token/{app}/{token_name} instead]", - "parameters": [ - { - "type": "string", - "description": "username", - "name": "username", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "token_name", - "name": "token_name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.DeleteUserTokenRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/users": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["User"], - "summary": "Get users info. Only Admin", - "parameters": [ - { - "type": "string", - "description": "search", - "name": "search", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.User" - } - }, - "total": { - "type": "integer" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/blob/{file_path}": { - "get": { - "security": [ - { - "ApiKey or JWT": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get the repo file information like size, content, sha etc", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.File" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/branches": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get the branches of repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Branch" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/commit/{commit_id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get commit diff of repository and data field of response need to be decode with base64", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "commit id", - "name": "commit_id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CommitResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/commits": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get all commits of repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "per", - "name": "per", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "per page", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Commit" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/discussions": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "list repo discussions", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "List repo discussions", - "parameters": [ - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "repository type", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.ListRepoDiscussionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create a new repo discussion", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Discussion"], - "summary": "Create a new repo discussion", - "parameters": [ - { - "type": "string", - "description": "current user, the owner", - "name": "current_user", - "in": "query", - "required": true - }, - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "repository type", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateRepoDiscussionRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CreateDiscussionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/download/{file_path}": { - "get": { - "security": [ - { - "ApiKey or JWT": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Download a repo file [Depricated: use 'resolve' api instead]", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query" - }, - { - "type": "string", - "description": "file name to save as", - "name": "save_as", - "in": "query" - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "object" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/incr_downloads": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Increase repo download count by 1", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/last_commit": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get the last commit of repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.Commit" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/mirror": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get a mirror", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Update a mirror for a existing repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateMirrorParams" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Create mirror for a existing repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateMirrorParams" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Delete a mirror", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/mirror/sync": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Triggers the mirror synchronization", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/mirror_from_saas": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Mirror repo from OpenCSG Saas(only on-premises)", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,datasets,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/database.Mirror" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/raw/{file_path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get the last commit of repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Update existing file in repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the new file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - }, - { - "description": "create file request", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.UpdateFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.UpdateFileResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Create a new file in repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the new file relative path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - }, - { - "description": "create file request", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.CreateFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.CreateFileResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/refs/{ref}/logs_tree/{path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get last commit for file tree", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "dir to list", - "name": "path", - "in": "path" - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "path" - }, - { - "type": "integer", - "description": "limit of records return", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "pagination offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.LogsTreeResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/refs/{ref}/tree/{path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get file tree", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "dir to list", - "name": "path", - "in": "path" - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "path" - }, - { - "type": "integer", - "description": "limit of records return", - "name": "limit", - "in": "query" - }, - { - "type": "string", - "description": "pagination cursor", - "name": "cursor", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/types.GetRepoFileTreeResp" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/resolve/{file_path}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Download a rep file", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "file path", - "name": "file_path", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "List repo deploys", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "List repo deploys", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run/{id}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Get repo deploy detail", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get repo deploy detail", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "401": { - "description": "Permission denied", - "schema": { - "$ref": "#/definitions/types.APIUnauthorized" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Update deploy parameters", - "parameters": [ - { - "enum": ["models"], - "type": "string", - "description": "models", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - }, - { - "description": "deploy setting of inference", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.DeployUpdateReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run/{id}/logs/{instance}": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "get deploy instance logs", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "instance", - "name": "instance", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "401": { - "description": "Permission denied", - "schema": { - "$ref": "#/definitions/types.APIUnauthorized" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/run/{id}/status": { - "get": { - "security": [ - { - "JWT token": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "get deploy status", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "deploy id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current_user", - "name": "current_user", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "401": { - "description": "Permission denied", - "schema": { - "$ref": "#/definitions/types.APIUnauthorized" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/runtime_framework": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "List repo runtime framework", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "List repo runtime framework", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "enum": [0, 1, 2, 4], - "type": "integer", - "default": 1, - "description": "deploy_type", - "name": "deploy_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "create runtime framework", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Create runtime framework", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.RuntimeFramework" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/runtime_framework/{id}": { - "put": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "Update runtime framework", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Update runtime framework", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - }, - { - "description": "body", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/types.RuntimeFrameworkReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.RuntimeFramework" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "ApiKey": [] - } - ], - "description": "delete a exist RuntimeFramework", - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Delete a exist RuntimeFramework", - "parameters": [ - { - "enum": ["models", "spaces"], - "type": "string", - "description": "models,spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "namespace", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/tags": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get the tags of repository", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Tag" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/tags/{category}": { - "post": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "update the tags of a certain category", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "current user name", - "name": "current_user", - "in": "query", - "required": true - }, - { - "enum": ["task", "license", "framework", "language", "industry"], - "type": "string", - "description": "tag category", - "name": "category", - "in": "path", - "required": true - }, - { - "description": "tag names in array", - "name": "tags", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.Response" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - }, - "/{repo_type}/{namespace}/{name}/tree": { - "get": { - "security": [ - { - "ApiKey": [] - } - ], - "consumes": ["application/json"], - "produces": ["application/json"], - "tags": ["Repository"], - "summary": "Get repository file tree", - "parameters": [ - { - "enum": ["models", "datasets", "codes", "spaces"], - "type": "string", - "description": "models,dataset,codes or spaces", - "name": "repo_type", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo owner name", - "name": "namespace", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "repo name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "root dir", - "name": "path", - "in": "query" - }, - { - "type": "string", - "description": "branch or tag", - "name": "ref", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/types.ResponseWithTotal" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/types.File" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/types.APIBadRequest" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/types.APIInternalServerError" - } - } - } - } - } - }, - "definitions": { - "database.AccessToken": { - "type": "object", - "properties": { - "application": { - "description": "example: csghub, starship", - "allOf": [ - { - "$ref": "#/definitions/types.AccessTokenApp" - } - ] - }, - "created_at": { - "type": "string" - }, - "expired_at": { - "type": "string" - }, - "git_id": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "is_active": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "permission": { - "type": "string" - }, - "token": { - "type": "string" - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/database.User" - }, - "user_id": { - "type": "integer" - } - } - }, - "database.Code": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "last_updated_at": { - "type": "string" - }, - "repository": { - "$ref": "#/definitions/database.Repository" - }, - "repository_id": { - "type": "integer" - }, - "updated_at": { - "type": "string" - } - } - }, - "database.Collection": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "likes": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "namespace": { - "type": "string" - }, - "nickname": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "repositories": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Repository" - } - }, - "theme": { - "type": "string" - }, - "updated_at": { - "type": "string" - }, - "user_id": { - "type": "integer" - }, - "username": { - "type": "string" - } - } - }, - "database.Dataset": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "last_updated_at": { - "type": "string" - }, - "repository": { - "$ref": "#/definitions/database.Repository" - }, - "repository_id": { - "type": "integer" - }, - "updated_at": { - "type": "string" - } - } - }, - "database.Mirror": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "interval": { - "type": "string" - }, - "last_message": { - "type": "string" - }, - "last_updated_at": { - "type": "string" - }, - "local_repo_path": { - "type": "string" - }, - "mirror_source": { - "$ref": "#/definitions/database.MirrorSource" - }, - "mirror_source_id": { - "type": "integer" - }, - "mirror_task_id": { - "type": "integer" - }, - "next_execution_timestamp": { - "type": "string" - }, - "priority": { - "$ref": "#/definitions/types.MirrorPriority" - }, - "progress": { - "type": "integer" - }, - "push_mirror_created": { - "type": "boolean" - }, - "repository": { - "$ref": "#/definitions/database.Repository" - }, - "repository_id": { - "type": "integer" - }, - "source_repo_path": { - "type": "string" - }, - "source_url": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/types.MirrorTaskStatus" - }, - "updated_at": { - "type": "string" - } - } - }, - "database.MirrorSource": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "info_api_url": { - "type": "string" - }, - "source_name": { - "type": "string" - }, - "updated_at": { - "type": "string" - } - } - }, - "database.Model": { - "type": "object", - "properties": { - "base_model": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "last_updated_at": { - "type": "string" - }, - "repository": { - "$ref": "#/definitions/database.Repository" - }, - "repository_id": { - "type": "integer" - }, - "updated_at": { - "type": "string" - } - } - }, - "database.Namespace": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "mirrored": { - "type": "boolean" - }, - "namespace_type": { - "$ref": "#/definitions/database.NamespaceType" - }, - "path": { - "type": "string" - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/database.User" - }, - "user_id": { - "type": "integer" - } - } - }, - "database.NamespaceType": { - "type": "string", - "enum": ["user", "organization"], - "x-enum-varnames": ["UserNamespace", "OrgNamespace"] - }, - "database.Organization": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "description": { - "type": "string" - }, - "git_path": { - "type": "string" - }, - "homepage": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "logo": { - "type": "string" - }, - "name": { - "type": "string" - }, - "namespace": { - "$ref": "#/definitions/database.Namespace" - }, - "namespace_id": { - "type": "integer" - }, - "org_type": { - "type": "string" - }, - "path": { - "description": "unique name of the organization", - "type": "string" - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/database.User" - }, - "user_id": { - "type": "integer" - }, - "verified": { - "type": "boolean" - } - } - }, - "database.Repository": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "default_branch": { - "type": "string" - }, - "description": { - "type": "string" - }, - "download_count": { - "type": "integer" - }, - "downloads": { - "type": "array", - "items": { - "$ref": "#/definitions/database.RepositoryDownload" - } - }, - "git_path": { - "type": "string" - }, - "http_clone_url": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "labels": { - "description": "Depreated", - "type": "string" - }, - "license": { - "type": "string" - }, - "likes": { - "type": "integer" - }, - "mirror": { - "$ref": "#/definitions/database.Mirror" - }, - "name": { - "type": "string" - }, - "nickname": { - "type": "string" - }, - "path": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "readme": { - "description": "Depreated", - "type": "string" - }, - "repository_type": { - "$ref": "#/definitions/types.RepositoryType" - }, - "sensitive_check_status": { - "$ref": "#/definitions/types.SensitiveCheckStatus" - }, - "source": { - "$ref": "#/definitions/types.RepositorySource" - }, - "ssh_clone_url": { - "type": "string" - }, - "sync_status": { - "$ref": "#/definitions/types.RepositorySyncStatus" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Tag" - } - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/database.User" - }, - "user_id": { - "type": "integer" - } - } - }, - "database.RepositoryDownload": { - "type": "object", - "properties": { - "click_download_count": { - "type": "integer" - }, - "created_at": { - "type": "string" - }, - "date": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "repository": { - "$ref": "#/definitions/database.Repository" - }, - "repository_id": { - "type": "integer" - }, - "updated_at": { - "type": "string" - }, - "user_id": { - "type": "integer" - } - } - }, - "database.SSHKey": { - "type": "object", - "properties": { - "content": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "fingerprint_sha256": { - "type": "string" - }, - "git_id": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/database.User" - }, - "user_id": { - "type": "integer" - } - } - }, - "database.SyncClientSetting": { - "type": "object", - "properties": { - "concurrent_count": { - "type": "integer" - }, - "created_at": { - "type": "string" - }, - "default": { - "type": "boolean" - }, - "id": { - "type": "integer" - }, - "max_bandwidth": { - "type": "integer" - }, - "token": { - "type": "string" - }, - "updated_at": { - "type": "string" - } - } - }, - "database.Tag": { - "type": "object", - "properties": { - "built_in": { - "type": "boolean" - }, - "category": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "group": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "scope": { - "$ref": "#/definitions/database.TagScope" - }, - "show_name": { - "type": "string" - }, - "updated_at": { - "type": "string" - } - } - }, - "database.TagCategory": { - "type": "object", - "properties": { - "enabled": { - "type": "boolean" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "scope": { - "$ref": "#/definitions/database.TagScope" - }, - "show_name": { - "type": "string" - } - } - }, - "database.TagScope": { - "type": "string", - "enum": ["model", "dataset", "code", "space", "prompt"], - "x-enum-varnames": [ - "ModelTagScope", - "DatasetTagScope", - "CodeTagScope", - "SpaceTagScope", - "PromptTagScope" - ] - }, - "database.User": { - "type": "object", - "properties": { - "accessTokens": { - "type": "array", - "items": { - "$ref": "#/definitions/database.AccessToken" - } - }, - "avatar": { - "type": "string" - }, - "bio": { - "type": "string" - }, - "can_change_username": { - "description": "allow user to change username once", - "type": "boolean" - }, - "company_verified": { - "type": "boolean" - }, - "created_at": { - "type": "string" - }, - "email": { - "type": "string" - }, - "email_verified": { - "type": "boolean" - }, - "gender": { - "type": "string" - }, - "git_id": { - "type": "integer" - }, - "homepage": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "last_login_at": { - "type": "string" - }, - "name": { - "type": "string" - }, - "namespace": { - "type": "array", - "items": { - "$ref": "#/definitions/database.Namespace" - } - }, - "password_hash": { - "description": "password for user registered without casdoor", - "type": "string" - }, - "phone": { - "type": "string" - }, - "phone_verified": { - "type": "boolean" - }, - "reg_provider": { - "description": "user registered from default login page, from casdoor, etc. Possible values:\n\n- \"default\"\n- \"casdoor\"", - "type": "string" - }, - "role_mask": { - "type": "string" - }, - "updated_at": { - "type": "string" - }, - "username": { - "type": "string" - }, - "uuid": { - "description": "TODO:add unique index after migration", - "type": "string" - } - } - }, - "handler.Create.addMemberRequest": { - "type": "object", - "required": ["role", "users"], - "properties": { - "role": { - "type": "string" - }, - "users": { - "description": "name of user will be added to the org as a member", - "type": "string", - "example": "user1,user2" - } - } - }, - "handler.Delete.removeMemberRequest": { - "type": "object", - "required": ["role"], - "properties": { - "role": { - "type": "string" - } - } - }, - "handler.SetOpWeight.SetOpWeightReq": { - "type": "object", - "required": ["repo_id", "weight"], - "properties": { - "repo_id": { - "type": "integer" - }, - "weight": { - "type": "integer" - } - } - }, - "handler.Update.updateMemberRequest": { - "type": "object", - "required": ["new_role", "old_role"], - "properties": { - "new_role": { - "type": "string" - }, - "old_role": { - "type": "string" - } - } - }, - "telemetry.Counts": { - "type": "object", - "properties": { - "codes": { - "type": "integer" - }, - "datasets": { - "type": "integer" - }, - "models": { - "type": "integer" - }, - "spaces": { - "type": "integer" - }, - "total_repos": { - "type": "integer" - } - } - }, - "telemetry.Licensee": { - "type": "object", - "properties": { - "Company": { - "type": "string" - }, - "Email": { - "type": "string" - }, - "Name": { - "type": "string" - } - } - }, - "telemetry.Settings": { - "type": "object", - "properties": { - "collected_data_categories": { - "type": "array", - "items": { - "type": "string" - } - }, - "gitaly_apdex": { - "type": "number" - }, - "ldap_encrypted_secrets_enabled": { - "type": "boolean" - }, - "operating_system": { - "type": "string" - }, - "service_ping_features_enabled": { - "type": "boolean" - }, - "smtp_encrypted_secrets_enabled": { - "type": "boolean" - }, - "snowplow_configured_to_gitlab_collector": { - "type": "boolean" - }, - "snowplow_enabled": { - "type": "boolean" - } - } - }, - "telemetry.Usage": { - "type": "object", - "properties": { - "active_user_count": { - "type": "integer" - }, - "counts": { - "$ref": "#/definitions/telemetry.Counts" - }, - "edition": { - "type": "string" - }, - "historical_max_users": { - "type": "integer" - }, - "hostname": { - "type": "string" - }, - "installation_type": { - "type": "string" - }, - "license_add_ons": { - "type": "object", - "additionalProperties": true - }, - "license_billable_users": { - "type": "integer" - }, - "license_expires_at": { - "type": "string" - }, - "license_id": { - "type": "integer" - }, - "license_md5": { - "type": "string" - }, - "license_plan": { - "type": "string" - }, - "license_starts_at": { - "type": "string" - }, - "license_user_count": { - "type": "integer" - }, - "licensee": { - "$ref": "#/definitions/telemetry.Licensee" - }, - "recorded_at": { - "type": "string" - }, - "settings": { - "$ref": "#/definitions/telemetry.Settings" - }, - "uuid": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "types.APIBadRequest": { - "type": "object" - }, - "types.APIForbidden": { - "type": "object" - }, - "types.APIInternalServerError": { - "type": "object" - }, - "types.APIUnauthorized": { - "type": "object" - }, - "types.AccessTokenApp": { - "type": "string", - "enum": ["git", "git", "mirror", "starship"], - "x-enum-varnames": [ - "AccessTokenAppGit", - "AccessTokenAppCSGHub", - "AccessTokenAppMirror", - "AccessTokenAppStarship" - ] - }, - "types.Branch": { - "type": "object", - "properties": { - "commit": { - "$ref": "#/definitions/types.RepoBranchCommit" - }, - "message": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "types.Code": { - "type": "object", - "properties": { - "can_manage": { - "type": "boolean" - }, - "can_write": { - "type": "boolean" - }, - "created_at": { - "type": "string" - }, - "default_branch": { - "type": "string" - }, - "description": { - "type": "string" - }, - "downloads": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "license": { - "type": "string" - }, - "likes": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "namespace": { - "$ref": "#/definitions/types.Namespace" - }, - "nickname": { - "type": "string" - }, - "path": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "repository": { - "$ref": "#/definitions/types.Repository" - }, - "repository_id": { - "type": "integer" - }, - "sensitive_check_status": { - "type": "string" - }, - "source": { - "$ref": "#/definitions/types.RepositorySource" - }, - "sync_status": { - "$ref": "#/definitions/types.RepositorySyncStatus" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/types.User" - }, - "user_likes": { - "type": "boolean" - } - } - }, - "types.Collection": { - "type": "object", - "properties": { - "avatar": { - "type": "string" - }, - "can_manage": { - "type": "boolean" - }, - "can_write": { - "type": "boolean" - }, - "created_at": { - "type": "string" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "likes": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "namespace": { - "type": "string" - }, - "nickname": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "repositories": { - "type": "array", - "items": { - "$ref": "#/definitions/types.CollectionRepository" - } - }, - "theme": { - "type": "string" - }, - "updated_at": { - "type": "string" - }, - "user_likes": { - "type": "boolean" - }, - "username": { - "type": "string" - } - } - }, - "types.CollectionRepository": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "description": { - "type": "string" - }, - "download_count": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "likes": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "nickname": { - "type": "string" - }, - "path": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "repository_type": { - "$ref": "#/definitions/types.RepositoryType" - }, - "status": { - "type": "string" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } - }, - "updated_at": { - "type": "string" - }, - "user_id": { - "type": "integer" - } - } - }, - "types.Commit": { - "type": "object", - "properties": { - "author_email": { - "type": "string" - }, - "author_name": { - "type": "string" - }, - "authored_date": { - "type": "string" - }, - "committer_date": { - "type": "string" - }, - "committer_email": { - "type": "string" - }, - "committer_name": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "types.CommitForTree": { - "type": "object", - "properties": { - "author_email": { - "type": "string" - }, - "author_name": { - "type": "string" - }, - "authored_date": { - "type": "string" - }, - "committer_date": { - "type": "string" - }, - "committer_email": { - "type": "string" - }, - "committer_name": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "string" - }, - "message": { - "type": "string" - }, - "name": { - "type": "string" - }, - "path": { - "type": "string" - } - } - }, - "types.CommitMeta": { - "type": "object", - "properties": { - "sha": { - "type": "string" - } - } - }, - "types.CommitResponse": { - "type": "object", - "properties": { - "author_email": { - "type": "string" - }, - "author_name": { - "type": "string" - }, - "authored_date": { - "type": "string" - }, - "committer_date": { - "type": "string" - }, - "committer_email": { - "type": "string" - }, - "committer_name": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "diff": { - "type": "array", - "items": { - "type": "integer" - } - }, - "files": { - "type": "array", - "items": { - "type": "string" - } - }, - "id": { - "type": "string" - }, - "message": { - "type": "string" - }, - "parents": { - "type": "array", - "items": { - "$ref": "#/definitions/types.CommitMeta" - } - }, - "stats": { - "$ref": "#/definitions/types.CommitStats" - } - } - }, - "types.CommitStats": { - "type": "object", - "properties": { - "additions": { - "type": "integer" - }, - "deletions": { - "type": "integer" - }, - "total": { - "type": "integer" - } - } - }, - "types.CreateCategory": { - "type": "object", - "required": ["name", "scope"], - "properties": { - "enabled": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "scope": { - "type": "string" - }, - "show_name": { - "type": "string" - } - } - }, - "types.CreateCodeReq": { - "type": "object", - "properties": { - "default_branch": { - "type": "string", - "example": "main" - }, - "description": { - "type": "string" - }, - "labels": { - "type": "string", - "example": "" - }, - "license": { - "type": "string", - "example": "MIT" - }, - "name": { - "type": "string", - "example": "model_name_1" - }, - "namespace": { - "type": "string", - "example": "user_or_org_name" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean" - }, - "readme": { - "type": "string" - } - } - }, - "types.CreateCollectionReq": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "name": { - "type": "string", - "example": "collection1" - }, - "namespace": { - "type": "string", - "example": "user_or_org_name" - }, - "nickname": { - "type": "string", - "example": "collection nick name" - }, - "private": { - "type": "boolean" - }, - "theme": { - "type": "string", - "example": "#fff000" - } - } - }, - "types.CreateCommentRequest": { - "type": "object", - "required": ["content"], - "properties": { - "commentable_id": { - "type": "integer" - }, - "commentable_type": { - "type": "string" - }, - "content": { - "type": "string" - } - } - }, - "types.CreateCommentResponse": { - "type": "object", - "properties": { - "commentable_id": { - "type": "integer" - }, - "commentable_type": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "user": { - "$ref": "#/definitions/types.DiscussionResponse_User" - } - } - }, - "types.CreateDatasetReq": { - "type": "object", - "properties": { - "default_branch": { - "type": "string", - "example": "main" - }, - "description": { - "type": "string" - }, - "labels": { - "type": "string", - "example": "" - }, - "license": { - "type": "string", - "example": "MIT" - }, - "name": { - "type": "string", - "example": "model_name_1" - }, - "namespace": { - "type": "string", - "example": "user_or_org_name" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean" - }, - "readme": { - "type": "string" - }, - "type": { - "type": "integer" - } - } - }, - "types.CreateDiscussionResponse": { - "type": "object", - "properties": { - "comment_count": { - "description": "DiscussionableID int64 `json:\"discussionable_id\"`\nDiscussionableType string `json:\"discussionable_type\"`", - "type": "integer" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "title": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/types.DiscussionResponse_User" - } - } - }, - "types.CreateFileReq": { - "type": "object", - "properties": { - "branch": { - "type": "string" - }, - "content": { - "type": "string" - }, - "current_user": { - "type": "string" - }, - "message": { - "type": "string" - }, - "new_branch": { - "type": "string" - }, - "original_content": { - "description": "Use for lfs file", - "type": "array", - "items": { - "type": "integer" - } - }, - "pointer": { - "$ref": "#/definitions/types.Pointer" - } - } - }, - "types.CreateFileResp": { - "type": "object" - }, - "types.CreateJWTReq": { - "type": "object", - "required": ["uuid"], - "properties": { - "uuid": { - "type": "string" - } - } - }, - "types.CreateJWTResp": { - "type": "object", - "properties": { - "expire_at": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, - "types.CreateMirrorParams": { - "type": "object", - "properties": { - "mirror_source_id": { - "type": "integer" - }, - "password": { - "type": "string" - }, - "source_url": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "types.CreateMirrorRepoReq": { - "type": "object", - "required": [ - "mirror_source_id", - "repo_type", - "source_name", - "source_namespace", - "source_url" - ], - "properties": { - "branch": { - "type": "string" - }, - "current_user": { - "type": "string" - }, - "description": { - "type": "string" - }, - "license": { - "type": "string" - }, - "mirror_source_id": { - "description": "source id for HF,github etc", - "type": "integer" - }, - "repo_type": { - "description": "repo basic info", - "allOf": [ - { - "$ref": "#/definitions/types.RepositoryType" - } - ] - }, - "source_name": { - "type": "string" - }, - "source_namespace": { - "type": "string" - }, - "source_url": { - "description": "mirror source info", - "type": "string" - }, - "sync_lfs": { - "type": "boolean" - } - } - }, - "types.CreateMirrorSourceReq": { - "type": "object", - "required": ["source_name"], - "properties": { - "current_user": { - "type": "string" - }, - "info_api_url": { - "type": "string" - }, - "source_name": { - "type": "string" - } - } - }, - "types.CreateModelReq": { - "type": "object", - "properties": { - "base_model": { - "type": "string" - }, - "default_branch": { - "type": "string", - "example": "main" - }, - "description": { - "type": "string" - }, - "labels": { - "type": "string", - "example": "" - }, - "license": { - "type": "string", - "example": "MIT" - }, - "name": { - "type": "string", - "example": "model_name_1" - }, - "namespace": { - "type": "string", - "example": "user_or_org_name" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean" - }, - "readme": { - "type": "string" - } - } - }, - "types.CreateOrgReq": { - "type": "object", - "properties": { - "description": { - "type": "string", - "example": "org description" - }, - "homepage": { - "type": "string", - "example": "https://www.example.com" - }, - "logo": { - "type": "string", - "example": "https://www.example.com/logo.png" - }, - "name": { - "description": "Org unique identifier", - "type": "string", - "example": "org_name_1" - }, - "nickname": { - "description": "Display name", - "type": "string", - "example": "org_display_name" - }, - "org_type": { - "type": "string", - "example": "company or school etc" - }, - "verified": { - "type": "boolean", - "example": false - } - } - }, - "types.CreatePromptRepoReq": { - "type": "object", - "properties": { - "default_branch": { - "type": "string", - "example": "main" - }, - "description": { - "type": "string" - }, - "labels": { - "type": "string", - "example": "" - }, - "license": { - "type": "string", - "example": "MIT" - }, - "name": { - "type": "string", - "example": "model_name_1" - }, - "namespace": { - "type": "string", - "example": "user_or_org_name" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean" - }, - "readme": { - "type": "string" - } - } - }, - "types.CreateRepoDiscussionRequest": { - "type": "object", - "required": ["title"], - "properties": { - "title": { - "type": "string" - } - } - }, - "types.CreateSSHKeyRequest": { - "type": "object", - "properties": { - "content": { - "type": "string" - }, - "name": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "types.CreateSpaceReq": { - "type": "object", - "properties": { - "cluster_id": { - "type": "string" - }, - "cover_image_url": { - "type": "string" - }, - "default_branch": { - "type": "string", - "example": "main" - }, - "description": { - "type": "string" - }, - "env": { - "type": "string" - }, - "labels": { - "type": "string", - "example": "" - }, - "license": { - "type": "string", - "example": "MIT" - }, - "name": { - "type": "string", - "example": "model_name_1" - }, - "namespace": { - "type": "string", - "example": "user_or_org_name" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean" - }, - "readme": { - "type": "string" - }, - "resource_id": { - "type": "integer" - }, - "sdk": { - "type": "string", - "example": "1" - }, - "sdk_version": { - "type": "string", - "example": "v0.1" - }, - "secrets": { - "type": "string" - }, - "template": { - "type": "string" - } - } - }, - "types.CreateSpaceResourceReq": { - "type": "object", - "required": ["cluster_id", "name", "resources"], - "properties": { - "cluster_id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "resources": { - "type": "string" - } - } - }, - "types.CreateSpaceSdkReq": { - "type": "object", - "required": ["name", "version"], - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "types.CreateSyncClientSettingReq": { - "type": "object", - "required": ["token"], - "properties": { - "concurrent_count": { - "type": "integer" - }, - "max_bandwidth": { - "type": "integer" - }, - "token": { - "type": "string" - } - } - }, - "types.CreateTag": { - "type": "object", - "required": ["category", "name", "scope"], - "properties": { - "built_in": { - "type": "boolean" - }, - "category": { - "type": "string" - }, - "group": { - "type": "string" - }, - "name": { - "type": "string" - }, - "scope": { - "type": "string" - }, - "show_name": { - "type": "string" - } - } - }, - "types.CreateUserTokenRequest": { - "type": "object", - "properties": { - "application": { - "description": "default to csghub", - "allOf": [ - { - "$ref": "#/definitions/types.AccessTokenApp" - } - ] - }, - "expired_at": { - "type": "string" - }, - "name": { - "type": "string" - }, - "permission": { - "description": "default to empty, means full permission", - "type": "string" - } - } - }, - "types.Dataset": { - "type": "object", - "properties": { - "can_manage": { - "type": "boolean" - }, - "can_write": { - "type": "boolean" - }, - "created_at": { - "type": "string" - }, - "default_branch": { - "type": "string" - }, - "description": { - "type": "string" - }, - "downloads": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "license": { - "type": "string" - }, - "likes": { - "type": "integer" - }, - "mirror_last_updated_at": { - "type": "string" - }, - "name": { - "type": "string" - }, - "namespace": { - "$ref": "#/definitions/types.Namespace" - }, - "nickname": { - "type": "string" - }, - "path": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "readme": { - "type": "string" - }, - "repository": { - "$ref": "#/definitions/types.Repository" - }, - "repository_id": { - "type": "integer" - }, - "sensitive_check_status": { - "type": "string" - }, - "source": { - "$ref": "#/definitions/types.RepositorySource" - }, - "sync_status": { - "$ref": "#/definitions/types.RepositorySyncStatus" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/types.User" - }, - "user_likes": { - "type": "boolean" - } - } - }, - "types.DatasetResp": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "downloads": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "nickname": { - "type": "string" - }, - "path": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } - }, - "updated_at": { - "type": "string" - } - } - }, - "types.DeleteOrgReq": { - "type": "object" - }, - "types.DeleteUserTokenRequest": { - "type": "object", - "properties": { - "application": { - "description": "default to csghub", - "allOf": [ - { - "$ref": "#/definitions/types.AccessTokenApp" - } - ] - }, - "expired_at": { - "type": "string" - }, - "name": { - "type": "string" - }, - "permission": { - "description": "default to empty, means full permission", - "type": "string" - } - } - }, - "types.DeployUpdateReq": { - "type": "object", - "properties": { - "cluster_id": { - "type": "string" - }, - "deploy_name": { - "type": "string" - }, - "env": { - "type": "string" - }, - "max_replica": { - "type": "integer", - "minimum": 1 - }, - "min_replica": { - "type": "integer", - "minimum": 1 - }, - "resource_id": { - "type": "integer" - }, - "revision": { - "type": "string" - }, - "runtime_framework_id": { - "type": "integer" - }, - "secure_level": { - "type": "integer" - } - } - }, - "types.DiscussionResponse_Comment": { - "type": "object", - "properties": { - "content": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "user": { - "$ref": "#/definitions/types.DiscussionResponse_User" - } - } - }, - "types.DiscussionResponse_User": { - "type": "object", - "properties": { - "avatar": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - } - } - }, - "types.EditOrgReq": { - "type": "object", - "properties": { - "description": { - "type": "string", - "example": "org description" - }, - "homepage": { - "type": "string", - "example": "https://www.example.com" - }, - "logo": { - "type": "string", - "example": "https://www.example.com/logo.png" - }, - "nickname": { - "description": "Display name", - "type": "string", - "example": "org display name" - }, - "org_type": { - "type": "string", - "example": "company or school etc" - }, - "verified": { - "type": "boolean", - "example": false - } - } - }, - "types.EvaluationReq": { - "type": "object", - "properties": { - "datasets": { - "type": "array", - "items": { - "type": "string" - } - }, - "model_id": { - "type": "string" - }, - "resource_id": { - "type": "integer" - }, - "runtime_framework_id": { - "description": "ArgoWorkFlow framework", - "type": "integer" - }, - "share_mode": { - "type": "boolean" - }, - "task_desc": { - "type": "string" - }, - "task_name": { - "type": "string" - } - } - }, - "types.EvaluationRes": { - "type": "object", - "properties": { - "datasets": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTags" - } - }, - "download_url": { - "type": "string" - }, - "end_time": { - "type": "string" - }, - "failures_url": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "image": { - "type": "string" - }, - "reason": { - "type": "string" - }, - "repo_ids": { - "type": "array", - "items": { - "type": "string" - } - }, - "repo_type": { - "type": "string" - }, - "resource_id": { - "type": "integer" - }, - "result_url": { - "type": "string" - }, - "start_time": { - "type": "string" - }, - "status": { - "type": "string" - }, - "submit_time": { - "type": "string" - }, - "task_desc": { - "type": "string" - }, - "task_id": { - "type": "string" - }, - "task_name": { - "type": "string" - }, - "task_type": { - "$ref": "#/definitions/types.TaskType" - }, - "username": { - "type": "string" - } - } - }, - "types.Event": { - "type": "object", - "properties": { - "c_id": { - "type": "string", - "example": "" - }, - "c_ip": { - "type": "string", - "example": "" - }, - "ext": { - "description": "reserved for future use", - "type": "string", - "example": "" - }, - "id": { - "type": "string", - "example": "space_card" - }, - "m": { - "type": "string", - "example": "space" - }, - "v": { - "type": "string", - "example": "1" - } - } - }, - "types.File": { - "type": "object", - "properties": { - "commit": { - "$ref": "#/definitions/types.Commit" - }, - "content": { - "type": "string" - }, - "last_commit_sha": { - "type": "string" - }, - "lfs": { - "type": "boolean" - }, - "lfs_pointer_size": { - "type": "integer" - }, - "lfs_relative_path": { - "description": "relative path in lfs storage", - "type": "string" - }, - "mode": { - "type": "string" - }, - "name": { - "type": "string" - }, - "path": { - "type": "string" - }, - "sha": { - "type": "string" - }, - "size": { - "type": "integer" - }, - "type": { - "type": "string" - }, - "url": { - "description": "URL to browse the file", - "type": "string" - } - } - }, - "types.GetRepoFileTreeResp": { - "type": "object", - "properties": { - "cursor": { - "type": "string" - }, - "files": { - "type": "array", - "items": { - "$ref": "#/definitions/types.File" - } - } - } - }, - "types.InstanceRunReq": { - "type": "object", - "properties": { - "cluster_id": { - "type": "string" - }, - "deploy_name": { - "type": "string" - }, - "resource_id": { - "type": "integer" - }, - "revision": { - "type": "string" - }, - "runtime_framework_id": { - "type": "integer" - } - } - }, - "types.ListByPathReq": { - "type": "object", - "properties": { - "paths": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "types.ListRepoDiscussionResponse": { - "type": "object", - "properties": { - "discussions": { - "type": "array", - "items": { - "$ref": "#/definitions/types.CreateDiscussionResponse" - } - } - } - }, - "types.LogsTreeResp": { - "type": "object", - "properties": { - "commits": { - "type": "array", - "items": { - "$ref": "#/definitions/types.CommitForTree" - } - } - } - }, - "types.Member": { - "type": "object", - "properties": { - "avatar": { - "type": "string" - }, - "last_login_at": { - "type": "string" - }, - "nickname": { - "type": "string" - }, - "role": { - "type": "string" - }, - "username": { - "type": "string" - }, - "uuid": { - "type": "string" - } - } - }, - "types.Mirror": { - "type": "object", - "properties": { - "access_token": { - "description": "source access token", - "type": "string" - }, - "last_message": { - "type": "string" - }, - "last_updated_at": { - "type": "string" - }, - "local_repo_path": { - "type": "string" - }, - "mirror_source": { - "$ref": "#/definitions/types.MirrorSource" - }, - "progress": { - "type": "integer" - }, - "push_access_token": { - "type": "string" - }, - "push_url": { - "type": "string" - }, - "push_username": { - "type": "string" - }, - "repository": { - "$ref": "#/definitions/types.Repository" - }, - "source_repo_path": { - "type": "string" - }, - "source_url": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/types.MirrorTaskStatus" - }, - "username": { - "description": "source user name", - "type": "string" - } - } - }, - "types.MirrorPriority": { - "type": "integer", - "enum": [3, 2, 1], - "x-enum-varnames": [ - "HighMirrorPriority", - "MediumMirrorPriority", - "LowMirrorPriority" - ] - }, - "types.MirrorRepo": { - "type": "object", - "properties": { - "path": { - "type": "string" - }, - "progress": { - "type": "integer" - }, - "repo_type": { - "$ref": "#/definitions/types.RepositoryType" - }, - "sync_status": { - "$ref": "#/definitions/types.RepositorySyncStatus" - } - } - }, - "types.MirrorSource": { - "type": "object", - "properties": { - "source_name": { - "type": "string" - } - } - }, - "types.MirrorTaskStatus": { - "type": "string", - "enum": [ - "waiting", - "running", - "repo_synced", - "finished", - "failed", - "incomplete" - ], - "x-enum-varnames": [ - "MirrorWaiting", - "MirrorRunning", - "MirrorRepoSynced", - "MirrorFinished", - "MirrorFailed", - "MirrorIncomplete" - ] - }, - "types.Model": { - "type": "object", - "properties": { - "base_model": { - "type": "string" - }, - "can_manage": { - "type": "boolean" - }, - "can_write": { - "type": "boolean" - }, - "created_at": { - "type": "string" - }, - "default_branch": { - "type": "string" - }, - "description": { - "type": "string" - }, - "downloads": { - "type": "integer" - }, - "enable_evaluation": { - "type": "boolean" - }, - "enable_finetune": { - "type": "boolean" - }, - "enable_inference": { - "type": "boolean" - }, - "id": { - "type": "integer" - }, - "license": { - "type": "string" - }, - "likes": { - "type": "integer" - }, - "mirror_last_updated_at": { - "type": "string" - }, - "name": { - "type": "string" - }, - "namespace": { - "$ref": "#/definitions/types.Namespace" - }, - "nickname": { - "type": "string" - }, - "path": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "readme": { - "type": "string" - }, - "recom_op_weight": { - "type": "integer" - }, - "repository": { - "$ref": "#/definitions/types.Repository" - }, - "repository_id": { - "type": "integer" - }, - "sensitive_check_status": { - "type": "string" - }, - "source": { - "$ref": "#/definitions/types.RepositorySource" - }, - "status": { - "description": "url to interact with the model", - "type": "string", - "example": "RUNNING" - }, - "sync_status": { - "$ref": "#/definitions/types.RepositorySyncStatus" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } - }, - "updated_at": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/types.User" - }, - "user_likes": { - "type": "boolean" - }, - "widget_type": { - "description": "widget UI style: generation,chat", - "allOf": [ - { - "$ref": "#/definitions/types.ModelWidgetType" + "database.Code": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "last_updated_at": { + "type": "string" + }, + "repository": { + "$ref": "#/definitions/database.Repository" + }, + "repository_id": { + "type": "integer" + }, + "updated_at": { + "type": "string" + } } - ], - "example": "generation" - } - } - }, - "types.ModelResp": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "downloads": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "nickname": { - "type": "string" - }, - "path": { - "type": "string" - }, - "private": { - "type": "boolean" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } - }, - "updated_at": { - "type": "string" - } - } - }, - "types.ModelRunReq": { - "type": "object", - "properties": { - "cluster_id": { - "type": "string" - }, - "deploy_name": { - "type": "string" - }, - "env": { - "type": "string" - }, - "max_replica": { - "type": "integer" - }, - "min_replica": { - "type": "integer" - }, - "resource_id": { - "type": "integer" - }, - "revision": { - "type": "string" - }, - "runtime_framework_id": { - "type": "integer" - }, - "secure_level": { - "type": "integer" - } - } - }, - "types.ModelWidgetType": { - "type": "string", - "enum": ["generation", "chat"], - "x-enum-varnames": ["ModelWidgetTypeGeneration", "ModelWidgetTypeChat"] - }, - "types.Namespace": { - "type": "object", - "properties": { - "avatar": { - "type": "string" - }, - "path": { - "type": "string" - }, - "type": { - "description": "namespace types like 'user' for normal user, and 'school', 'company' for orgs etc.", - "type": "string" - } - } - }, - "types.Organization": { - "type": "object", - "properties": { - "homepage": { - "type": "string" - }, - "logo": { - "type": "string" - }, - "name": { - "type": "string" - }, - "org_type": { - "type": "string" - }, - "path": { - "description": "unique name of the organization", - "type": "string" - }, - "user_id": { - "type": "integer" - }, - "verified": { - "type": "boolean" - } - } - }, - "types.Pointer": { - "type": "object", - "properties": { - "download_url": { - "type": "string" - }, - "oid": { - "type": "string" - }, - "size": { - "type": "integer" - } - } - }, - "types.PromptRes": { - "type": "object", - "properties": { - "can_manage": { - "type": "boolean" - }, - "can_write": { - "type": "boolean" - }, - "created_at": { - "type": "string" - }, - "default_branch": { - "type": "string" - }, - "description": { - "type": "string" - }, - "downloads": { - "type": "integer" - }, - "id": { - "type": "integer" }, - "license": { - "type": "string" - }, - "likes": { - "type": "integer" - }, - "name": { - "type": "string" + "database.Collection": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "likes": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "repositories": { + "type": "array", + "items": { + "$ref": "#/definitions/database.Repository" + } + }, + "theme": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "user_id": { + "type": "integer" + }, + "username": { + "type": "string" + } + } }, - "namespace": { - "$ref": "#/definitions/types.Namespace" + "database.Dataset": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "last_updated_at": { + "type": "string" + }, + "repository": { + "$ref": "#/definitions/database.Repository" + }, + "repository_id": { + "type": "integer" + }, + "updated_at": { + "type": "string" + } + } }, - "nickname": { - "type": "string" + "database.Mirror": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "interval": { + "type": "string" + }, + "last_message": { + "type": "string" + }, + "last_updated_at": { + "type": "string" + }, + "local_repo_path": { + "type": "string" + }, + "mirror_source": { + "$ref": "#/definitions/database.MirrorSource" + }, + "mirror_source_id": { + "type": "integer" + }, + "mirror_task_id": { + "type": "integer" + }, + "next_execution_timestamp": { + "type": "string" + }, + "priority": { + "$ref": "#/definitions/types.MirrorPriority" + }, + "progress": { + "type": "integer" + }, + "push_mirror_created": { + "type": "boolean" + }, + "repository": { + "$ref": "#/definitions/database.Repository" + }, + "repository_id": { + "type": "integer" + }, + "source_repo_path": { + "type": "string" + }, + "source_url": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/types.MirrorTaskStatus" + }, + "updated_at": { + "type": "string" + } + } }, - "path": { - "type": "string" + "database.MirrorSource": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "info_api_url": { + "type": "string" + }, + "source_name": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + } }, - "private": { - "type": "boolean" + "database.Model": { + "type": "object", + "properties": { + "base_model": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "last_updated_at": { + "type": "string" + }, + "repository": { + "$ref": "#/definitions/database.Repository" + }, + "repository_id": { + "type": "integer" + }, + "updated_at": { + "type": "string" + } + } }, - "readme": { - "type": "string" + "database.Namespace": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "mirrored": { + "type": "boolean" + }, + "namespace_type": { + "$ref": "#/definitions/database.NamespaceType" + }, + "path": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/database.User" + }, + "user_id": { + "type": "integer" + } + } }, - "repository": { - "$ref": "#/definitions/types.Repository" + "database.NamespaceType": { + "type": "string", + "enum": [ + "user", + "organization" + ], + "x-enum-varnames": [ + "UserNamespace", + "OrgNamespace" + ] }, - "repository_id": { - "type": "integer" + "database.Organization": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "git_path": { + "type": "string" + }, + "homepage": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "logo": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "$ref": "#/definitions/database.Namespace" + }, + "namespace_id": { + "type": "integer" + }, + "org_type": { + "type": "string" + }, + "path": { + "description": "unique name of the organization", + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/database.User" + }, + "user_id": { + "type": "integer" + }, + "verified": { + "type": "boolean" + } + } }, - "source": { - "$ref": "#/definitions/types.RepositorySource" + "database.Repository": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "default_branch": { + "type": "string" + }, + "description": { + "type": "string" + }, + "download_count": { + "type": "integer" + }, + "downloads": { + "type": "array", + "items": { + "$ref": "#/definitions/database.RepositoryDownload" + } + }, + "git_path": { + "type": "string" + }, + "http_clone_url": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "labels": { + "description": "Depreated", + "type": "string" + }, + "license": { + "type": "string" + }, + "likes": { + "type": "integer" + }, + "mirror": { + "$ref": "#/definitions/database.Mirror" + }, + "name": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "readme": { + "description": "Depreated", + "type": "string" + }, + "repository_type": { + "$ref": "#/definitions/types.RepositoryType" + }, + "sensitive_check_status": { + "$ref": "#/definitions/types.SensitiveCheckStatus" + }, + "source": { + "$ref": "#/definitions/types.RepositorySource" + }, + "ssh_clone_url": { + "type": "string" + }, + "sync_status": { + "$ref": "#/definitions/types.RepositorySyncStatus" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/database.Tag" + } + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/database.User" + }, + "user_id": { + "type": "integer" + } + } }, - "sync_status": { - "$ref": "#/definitions/types.RepositorySyncStatus" + "database.RepositoryDownload": { + "type": "object", + "properties": { + "click_download_count": { + "type": "integer" + }, + "created_at": { + "type": "string" + }, + "date": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "repository": { + "$ref": "#/definitions/database.Repository" + }, + "repository_id": { + "type": "integer" + }, + "updated_at": { + "type": "string" + }, + "user_id": { + "type": "integer" + } + } }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } + "database.SSHKey": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "fingerprint_sha256": { + "type": "string" + }, + "git_id": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/database.User" + }, + "user_id": { + "type": "integer" + } + } }, - "updated_at": { - "type": "string" + "database.SyncClientSetting": { + "type": "object", + "properties": { + "concurrent_count": { + "type": "integer" + }, + "created_at": { + "type": "string" + }, + "default": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "max_bandwidth": { + "type": "integer" + }, + "token": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + } }, - "user": { - "$ref": "#/definitions/types.User" + "database.Tag": { + "type": "object", + "properties": { + "built_in": { + "type": "boolean" + }, + "category": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "group": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "scope": { + "$ref": "#/definitions/database.TagScope" + }, + "show_name": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + } }, - "user_likes": { - "type": "boolean" - } - } - }, - "types.RelationDataset": { - "type": "object", - "properties": { - "dataset": { - "type": "string" - } - } - }, - "types.RelationDatasets": { - "type": "object", - "properties": { - "datasets": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "types.RelationModel": { - "type": "object", - "properties": { - "model": { - "type": "string" - } - } - }, - "types.RelationModels": { - "type": "object", - "properties": { - "models": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "types.Relations": { - "type": "object", - "properties": { - "codes": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Code" - } - }, - "datasets": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Dataset" - } - }, - "models": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Model" - } - }, - "prompts": { - "type": "array", - "items": { - "$ref": "#/definitions/types.PromptRes" - } - }, - "spaces": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Space" - } - } - } - }, - "types.RepoBranchCommit": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, - "types.RepoTag": { - "type": "object", - "properties": { - "built_in": { - "type": "boolean" + "database.TagCategory": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "scope": { + "$ref": "#/definitions/database.TagScope" + }, + "show_name": { + "type": "string" + } + } + }, + "database.TagScope": { + "type": "string", + "enum": [ + "model", + "dataset", + "code", + "space", + "prompt" + ], + "x-enum-varnames": [ + "ModelTagScope", + "DatasetTagScope", + "CodeTagScope", + "SpaceTagScope", + "PromptTagScope" + ] + }, + "database.User": { + "type": "object", + "properties": { + "accessTokens": { + "type": "array", + "items": { + "$ref": "#/definitions/database.AccessToken" + } + }, + "avatar": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "can_change_username": { + "description": "allow user to change username once", + "type": "boolean" + }, + "company_verified": { + "type": "boolean" + }, + "created_at": { + "type": "string" + }, + "email": { + "type": "string" + }, + "email_verified": { + "type": "boolean" + }, + "gender": { + "type": "string" + }, + "git_id": { + "type": "integer" + }, + "homepage": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "last_login_at": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "array", + "items": { + "$ref": "#/definitions/database.Namespace" + } + }, + "password_hash": { + "description": "password for user registered without casdoor", + "type": "string" + }, + "phone": { + "type": "string" + }, + "phone_verified": { + "type": "boolean" + }, + "reg_provider": { + "description": "user registered from default login page, from casdoor, etc. Possible values:\n\n- \"default\"\n- \"casdoor\"", + "type": "string" + }, + "role_mask": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "username": { + "type": "string" + }, + "uuid": { + "description": "TODO:add unique index after migration", + "type": "string" + } + } }, - "category": { - "type": "string" + "handler.Create.addMemberRequest": { + "type": "object", + "required": [ + "role", + "users" + ], + "properties": { + "role": { + "type": "string" + }, + "users": { + "description": "name of user will be added to the org as a member", + "type": "string", + "example": "user1,user2" + } + } }, - "created_at": { - "type": "string" + "handler.Delete.removeMemberRequest": { + "type": "object", + "required": [ + "role" + ], + "properties": { + "role": { + "type": "string" + } + } }, - "group": { - "type": "string" + "handler.SetOpWeight.SetOpWeightReq": { + "type": "object", + "required": [ + "repo_id", + "weight" + ], + "properties": { + "repo_id": { + "type": "integer" + }, + "weight": { + "type": "integer" + } + } }, - "name": { - "type": "string" + "handler.Update.updateMemberRequest": { + "type": "object", + "required": [ + "new_role", + "old_role" + ], + "properties": { + "new_role": { + "type": "string" + }, + "old_role": { + "type": "string" + } + } }, - "show_name": { - "type": "string" + "telemetry.Counts": { + "type": "object", + "properties": { + "codes": { + "type": "integer" + }, + "datasets": { + "type": "integer" + }, + "models": { + "type": "integer" + }, + "spaces": { + "type": "integer" + }, + "total_repos": { + "type": "integer" + } + } }, - "updated_at": { - "type": "string" - } - } - }, - "types.RepoTags": { - "type": "object", - "properties": { - "repo_id": { - "type": "string" - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } - } - } - }, - "types.Repository": { - "type": "object", - "properties": { - "http_clone_url": { - "type": "string" - }, - "ssh_clone_url": { - "type": "string" - } - } - }, - "types.RepositorySource": { - "type": "string", - "enum": ["opencsg", "local", "huggingface"], - "x-enum-varnames": ["OpenCSGSource", "LocalSource", "HuggingfaceSource"] - }, - "types.RepositorySyncStatus": { - "type": "string", - "enum": ["pending", "inprogress", "failed", "completed"], - "x-enum-varnames": [ - "SyncStatusPending", - "SyncStatusInProgress", - "SyncStatusFailed", - "SyncStatusCompleted" - ] - }, - "types.RepositoryType": { - "type": "string", - "enum": ["model", "dataset", "space", "code", "prompt", ""], - "x-enum-varnames": [ - "ModelRepo", - "DatasetRepo", - "SpaceRepo", - "CodeRepo", - "PromptRepo", - "UnknownRepo" - ] - }, - "types.ResourceType": { - "type": "string", - "enum": ["cpu", "gpu"], - "x-enum-varnames": ["ResourceTypeCPU", "ResourceTypeGPU"] - }, - "types.Response": { - "type": "object", - "properties": { - "data": {}, - "msg": { - "type": "string" - } - } - }, - "types.ResponseWithTotal": { - "type": "object", - "properties": { - "data": {}, - "msg": { - "type": "string" - }, - "total": { - "type": "integer" - } - } - }, - "types.RuntimeArchitecture": { - "type": "object", - "properties": { - "architectures": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "types.RuntimeFramework": { - "type": "object", - "properties": { - "container_port": { - "type": "integer" + "telemetry.Licensee": { + "type": "object", + "properties": { + "Company": { + "type": "string" + }, + "Email": { + "type": "string" + }, + "Name": { + "type": "string" + } + } }, - "enabled": { - "type": "integer" + "telemetry.Settings": { + "type": "object", + "properties": { + "collected_data_categories": { + "type": "array", + "items": { + "type": "string" + } + }, + "gitaly_apdex": { + "type": "number" + }, + "ldap_encrypted_secrets_enabled": { + "type": "boolean" + }, + "operating_system": { + "type": "string" + }, + "service_ping_features_enabled": { + "type": "boolean" + }, + "smtp_encrypted_secrets_enabled": { + "type": "boolean" + }, + "snowplow_configured_to_gitlab_collector": { + "type": "boolean" + }, + "snowplow_enabled": { + "type": "boolean" + } + } }, - "frame_cpu_image": { - "type": "string" + "telemetry.Usage": { + "type": "object", + "properties": { + "active_user_count": { + "type": "integer" + }, + "counts": { + "$ref": "#/definitions/telemetry.Counts" + }, + "edition": { + "type": "string" + }, + "historical_max_users": { + "type": "integer" + }, + "hostname": { + "type": "string" + }, + "installation_type": { + "type": "string" + }, + "license_add_ons": { + "type": "object", + "additionalProperties": true + }, + "license_billable_users": { + "type": "integer" + }, + "license_expires_at": { + "type": "string" + }, + "license_id": { + "type": "integer" + }, + "license_md5": { + "type": "string" + }, + "license_plan": { + "type": "string" + }, + "license_starts_at": { + "type": "string" + }, + "license_user_count": { + "type": "integer" + }, + "licensee": { + "$ref": "#/definitions/telemetry.Licensee" + }, + "recorded_at": { + "type": "string" + }, + "settings": { + "$ref": "#/definitions/telemetry.Settings" + }, + "uuid": { + "type": "string" + }, + "version": { + "type": "string" + } + } }, - "frame_image": { - "type": "string" + "types.APIBadRequest": { + "type": "object" }, - "frame_name": { - "type": "string" + "types.APIForbidden": { + "type": "object" }, - "frame_version": { - "type": "string" + "types.APIInternalServerError": { + "type": "object" }, - "id": { - "type": "integer" + "types.APIUnauthorized": { + "type": "object" }, - "type": { - "type": "integer" - } - } - }, - "types.RuntimeFrameworkModels": { - "type": "object", - "properties": { - "models": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "types.RuntimeFrameworkReq": { - "type": "object", - "properties": { - "container_port": { - "type": "integer" + "types.AccessTokenApp": { + "type": "string", + "enum": [ + "git", + "git", + "mirror", + "starship" + ], + "x-enum-varnames": [ + "AccessTokenAppGit", + "AccessTokenAppCSGHub", + "AccessTokenAppMirror", + "AccessTokenAppStarship" + ] }, - "enabled": { - "type": "integer" + "types.Branch": { + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/types.RepoBranchCommit" + }, + "message": { + "type": "string" + }, + "name": { + "type": "string" + } + } }, - "frame_cpu_image": { - "type": "string" + "types.Code": { + "type": "object", + "properties": { + "can_manage": { + "type": "boolean" + }, + "can_write": { + "type": "boolean" + }, + "created_at": { + "type": "string" + }, + "default_branch": { + "type": "string" + }, + "description": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "license": { + "type": "string" + }, + "likes": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "namespace": { + "$ref": "#/definitions/types.Namespace" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "repository": { + "$ref": "#/definitions/types.Repository" + }, + "repository_id": { + "type": "integer" + }, + "sensitive_check_status": { + "type": "string" + }, + "source": { + "$ref": "#/definitions/types.RepositorySource" + }, + "sync_status": { + "$ref": "#/definitions/types.RepositorySyncStatus" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/types.User" + }, + "user_likes": { + "type": "boolean" + } + } }, - "frame_image": { - "type": "string" + "types.Collection": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "can_manage": { + "type": "boolean" + }, + "can_write": { + "type": "boolean" + }, + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "likes": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "repositories": { + "type": "array", + "items": { + "$ref": "#/definitions/types.CollectionRepository" + } + }, + "theme": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "user_likes": { + "type": "boolean" + }, + "username": { + "type": "string" + } + } }, - "frame_name": { - "type": "string" + "types.CollectionRepository": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "download_count": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "likes": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "repository_type": { + "$ref": "#/definitions/types.RepositoryType" + }, + "status": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "updated_at": { + "type": "string" + }, + "user_id": { + "type": "integer" + } + } }, - "frame_version": { - "type": "string" + "types.Commit": { + "type": "object", + "properties": { + "author_email": { + "type": "string" + }, + "author_name": { + "type": "string" + }, + "authored_date": { + "type": "string" + }, + "committer_date": { + "type": "string" + }, + "committer_email": { + "type": "string" + }, + "committer_name": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "string" + }, + "message": { + "type": "string" + } + } }, - "type": { - "type": "integer" - } - } - }, - "types.SensitiveCheckStatus": { - "type": "integer", - "enum": [-1, 0, 1, 2, 3], - "x-enum-comments": { - "SensitiveCheckException": "error happen", - "SensitiveCheckFail": "sensitive content detected", - "SensitiveCheckPass": "pass", - "SensitiveCheckPending": "default", - "SensitiveCheckSkip": "skip" - }, - "x-enum-varnames": [ - "SensitiveCheckFail", - "SensitiveCheckPending", - "SensitiveCheckPass", - "SensitiveCheckSkip", - "SensitiveCheckException" - ] - }, - "types.ShowDiscussionResponse": { - "type": "object", - "properties": { - "comment_count": { - "type": "integer" - }, - "comments": { - "type": "array", - "items": { - "$ref": "#/definitions/types.DiscussionResponse_Comment" - } - }, - "id": { - "type": "integer" - }, - "title": { - "type": "string" - }, - "user": { - "$ref": "#/definitions/types.DiscussionResponse_User" - } - } - }, - "types.Space": { - "type": "object", - "properties": { - "can_manage": { - "type": "boolean" + "types.CommitForTree": { + "type": "object", + "properties": { + "author_email": { + "type": "string" + }, + "author_name": { + "type": "string" + }, + "authored_date": { + "type": "string" + }, + "committer_date": { + "type": "string" + }, + "committer_email": { + "type": "string" + }, + "committer_name": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "string" + }, + "message": { + "type": "string" + }, + "name": { + "type": "string" + }, + "path": { + "type": "string" + } + } }, - "can_write": { - "type": "boolean" + "types.CommitMeta": { + "type": "object", + "properties": { + "sha": { + "type": "string" + } + } }, - "cover_image_url": { - "type": "string" + "types.CommitResponse": { + "type": "object", + "properties": { + "author_email": { + "type": "string" + }, + "author_name": { + "type": "string" + }, + "authored_date": { + "type": "string" + }, + "committer_date": { + "type": "string" + }, + "committer_email": { + "type": "string" + }, + "committer_name": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "diff": { + "type": "array", + "items": { + "type": "integer" + } + }, + "files": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "string" + }, + "message": { + "type": "string" + }, + "parents": { + "type": "array", + "items": { + "$ref": "#/definitions/types.CommitMeta" + } + }, + "stats": { + "$ref": "#/definitions/types.CommitStats" + } + } }, - "created_at": { - "type": "string" + "types.CommitStats": { + "type": "object", + "properties": { + "additions": { + "type": "integer" + }, + "deletions": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } }, - "default_branch": { - "type": "string" + "types.CreateCategory": { + "type": "object", + "required": [ + "name", + "scope" + ], + "properties": { + "enabled": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "show_name": { + "type": "string" + } + } }, - "description": { - "type": "string", - "example": "" + "types.CreateCodeReq": { + "type": "object", + "properties": { + "default_branch": { + "type": "string", + "example": "main" + }, + "description": { + "type": "string" + }, + "labels": { + "type": "string", + "example": "" + }, + "license": { + "type": "string", + "example": "MIT" + }, + "name": { + "type": "string", + "example": "model_name_1" + }, + "namespace": { + "type": "string", + "example": "user_or_org_name" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + } + } }, - "endpoint": { - "description": "the serving endpoint url", - "type": "string", - "example": "https://localhost/spaces/myname/myspace" + "types.CreateCollectionReq": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string", + "example": "collection1" + }, + "namespace": { + "type": "string", + "example": "user_or_org_name" + }, + "nickname": { + "type": "string", + "example": "collection nick name" + }, + "private": { + "type": "boolean" + }, + "theme": { + "type": "string", + "example": "#fff000" + } + } }, - "env": { - "type": "string" + "types.CreateCommentRequest": { + "type": "object", + "required": [ + "content" + ], + "properties": { + "commentable_id": { + "type": "integer" + }, + "commentable_type": { + "type": "string" + }, + "content": { + "type": "string" + } + } }, - "hardware": { - "type": "string" + "types.CreateCommentResponse": { + "type": "object", + "properties": { + "commentable_id": { + "type": "integer" + }, + "commentable_type": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "user": { + "$ref": "#/definitions/types.DiscussionResponse_User" + } + } }, - "id": { - "type": "integer" + "types.CreateDatasetReq": { + "type": "object", + "properties": { + "default_branch": { + "type": "string", + "example": "main" + }, + "description": { + "type": "string" + }, + "labels": { + "type": "string", + "example": "" + }, + "license": { + "type": "string", + "example": "MIT" + }, + "name": { + "type": "string", + "example": "model_name_1" + }, + "namespace": { + "type": "string", + "example": "user_or_org_name" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + }, + "type": { + "type": "integer" + } + } }, - "license": { - "type": "string", - "example": "MIT" + "types.CreateDiscussionResponse": { + "type": "object", + "properties": { + "comment_count": { + "description": "DiscussionableID int64 `json:\"discussionable_id\"`\nDiscussionableType string `json:\"discussionable_type\"`", + "type": "integer" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/types.DiscussionResponse_User" + } + } }, - "like_count": { - "type": "integer" + "types.CreateFileReq": { + "type": "object", + "properties": { + "branch": { + "type": "string" + }, + "content": { + "type": "string" + }, + "current_user": { + "type": "string" + }, + "message": { + "type": "string" + }, + "new_branch": { + "type": "string" + }, + "original_content": { + "description": "Use for lfs file", + "type": "array", + "items": { + "type": "integer" + } + }, + "pointer": { + "$ref": "#/definitions/types.Pointer" + } + } }, - "name": { - "type": "string", - "example": "space_name_1" + "types.CreateFileResp": { + "type": "object" }, - "namespace": { - "$ref": "#/definitions/types.Namespace" + "types.CreateJWTReq": { + "type": "object", + "required": [ + "uuid" + ], + "properties": { + "uuid": { + "type": "string" + } + } }, - "nickname": { - "type": "string", - "example": "" + "types.CreateJWTResp": { + "type": "object", + "properties": { + "expire_at": { + "type": "string" + }, + "token": { + "type": "string" + } + } }, - "path": { - "type": "string", - "example": "user_or_org_name/space_name_1" + "types.CreateMirrorParams": { + "type": "object", + "properties": { + "mirror_source_id": { + "type": "integer" + }, + "password": { + "type": "string" + }, + "source_url": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "types.CreateMirrorRepoReq": { + "type": "object", + "required": [ + "mirror_source_id", + "repo_type", + "source_name", + "source_namespace", + "source_url" + ], + "properties": { + "branch": { + "type": "string" + }, + "current_user": { + "type": "string" + }, + "description": { + "type": "string" + }, + "license": { + "type": "string" + }, + "mirror_source_id": { + "description": "source id for HF,github etc", + "type": "integer" + }, + "repo_type": { + "description": "repo basic info", + "allOf": [ + { + "$ref": "#/definitions/types.RepositoryType" + } + ] + }, + "source_name": { + "type": "string" + }, + "source_namespace": { + "type": "string" + }, + "source_url": { + "description": "mirror source info", + "type": "string" + }, + "sync_lfs": { + "type": "boolean" + } + } }, - "private": { - "type": "boolean" + "types.CreateMirrorSourceReq": { + "type": "object", + "required": [ + "source_name" + ], + "properties": { + "current_user": { + "type": "string" + }, + "info_api_url": { + "type": "string" + }, + "source_name": { + "type": "string" + } + } }, - "repository": { - "$ref": "#/definitions/types.Repository" + "types.CreateModelReq": { + "type": "object", + "properties": { + "base_model": { + "type": "string" + }, + "default_branch": { + "type": "string", + "example": "main" + }, + "description": { + "type": "string" + }, + "labels": { + "type": "string", + "example": "" + }, + "license": { + "type": "string", + "example": "MIT" + }, + "name": { + "type": "string", + "example": "model_name_1" + }, + "namespace": { + "type": "string", + "example": "user_or_org_name" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + } + } }, - "repository_id": { - "type": "integer" + "types.CreateOrgReq": { + "type": "object", + "properties": { + "description": { + "type": "string", + "example": "org description" + }, + "homepage": { + "type": "string", + "example": "https://www.example.com" + }, + "logo": { + "type": "string", + "example": "https://www.example.com/logo.png" + }, + "name": { + "description": "Org unique identifier", + "type": "string", + "example": "org_name_1" + }, + "nickname": { + "description": "Display name", + "type": "string", + "example": "org_display_name" + }, + "org_type": { + "type": "string", + "example": "company or school etc" + }, + "verified": { + "type": "boolean", + "example": false + } + } }, - "sdk": { - "description": "like gradio,steamlit etc", - "type": "string", - "example": "1" + "types.CreatePromptRepoReq": { + "type": "object", + "properties": { + "default_branch": { + "type": "string", + "example": "main" + }, + "description": { + "type": "string" + }, + "labels": { + "type": "string", + "example": "" + }, + "license": { + "type": "string", + "example": "MIT" + }, + "name": { + "type": "string", + "example": "model_name_1" + }, + "namespace": { + "type": "string", + "example": "user_or_org_name" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + } + } }, - "sdk_version": { - "type": "string", - "example": "v0.1" + "types.CreateRepoDiscussionRequest": { + "type": "object", + "required": [ + "title" + ], + "properties": { + "title": { + "type": "string" + } + } }, - "secrets": { - "type": "string" + "types.CreateSSHKeyRequest": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "name": { + "type": "string" + }, + "username": { + "type": "string" + } + } }, - "sensitive_check_status": { - "type": "string" + "types.CreateSpaceReq": { + "type": "object", + "properties": { + "cluster_id": { + "type": "string" + }, + "cover_image_url": { + "type": "string" + }, + "default_branch": { + "type": "string", + "example": "main" + }, + "description": { + "type": "string" + }, + "env": { + "type": "string" + }, + "labels": { + "type": "string", + "example": "" + }, + "license": { + "type": "string", + "example": "MIT" + }, + "name": { + "type": "string", + "example": "model_name_1" + }, + "namespace": { + "type": "string", + "example": "user_or_org_name" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + }, + "resource_id": { + "type": "integer" + }, + "sdk": { + "type": "string", + "example": "1" + }, + "sdk_version": { + "type": "string", + "example": "v0.1" + }, + "secrets": { + "type": "string" + }, + "template": { + "type": "string" + } + } }, - "sku": { - "type": "string" + "types.CreateSpaceResourceReq": { + "type": "object", + "required": [ + "cluster_id", + "name", + "resources" + ], + "properties": { + "cluster_id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "resources": { + "type": "string" + } + } }, - "source": { - "$ref": "#/definitions/types.RepositorySource" + "types.CreateSpaceSdkReq": { + "type": "object", + "required": [ + "name", + "version" + ], + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + } }, - "status": { - "description": "deploying, running, failed", - "type": "string" + "types.CreateSyncClientSettingReq": { + "type": "object", + "required": [ + "token" + ], + "properties": { + "concurrent_count": { + "type": "integer" + }, + "max_bandwidth": { + "type": "integer" + }, + "token": { + "type": "string" + } + } }, - "svc_name": { - "type": "string" + "types.CreateTag": { + "type": "object", + "required": [ + "category", + "name", + "scope" + ], + "properties": { + "built_in": { + "type": "boolean" + }, + "category": { + "type": "string" + }, + "group": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "show_name": { + "type": "string" + } + } }, - "sync_status": { - "$ref": "#/definitions/types.RepositorySyncStatus" + "types.CreateUserTokenRequest": { + "type": "object", + "properties": { + "application": { + "description": "default to csghub", + "allOf": [ + { + "$ref": "#/definitions/types.AccessTokenApp" + } + ] + }, + "expired_at": { + "type": "string" + }, + "name": { + "type": "string" + }, + "permission": { + "description": "default to empty, means full permission", + "type": "string" + } + } }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/types.RepoTag" - } + "types.Dataset": { + "type": "object", + "properties": { + "can_manage": { + "type": "boolean" + }, + "can_write": { + "type": "boolean" + }, + "created_at": { + "type": "string" + }, + "default_branch": { + "type": "string" + }, + "description": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "license": { + "type": "string" + }, + "likes": { + "type": "integer" + }, + "mirror_last_updated_at": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "$ref": "#/definitions/types.Namespace" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + }, + "repository": { + "$ref": "#/definitions/types.Repository" + }, + "repository_id": { + "type": "integer" + }, + "sensitive_check_status": { + "type": "string" + }, + "source": { + "$ref": "#/definitions/types.RepositorySource" + }, + "sync_status": { + "$ref": "#/definitions/types.RepositorySyncStatus" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/types.User" + }, + "user_likes": { + "type": "boolean" + } + } }, - "template": { - "type": "string" + "types.DatasetResp": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "updated_at": { + "type": "string" + } + } }, - "updated_at": { - "type": "string" + "types.DeleteOrgReq": { + "type": "object" }, - "user": { - "$ref": "#/definitions/types.User" + "types.DeleteUserTokenRequest": { + "type": "object", + "properties": { + "application": { + "description": "default to csghub", + "allOf": [ + { + "$ref": "#/definitions/types.AccessTokenApp" + } + ] + }, + "expired_at": { + "type": "string" + }, + "name": { + "type": "string" + }, + "permission": { + "description": "default to empty, means full permission", + "type": "string" + } + } }, - "user_likes": { - "type": "boolean" + "types.DeployUpdateReq": { + "type": "object", + "properties": { + "cluster_id": { + "type": "string" + }, + "deploy_name": { + "type": "string" + }, + "env": { + "type": "string" + }, + "max_replica": { + "type": "integer", + "minimum": 1 + }, + "min_replica": { + "type": "integer", + "minimum": 1 + }, + "resource_id": { + "type": "integer" + }, + "revision": { + "type": "string" + }, + "runtime_framework_id": { + "type": "integer" + }, + "secure_level": { + "type": "integer" + } + } }, - "username": { - "type": "string", - "example": "creator_user_name" - } - } - }, - "types.SpaceResource": { - "type": "object", - "properties": { - "id": { - "type": "integer" + "types.DiscussionResponse_Comment": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "user": { + "$ref": "#/definitions/types.DiscussionResponse_User" + } + } }, - "is_available": { - "type": "boolean" + "types.DiscussionResponse_User": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } }, - "name": { - "type": "string" + "types.EditOrgReq": { + "type": "object", + "properties": { + "description": { + "type": "string", + "example": "org description" + }, + "homepage": { + "type": "string", + "example": "https://www.example.com" + }, + "logo": { + "type": "string", + "example": "https://www.example.com/logo.png" + }, + "nickname": { + "description": "Display name", + "type": "string", + "example": "org display name" + }, + "org_type": { + "type": "string", + "example": "company or school etc" + }, + "verified": { + "type": "boolean", + "example": false + } + } }, - "resources": { - "type": "string" + "types.EvaluationReq": { + "type": "object", + "properties": { + "datasets": { + "type": "array", + "items": { + "type": "string" + } + }, + "model_id": { + "type": "string" + }, + "resource_id": { + "type": "integer" + }, + "runtime_framework_id": { + "description": "ArgoWorkFlow framework", + "type": "integer" + }, + "share_mode": { + "type": "boolean" + }, + "task_desc": { + "type": "string" + }, + "task_name": { + "type": "string" + } + } }, - "type": { - "$ref": "#/definitions/types.ResourceType" - } - } - }, - "types.SpaceSdk": { - "type": "object", - "properties": { - "id": { - "type": "integer" + "types.EvaluationRes": { + "type": "object", + "properties": { + "datasets": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTags" + } + }, + "download_url": { + "type": "string" + }, + "end_time": { + "type": "string" + }, + "failures_url": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "image": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "repo_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "repo_type": { + "type": "string" + }, + "resource_id": { + "type": "integer" + }, + "result_url": { + "type": "string" + }, + "start_time": { + "type": "string" + }, + "status": { + "type": "string" + }, + "submit_time": { + "type": "string" + }, + "task_desc": { + "type": "string" + }, + "task_id": { + "type": "string" + }, + "task_name": { + "type": "string" + }, + "task_type": { + "$ref": "#/definitions/types.TaskType" + }, + "username": { + "type": "string" + } + } }, - "name": { - "type": "string" + "types.Event": { + "type": "object", + "properties": { + "c_id": { + "type": "string", + "example": "" + }, + "c_ip": { + "type": "string", + "example": "" + }, + "ext": { + "description": "reserved for future use", + "type": "string", + "example": "" + }, + "id": { + "type": "string", + "example": "space_card" + }, + "m": { + "type": "string", + "example": "space" + }, + "v": { + "type": "string", + "example": "1" + } + } }, - "version": { - "type": "string" - } - } - }, - "types.SyncVersion": { - "type": "object", - "properties": { - "change_log": { - "type": "string" + "types.File": { + "type": "object", + "properties": { + "commit": { + "$ref": "#/definitions/types.Commit" + }, + "content": { + "type": "string" + }, + "last_commit_sha": { + "type": "string" + }, + "lfs": { + "type": "boolean" + }, + "lfs_pointer_size": { + "type": "integer" + }, + "lfs_relative_path": { + "description": "relative path in lfs storage", + "type": "string" + }, + "mode": { + "type": "string" + }, + "name": { + "type": "string" + }, + "path": { + "type": "string" + }, + "sha": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "type": { + "type": "string" + }, + "url": { + "description": "URL to browse the file", + "type": "string" + } + } }, - "last_modify_time": { - "type": "string" + "types.GetRepoFileTreeResp": { + "type": "object", + "properties": { + "cursor": { + "type": "string" + }, + "files": { + "type": "array", + "items": { + "$ref": "#/definitions/types.File" + } + } + } }, - "repo_path": { - "type": "string" + "types.InstanceRunReq": { + "type": "object", + "properties": { + "cluster_id": { + "type": "string" + }, + "deploy_name": { + "type": "string" + }, + "resource_id": { + "type": "integer" + }, + "revision": { + "type": "string" + }, + "runtime_framework_id": { + "type": "integer" + } + } }, - "repo_type": { - "$ref": "#/definitions/types.RepositoryType" + "types.ListByPathReq": { + "type": "object", + "properties": { + "paths": { + "type": "array", + "items": { + "type": "string" + } + } + } }, - "source_id": { - "description": "0: opencsg, 1: HF", - "type": "integer" + "types.ListRepoDiscussionResponse": { + "type": "object", + "properties": { + "discussions": { + "type": "array", + "items": { + "$ref": "#/definitions/types.CreateDiscussionResponse" + } + } + } }, - "version": { - "type": "integer" - } - } - }, - "types.SyncVersionResponse": { - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "has_more": { - "type": "boolean" - }, - "versions": { - "type": "array", - "items": { - "$ref": "#/definitions/types.SyncVersion" - } + "types.LogsTreeResp": { + "type": "object", + "properties": { + "commits": { + "type": "array", + "items": { + "$ref": "#/definitions/types.CommitForTree" + } + } } - } }, - "msg": { - "type": "string" - } - } - }, - "types.TaskType": { - "type": "string", - "enum": ["evaluation", "training", "comparison", "leaderboard"], - "x-enum-varnames": [ - "TaskTypeEvaluation", - "TaskTypeTraining", - "TaskTypeComparison", - "TaskTypeLeaderBoard" - ] - }, - "types.UpdateCategory": { - "type": "object", - "required": ["name", "scope"], - "properties": { - "enabled": { - "type": "boolean" + "types.Member": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "last_login_at": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "role": { + "type": "string" + }, + "username": { + "type": "string" + }, + "uuid": { + "type": "string" + } + } }, - "name": { - "type": "string" + "types.Mirror": { + "type": "object", + "properties": { + "access_token": { + "description": "source access token", + "type": "string" + }, + "last_message": { + "type": "string" + }, + "last_updated_at": { + "type": "string" + }, + "local_repo_path": { + "type": "string" + }, + "mirror_source": { + "$ref": "#/definitions/types.MirrorSource" + }, + "progress": { + "type": "integer" + }, + "push_access_token": { + "type": "string" + }, + "push_url": { + "type": "string" + }, + "push_username": { + "type": "string" + }, + "repository": { + "$ref": "#/definitions/types.Repository" + }, + "source_repo_path": { + "type": "string" + }, + "source_url": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/types.MirrorTaskStatus" + }, + "username": { + "description": "source user name", + "type": "string" + } + } }, - "scope": { - "type": "string" + "types.MirrorPriority": { + "type": "integer", + "enum": [ + 3, + 2, + 1 + ], + "x-enum-varnames": [ + "HighMirrorPriority", + "MediumMirrorPriority", + "LowMirrorPriority" + ] + }, + "types.MirrorRepo": { + "type": "object", + "properties": { + "path": { + "type": "string" + }, + "progress": { + "type": "integer" + }, + "repo_type": { + "$ref": "#/definitions/types.RepositoryType" + }, + "sync_status": { + "$ref": "#/definitions/types.RepositorySyncStatus" + } + } + }, + "types.MirrorSource": { + "type": "object", + "properties": { + "source_name": { + "type": "string" + } + } + }, + "types.MirrorTaskStatus": { + "type": "string", + "enum": [ + "waiting", + "running", + "repo_synced", + "finished", + "failed", + "incomplete" + ], + "x-enum-varnames": [ + "MirrorWaiting", + "MirrorRunning", + "MirrorRepoSynced", + "MirrorFinished", + "MirrorFailed", + "MirrorIncomplete" + ] + }, + "types.Model": { + "type": "object", + "properties": { + "base_model": { + "type": "string" + }, + "can_manage": { + "type": "boolean" + }, + "can_write": { + "type": "boolean" + }, + "created_at": { + "type": "string" + }, + "default_branch": { + "type": "string" + }, + "description": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "enable_evaluation": { + "type": "boolean" + }, + "enable_finetune": { + "type": "boolean" + }, + "enable_inference": { + "type": "boolean" + }, + "id": { + "type": "integer" + }, + "license": { + "type": "string" + }, + "likes": { + "type": "integer" + }, + "mirror_last_updated_at": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "$ref": "#/definitions/types.Namespace" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + }, + "recom_op_weight": { + "type": "integer" + }, + "repository": { + "$ref": "#/definitions/types.Repository" + }, + "repository_id": { + "type": "integer" + }, + "sensitive_check_status": { + "type": "string" + }, + "source": { + "$ref": "#/definitions/types.RepositorySource" + }, + "status": { + "description": "url to interact with the model", + "type": "string", + "example": "RUNNING" + }, + "sync_status": { + "$ref": "#/definitions/types.RepositorySyncStatus" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/types.User" + }, + "user_likes": { + "type": "boolean" + }, + "widget_type": { + "description": "widget UI style: generation,chat", + "allOf": [ + { + "$ref": "#/definitions/types.ModelWidgetType" + } + ], + "example": "generation" + } + } }, - "show_name": { - "type": "string" - } - } - }, - "types.UpdateCodeReq": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean", - "example": false - } - } - }, - "types.UpdateCollectionReposReq": { - "type": "object", - "properties": { - "repo_ids": { - "type": "array", - "items": { - "type": "integer" - } - } - } - }, - "types.UpdateCommentRequest": { - "type": "object", - "required": ["content"], - "properties": { - "content": { - "type": "string" - } - } - }, - "types.UpdateDatasetReq": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean", - "example": false - } - } - }, - "types.UpdateDiscussionRequest": { - "type": "object", - "required": ["title"], - "properties": { - "title": { - "type": "string" - } - } - }, - "types.UpdateFileReq": { - "type": "object", - "properties": { - "branch": { - "type": "string" + "types.ModelResp": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "updated_at": { + "type": "string" + } + } }, - "content": { - "type": "string" + "types.ModelRunReq": { + "type": "object", + "properties": { + "cluster_id": { + "type": "string" + }, + "deploy_name": { + "type": "string" + }, + "env": { + "type": "string" + }, + "max_replica": { + "type": "integer" + }, + "min_replica": { + "type": "integer" + }, + "resource_id": { + "type": "integer" + }, + "revision": { + "type": "string" + }, + "runtime_framework_id": { + "type": "integer" + }, + "secure_level": { + "type": "integer" + } + } }, - "message": { - "type": "string" + "types.ModelWidgetType": { + "type": "string", + "enum": [ + "generation", + "chat" + ], + "x-enum-varnames": [ + "ModelWidgetTypeGeneration", + "ModelWidgetTypeChat" + ] }, - "new_branch": { - "type": "string" + "types.Namespace": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "path": { + "type": "string" + }, + "type": { + "description": "namespace types like 'user' for normal user, and 'school', 'company' for orgs etc.", + "type": "string" + } + } }, - "origin_path": { - "type": "string" + "types.Organization": { + "type": "object", + "properties": { + "homepage": { + "type": "string" + }, + "logo": { + "type": "string" + }, + "name": { + "type": "string" + }, + "org_type": { + "type": "string" + }, + "path": { + "description": "unique name of the organization", + "type": "string" + }, + "user_id": { + "type": "integer" + }, + "verified": { + "type": "boolean" + } + } }, - "original_content": { - "description": "Use for lfs file", - "type": "array", - "items": { - "type": "integer" - } + "types.Pointer": { + "type": "object", + "properties": { + "download_url": { + "type": "string" + }, + "oid": { + "type": "string" + }, + "size": { + "type": "integer" + } + } }, - "pointer": { - "$ref": "#/definitions/types.Pointer" + "types.PromptRes": { + "type": "object", + "properties": { + "can_manage": { + "type": "boolean" + }, + "can_write": { + "type": "boolean" + }, + "created_at": { + "type": "string" + }, + "default_branch": { + "type": "string" + }, + "description": { + "type": "string" + }, + "downloads": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "license": { + "type": "string" + }, + "likes": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "namespace": { + "$ref": "#/definitions/types.Namespace" + }, + "nickname": { + "type": "string" + }, + "path": { + "type": "string" + }, + "private": { + "type": "boolean" + }, + "readme": { + "type": "string" + }, + "repository": { + "$ref": "#/definitions/types.Repository" + }, + "repository_id": { + "type": "integer" + }, + "source": { + "$ref": "#/definitions/types.RepositorySource" + }, + "sync_status": { + "$ref": "#/definitions/types.RepositorySyncStatus" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/types.User" + }, + "user_likes": { + "type": "boolean" + } + } }, - "repoType": { - "$ref": "#/definitions/types.RepositoryType" + "types.RelationDataset": { + "type": "object", + "properties": { + "dataset": { + "type": "string" + } + } }, - "sha": { - "type": "string" - } - } - }, - "types.UpdateFileResp": { - "type": "object" - }, - "types.UpdateMirrorParams": { - "type": "object", - "properties": { - "mirror_source_id": { - "type": "integer" + "types.RelationDatasets": { + "type": "object", + "properties": { + "datasets": { + "type": "array", + "items": { + "type": "string" + } + } + } }, - "password": { - "type": "string" + "types.RelationModel": { + "type": "object", + "properties": { + "model": { + "type": "string" + } + } }, - "source_url": { - "type": "string" + "types.RelationModels": { + "type": "object", + "properties": { + "models": { + "type": "array", + "items": { + "type": "string" + } + } + } }, - "username": { - "type": "string" - } - } - }, - "types.UpdateMirrorSourceReq": { - "type": "object", - "required": ["source_name"], - "properties": { - "current_user": { - "type": "string" + "types.Relations": { + "type": "object", + "properties": { + "codes": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Code" + } + }, + "datasets": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Dataset" + } + }, + "models": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Model" + } + }, + "prompts": { + "type": "array", + "items": { + "$ref": "#/definitions/types.PromptRes" + } + }, + "spaces": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Space" + } + } + } }, - "id": { - "type": "integer" + "types.RepoBranchCommit": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } }, - "info_api_url": { - "type": "string" + "types.RepoTag": { + "type": "object", + "properties": { + "built_in": { + "type": "boolean" + }, + "category": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "group": { + "type": "string" + }, + "name": { + "type": "string" + }, + "show_name": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + } }, - "source_name": { - "type": "string" - } - } - }, - "types.UpdateModelReq": { - "type": "object", - "properties": { - "base_model": { - "type": "string" - }, - "description": { - "type": "string" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean", - "example": false - } - } - }, - "types.UpdatePromptRepoReq": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "nickname": { - "type": "string", - "example": "model display name" - }, - "private": { - "type": "boolean", - "example": false - } - } - }, - "types.UpdateSpaceReq": { - "type": "object", - "properties": { - "cover_image_url": { - "type": "string" + "types.RepoTags": { + "type": "object", + "properties": { + "repo_id": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + } + } }, - "description": { - "type": "string" + "types.Repository": { + "type": "object", + "properties": { + "http_clone_url": { + "type": "string" + }, + "ssh_clone_url": { + "type": "string" + } + } + }, + "types.RepositorySource": { + "type": "string", + "enum": [ + "opencsg", + "local", + "huggingface" + ], + "x-enum-varnames": [ + "OpenCSGSource", + "LocalSource", + "HuggingfaceSource" + ] + }, + "types.RepositorySyncStatus": { + "type": "string", + "enum": [ + "pending", + "inprogress", + "failed", + "completed" + ], + "x-enum-varnames": [ + "SyncStatusPending", + "SyncStatusInProgress", + "SyncStatusFailed", + "SyncStatusCompleted" + ] + }, + "types.RepositoryType": { + "type": "string", + "enum": [ + "model", + "dataset", + "space", + "code", + "prompt", + "" + ], + "x-enum-varnames": [ + "ModelRepo", + "DatasetRepo", + "SpaceRepo", + "CodeRepo", + "PromptRepo", + "UnknownRepo" + ] + }, + "types.ResourceType": { + "type": "string", + "enum": [ + "cpu", + "gpu" + ], + "x-enum-varnames": [ + "ResourceTypeCPU", + "ResourceTypeGPU" + ] + }, + "types.Response": { + "type": "object", + "properties": { + "data": {}, + "msg": { + "type": "string" + } + } + }, + "types.ResponseWithTotal": { + "type": "object", + "properties": { + "data": {}, + "msg": { + "type": "string" + }, + "total": { + "type": "integer" + } + } }, - "env": { - "type": "string" + "types.RuntimeArchitecture": { + "type": "object", + "properties": { + "architectures": { + "type": "array", + "items": { + "type": "string" + } + } + } }, - "nickname": { - "type": "string", - "example": "model display name" + "types.RuntimeFramework": { + "type": "object", + "properties": { + "container_port": { + "type": "integer" + }, + "enabled": { + "type": "integer" + }, + "frame_cpu_image": { + "type": "string" + }, + "frame_image": { + "type": "string" + }, + "frame_name": { + "type": "string" + }, + "frame_version": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "type": { + "type": "integer" + } + } }, - "private": { - "type": "boolean", - "example": false + "types.RuntimeFrameworkModels": { + "type": "object", + "properties": { + "models": { + "type": "array", + "items": { + "type": "string" + } + } + } }, - "resource_id": { - "type": "integer" + "types.RuntimeFrameworkReq": { + "type": "object", + "properties": { + "container_port": { + "type": "integer" + }, + "enabled": { + "type": "integer" + }, + "frame_cpu_image": { + "type": "string" + }, + "frame_image": { + "type": "string" + }, + "frame_name": { + "type": "string" + }, + "frame_version": { + "type": "string" + }, + "type": { + "type": "integer" + } + } }, - "sdk": { - "type": "string", - "example": "1" + "types.SensitiveCheckStatus": { + "type": "integer", + "enum": [ + -1, + 0, + 1, + 2, + 3 + ], + "x-enum-comments": { + "SensitiveCheckException": "error happen", + "SensitiveCheckFail": "sensitive content detected", + "SensitiveCheckPass": "pass", + "SensitiveCheckPending": "default", + "SensitiveCheckSkip": "skip" + }, + "x-enum-varnames": [ + "SensitiveCheckFail", + "SensitiveCheckPending", + "SensitiveCheckPass", + "SensitiveCheckSkip", + "SensitiveCheckException" + ] + }, + "types.ShowDiscussionResponse": { + "type": "object", + "properties": { + "comment_count": { + "type": "integer" + }, + "comments": { + "type": "array", + "items": { + "$ref": "#/definitions/types.DiscussionResponse_Comment" + } + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/types.DiscussionResponse_User" + } + } }, - "sdk_version": { - "type": "string", - "example": "v0.1" + "types.Space": { + "type": "object", + "properties": { + "can_manage": { + "type": "boolean" + }, + "can_write": { + "type": "boolean" + }, + "cover_image_url": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "default_branch": { + "type": "string" + }, + "description": { + "type": "string", + "example": "" + }, + "endpoint": { + "description": "the serving endpoint url", + "type": "string", + "example": "https://localhost/spaces/myname/myspace" + }, + "env": { + "type": "string" + }, + "hardware": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "license": { + "type": "string", + "example": "MIT" + }, + "like_count": { + "type": "integer" + }, + "name": { + "type": "string", + "example": "space_name_1" + }, + "namespace": { + "$ref": "#/definitions/types.Namespace" + }, + "nickname": { + "type": "string", + "example": "" + }, + "path": { + "type": "string", + "example": "user_or_org_name/space_name_1" + }, + "private": { + "type": "boolean" + }, + "repository": { + "$ref": "#/definitions/types.Repository" + }, + "repository_id": { + "type": "integer" + }, + "sdk": { + "description": "like gradio,steamlit etc", + "type": "string", + "example": "1" + }, + "sdk_version": { + "type": "string", + "example": "v0.1" + }, + "secrets": { + "type": "string" + }, + "sensitive_check_status": { + "type": "string" + }, + "sku": { + "type": "string" + }, + "source": { + "$ref": "#/definitions/types.RepositorySource" + }, + "status": { + "description": "deploying, running, failed", + "type": "string" + }, + "svc_name": { + "type": "string" + }, + "sync_status": { + "$ref": "#/definitions/types.RepositorySyncStatus" + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/types.RepoTag" + } + }, + "template": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/types.User" + }, + "user_likes": { + "type": "boolean" + }, + "username": { + "type": "string", + "example": "creator_user_name" + } + } }, - "secrets": { - "type": "string" + "types.SpaceResource": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "is_available": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "resources": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/types.ResourceType" + } + } }, - "template": { - "type": "string" - } - } - }, - "types.UpdateSpaceResourceReq": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "resources": { - "type": "string" - } - } - }, - "types.UpdateSpaceSdkReq": { - "type": "object", - "properties": { - "id": { - "type": "integer" + "types.SpaceSdk": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + } }, - "name": { - "type": "string" + "types.SyncVersion": { + "type": "object", + "properties": { + "change_log": { + "type": "string" + }, + "last_modify_time": { + "type": "string" + }, + "repo_path": { + "type": "string" + }, + "repo_type": { + "$ref": "#/definitions/types.RepositoryType" + }, + "source_id": { + "description": "0: opencsg, 1: HF", + "type": "integer" + }, + "version": { + "type": "integer" + } + } }, - "version": { - "type": "string" - } - } - }, - "types.UpdateTag": { - "type": "object", - "required": ["category", "name", "scope"], - "properties": { - "built_in": { - "type": "boolean" + "types.SyncVersionResponse": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "has_more": { + "type": "boolean" + }, + "versions": { + "type": "array", + "items": { + "$ref": "#/definitions/types.SyncVersion" + } + } + } + }, + "msg": { + "type": "string" + } + } + }, + "types.TaskType": { + "type": "string", + "enum": [ + "evaluation", + "training", + "comparison", + "leaderboard" + ], + "x-enum-varnames": [ + "TaskTypeEvaluation", + "TaskTypeTraining", + "TaskTypeComparison", + "TaskTypeLeaderBoard" + ] + }, + "types.UpdateCategory": { + "type": "object", + "required": [ + "name", + "scope" + ], + "properties": { + "enabled": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "show_name": { + "type": "string" + } + } }, - "category": { - "type": "string" + "types.UpdateCodeReq": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean", + "example": false + } + } }, - "group": { - "type": "string" + "types.UpdateCollectionReposReq": { + "type": "object", + "properties": { + "repo_ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } }, - "name": { - "type": "string" + "types.UpdateCommentRequest": { + "type": "object", + "required": [ + "content" + ], + "properties": { + "content": { + "type": "string" + } + } }, - "scope": { - "type": "string" + "types.UpdateDatasetReq": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean", + "example": false + } + } }, - "show_name": { - "type": "string" - } - } - }, - "types.UpdateUserRequest": { - "type": "object", - "properties": { - "avatar": { - "type": "string" - }, - "bio": { - "type": "string" - }, - "email": { - "type": "string" - }, - "homepage": { - "type": "string" - }, - "name": { - "description": "Display name of the user", - "type": "string" - }, - "new_username": { - "description": "if use want to change username, this should be the only field to send in request body", - "type": "string" - }, - "phone": { - "type": "string" - }, - "roles": { - "description": "should be updated by admin", - "type": "array", - "items": { - "type": "string" - }, - "example": ["[super_user", " admin", " personal_user]"] - }, - "uuid": { - "type": "string" - } - } - }, - "types.User": { - "type": "object", - "properties": { - "avatar": { - "type": "string" + "types.UpdateDiscussionRequest": { + "type": "object", + "required": [ + "title" + ], + "properties": { + "title": { + "type": "string" + } + } }, - "bio": { - "type": "string" + "types.UpdateFileReq": { + "type": "object", + "properties": { + "branch": { + "type": "string" + }, + "content": { + "type": "string" + }, + "message": { + "type": "string" + }, + "new_branch": { + "type": "string" + }, + "origin_path": { + "type": "string" + }, + "original_content": { + "description": "Use for lfs file", + "type": "array", + "items": { + "type": "integer" + } + }, + "pointer": { + "$ref": "#/definitions/types.Pointer" + }, + "repoType": { + "$ref": "#/definitions/types.RepositoryType" + }, + "sha": { + "type": "string" + } + } }, - "can_change_username": { - "type": "boolean" + "types.UpdateFileResp": { + "type": "object" }, - "email": { - "type": "string" + "types.UpdateMirrorParams": { + "type": "object", + "properties": { + "mirror_source_id": { + "type": "integer" + }, + "password": { + "type": "string" + }, + "source_url": { + "type": "string" + }, + "username": { + "type": "string" + } + } }, - "homepage": { - "type": "string" + "types.UpdateMirrorSourceReq": { + "type": "object", + "required": [ + "source_name" + ], + "properties": { + "current_user": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "info_api_url": { + "type": "string" + }, + "source_name": { + "type": "string" + } + } }, - "id": { - "type": "integer" + "types.UpdateModelReq": { + "type": "object", + "properties": { + "base_model": { + "type": "string" + }, + "description": { + "type": "string" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean", + "example": false + } + } }, - "last_login_at": { - "type": "string" + "types.UpdatePromptRepoReq": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean", + "example": false + } + } }, - "nickname": { - "type": "string" + "types.UpdateSpaceReq": { + "type": "object", + "properties": { + "cover_image_url": { + "type": "string" + }, + "description": { + "type": "string" + }, + "env": { + "type": "string" + }, + "nickname": { + "type": "string", + "example": "model display name" + }, + "private": { + "type": "boolean", + "example": false + }, + "resource_id": { + "type": "integer" + }, + "sdk": { + "type": "string", + "example": "1" + }, + "sdk_version": { + "type": "string", + "example": "v0.1" + }, + "secrets": { + "type": "string" + }, + "template": { + "type": "string" + } + } }, - "orgs": { - "type": "array", - "items": { - "$ref": "#/definitions/types.Organization" - } + "types.UpdateSpaceResourceReq": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "resources": { + "type": "string" + } + } }, - "phone": { - "type": "string" + "types.UpdateSpaceSdkReq": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + } }, - "roles": { - "type": "array", - "items": { - "type": "string" - } + "types.UpdateTag": { + "type": "object", + "required": [ + "category", + "name", + "scope" + ], + "properties": { + "built_in": { + "type": "boolean" + }, + "category": { + "type": "string" + }, + "group": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "show_name": { + "type": "string" + } + } }, - "username": { - "type": "string" + "types.UpdateUserRequest": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "email": { + "type": "string" + }, + "homepage": { + "type": "string" + }, + "name": { + "description": "Display name of the user", + "type": "string" + }, + "new_username": { + "description": "if use want to change username, this should be the only field to send in request body", + "type": "string" + }, + "phone": { + "type": "string" + }, + "roles": { + "description": "should be updated by admin", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "[super_user", + " admin", + " personal_user]" + ] + }, + "uuid": { + "type": "string" + } + } }, - "uuid": { - "type": "string" + "types.User": { + "type": "object", + "properties": { + "avatar": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "can_change_username": { + "type": "boolean" + }, + "email": { + "type": "string" + }, + "homepage": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "last_login_at": { + "type": "string" + }, + "nickname": { + "type": "string" + }, + "orgs": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Organization" + } + }, + "phone": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "string" + } + }, + "username": { + "type": "string" + }, + "uuid": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "ApiKey": { + "description": "Bearer token", + "type": "apiKey", + "name": "Authorization", + "in": "header" } - } - } - }, - "securityDefinitions": { - "ApiKey": { - "description": "Bearer token", - "type": "apiKey", - "name": "Authorization", - "in": "header" } - } -} +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 29be7c4d..be0819e2 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3,8 +3,8 @@ definitions: properties: application: allOf: - - $ref: "#/definitions/types.AccessTokenApp" - description: "example: csghub, starship" + - $ref: '#/definitions/types.AccessTokenApp' + description: 'example: csghub, starship' created_at: type: string expired_at: @@ -24,7 +24,7 @@ definitions: updated_at: type: string user: - $ref: "#/definitions/database.User" + $ref: '#/definitions/database.User' user_id: type: integer type: object @@ -37,7 +37,7 @@ definitions: last_updated_at: type: string repository: - $ref: "#/definitions/database.Repository" + $ref: '#/definitions/database.Repository' repository_id: type: integer updated_at: @@ -63,7 +63,7 @@ definitions: type: boolean repositories: items: - $ref: "#/definitions/database.Repository" + $ref: '#/definitions/database.Repository' type: array theme: type: string @@ -83,7 +83,7 @@ definitions: last_updated_at: type: string repository: - $ref: "#/definitions/database.Repository" + $ref: '#/definitions/database.Repository' repository_id: type: integer updated_at: @@ -104,7 +104,7 @@ definitions: local_repo_path: type: string mirror_source: - $ref: "#/definitions/database.MirrorSource" + $ref: '#/definitions/database.MirrorSource' mirror_source_id: type: integer mirror_task_id: @@ -112,13 +112,13 @@ definitions: next_execution_timestamp: type: string priority: - $ref: "#/definitions/types.MirrorPriority" + $ref: '#/definitions/types.MirrorPriority' progress: type: integer push_mirror_created: type: boolean repository: - $ref: "#/definitions/database.Repository" + $ref: '#/definitions/database.Repository' repository_id: type: integer source_repo_path: @@ -126,7 +126,7 @@ definitions: source_url: type: string status: - $ref: "#/definitions/types.MirrorTaskStatus" + $ref: '#/definitions/types.MirrorTaskStatus' updated_at: type: string type: object @@ -154,7 +154,7 @@ definitions: last_updated_at: type: string repository: - $ref: "#/definitions/database.Repository" + $ref: '#/definitions/database.Repository' repository_id: type: integer updated_at: @@ -169,24 +169,24 @@ definitions: mirrored: type: boolean namespace_type: - $ref: "#/definitions/database.NamespaceType" + $ref: '#/definitions/database.NamespaceType' path: type: string updated_at: type: string user: - $ref: "#/definitions/database.User" + $ref: '#/definitions/database.User' user_id: type: integer type: object database.NamespaceType: enum: - - user - - organization + - user + - organization type: string x-enum-varnames: - - UserNamespace - - OrgNamespace + - UserNamespace + - OrgNamespace database.Organization: properties: created_at: @@ -204,7 +204,7 @@ definitions: name: type: string namespace: - $ref: "#/definitions/database.Namespace" + $ref: '#/definitions/database.Namespace' namespace_id: type: integer org_type: @@ -215,7 +215,7 @@ definitions: updated_at: type: string user: - $ref: "#/definitions/database.User" + $ref: '#/definitions/database.User' user_id: type: integer verified: @@ -233,7 +233,7 @@ definitions: type: integer downloads: items: - $ref: "#/definitions/database.RepositoryDownload" + $ref: '#/definitions/database.RepositoryDownload' type: array git_path: type: string @@ -249,7 +249,7 @@ definitions: likes: type: integer mirror: - $ref: "#/definitions/database.Mirror" + $ref: '#/definitions/database.Mirror' name: type: string nickname: @@ -262,23 +262,23 @@ definitions: description: Depreated type: string repository_type: - $ref: "#/definitions/types.RepositoryType" + $ref: '#/definitions/types.RepositoryType' sensitive_check_status: - $ref: "#/definitions/types.SensitiveCheckStatus" + $ref: '#/definitions/types.SensitiveCheckStatus' source: - $ref: "#/definitions/types.RepositorySource" + $ref: '#/definitions/types.RepositorySource' ssh_clone_url: type: string sync_status: - $ref: "#/definitions/types.RepositorySyncStatus" + $ref: '#/definitions/types.RepositorySyncStatus' tags: items: - $ref: "#/definitions/database.Tag" + $ref: '#/definitions/database.Tag' type: array updated_at: type: string user: - $ref: "#/definitions/database.User" + $ref: '#/definitions/database.User' user_id: type: integer type: object @@ -293,7 +293,7 @@ definitions: id: type: integer repository: - $ref: "#/definitions/database.Repository" + $ref: '#/definitions/database.Repository' repository_id: type: integer updated_at: @@ -318,7 +318,7 @@ definitions: updated_at: type: string user: - $ref: "#/definitions/database.User" + $ref: '#/definitions/database.User' user_id: type: integer type: object @@ -354,7 +354,7 @@ definitions: name: type: string scope: - $ref: "#/definitions/database.TagScope" + $ref: '#/definitions/database.TagScope' show_name: type: string updated_at: @@ -369,29 +369,29 @@ definitions: name: type: string scope: - $ref: "#/definitions/database.TagScope" + $ref: '#/definitions/database.TagScope' show_name: type: string type: object database.TagScope: enum: - - model - - dataset - - code - - space - - prompt + - model + - dataset + - code + - space + - prompt type: string x-enum-varnames: - - ModelTagScope - - DatasetTagScope - - CodeTagScope - - SpaceTagScope - - PromptTagScope + - ModelTagScope + - DatasetTagScope + - CodeTagScope + - SpaceTagScope + - PromptTagScope database.User: properties: accessTokens: items: - $ref: "#/definitions/database.AccessToken" + $ref: '#/definitions/database.AccessToken' type: array avatar: type: string @@ -422,7 +422,7 @@ definitions: type: string namespace: items: - $ref: "#/definitions/database.Namespace" + $ref: '#/definitions/database.Namespace' type: array password_hash: description: password for user registered without casdoor @@ -457,15 +457,15 @@ definitions: example: user1,user2 type: string required: - - role - - users + - role + - users type: object handler.Delete.removeMemberRequest: properties: role: type: string required: - - role + - role type: object handler.SetOpWeight.SetOpWeightReq: properties: @@ -474,8 +474,8 @@ definitions: weight: type: integer required: - - repo_id - - weight + - repo_id + - weight type: object handler.Update.updateMemberRequest: properties: @@ -484,8 +484,8 @@ definitions: old_role: type: string required: - - new_role - - old_role + - new_role + - old_role type: object telemetry.Counts: properties: @@ -535,7 +535,7 @@ definitions: active_user_count: type: integer counts: - $ref: "#/definitions/telemetry.Counts" + $ref: '#/definitions/telemetry.Counts' edition: type: string historical_max_users: @@ -562,11 +562,11 @@ definitions: license_user_count: type: integer licensee: - $ref: "#/definitions/telemetry.Licensee" + $ref: '#/definitions/telemetry.Licensee' recorded_at: type: string settings: - $ref: "#/definitions/telemetry.Settings" + $ref: '#/definitions/telemetry.Settings' uuid: type: string version: @@ -582,20 +582,20 @@ definitions: type: object types.AccessTokenApp: enum: - - git - - git - - mirror - - starship + - git + - git + - mirror + - starship type: string x-enum-varnames: - - AccessTokenAppGit - - AccessTokenAppCSGHub - - AccessTokenAppMirror - - AccessTokenAppStarship + - AccessTokenAppGit + - AccessTokenAppCSGHub + - AccessTokenAppMirror + - AccessTokenAppStarship types.Branch: properties: commit: - $ref: "#/definitions/types.RepoBranchCommit" + $ref: '#/definitions/types.RepoBranchCommit' message: type: string name: @@ -624,7 +624,7 @@ definitions: name: type: string namespace: - $ref: "#/definitions/types.Namespace" + $ref: '#/definitions/types.Namespace' nickname: type: string path: @@ -632,23 +632,23 @@ definitions: private: type: boolean repository: - $ref: "#/definitions/types.Repository" + $ref: '#/definitions/types.Repository' repository_id: type: integer sensitive_check_status: type: string source: - $ref: "#/definitions/types.RepositorySource" + $ref: '#/definitions/types.RepositorySource' sync_status: - $ref: "#/definitions/types.RepositorySyncStatus" + $ref: '#/definitions/types.RepositorySyncStatus' tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array updated_at: type: string user: - $ref: "#/definitions/types.User" + $ref: '#/definitions/types.User' user_likes: type: boolean type: object @@ -678,7 +678,7 @@ definitions: type: boolean repositories: items: - $ref: "#/definitions/types.CollectionRepository" + $ref: '#/definitions/types.CollectionRepository' type: array theme: type: string @@ -710,12 +710,12 @@ definitions: private: type: boolean repository_type: - $ref: "#/definitions/types.RepositoryType" + $ref: '#/definitions/types.RepositoryType' status: type: string tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array updated_at: type: string @@ -803,10 +803,10 @@ definitions: type: string parents: items: - $ref: "#/definitions/types.CommitMeta" + $ref: '#/definitions/types.CommitMeta' type: array stats: - $ref: "#/definitions/types.CommitStats" + $ref: '#/definitions/types.CommitStats' type: object types.CommitStats: properties: @@ -828,8 +828,8 @@ definitions: show_name: type: string required: - - name - - scope + - name + - scope type: object types.CreateCodeReq: properties: @@ -874,7 +874,7 @@ definitions: private: type: boolean theme: - example: "#fff000" + example: '#fff000' type: string type: object types.CreateCommentRequest: @@ -886,7 +886,7 @@ definitions: content: type: string required: - - content + - content type: object types.CreateCommentResponse: properties: @@ -899,7 +899,7 @@ definitions: id: type: integer user: - $ref: "#/definitions/types.DiscussionResponse_User" + $ref: '#/definitions/types.DiscussionResponse_User' type: object types.CreateDatasetReq: properties: @@ -944,7 +944,7 @@ definitions: title: type: string user: - $ref: "#/definitions/types.DiscussionResponse_User" + $ref: '#/definitions/types.DiscussionResponse_User' type: object types.CreateFileReq: properties: @@ -964,7 +964,7 @@ definitions: type: integer type: array pointer: - $ref: "#/definitions/types.Pointer" + $ref: '#/definitions/types.Pointer' type: object types.CreateFileResp: type: object @@ -973,7 +973,7 @@ definitions: uuid: type: string required: - - uuid + - uuid type: object types.CreateJWTResp: properties: @@ -1008,7 +1008,7 @@ definitions: type: integer repo_type: allOf: - - $ref: "#/definitions/types.RepositoryType" + - $ref: '#/definitions/types.RepositoryType' description: repo basic info source_name: type: string @@ -1020,11 +1020,11 @@ definitions: sync_lfs: type: boolean required: - - mirror_source_id - - repo_type - - source_name - - source_namespace - - source_url + - mirror_source_id + - repo_type + - source_name + - source_namespace + - source_url type: object types.CreateMirrorSourceReq: properties: @@ -1035,7 +1035,7 @@ definitions: source_name: type: string required: - - source_name + - source_name type: object types.CreateModelReq: properties: @@ -1124,7 +1124,7 @@ definitions: title: type: string required: - - title + - title type: object types.CreateSSHKeyRequest: properties: @@ -1189,9 +1189,9 @@ definitions: resources: type: string required: - - cluster_id - - name - - resources + - cluster_id + - name + - resources type: object types.CreateSpaceSdkReq: properties: @@ -1200,8 +1200,8 @@ definitions: version: type: string required: - - name - - version + - name + - version type: object types.CreateSyncClientSettingReq: properties: @@ -1212,7 +1212,7 @@ definitions: token: type: string required: - - token + - token type: object types.CreateTag: properties: @@ -1229,15 +1229,15 @@ definitions: show_name: type: string required: - - category - - name - - scope + - category + - name + - scope type: object types.CreateUserTokenRequest: properties: application: allOf: - - $ref: "#/definitions/types.AccessTokenApp" + - $ref: '#/definitions/types.AccessTokenApp' description: default to csghub expired_at: type: string @@ -1272,7 +1272,7 @@ definitions: name: type: string namespace: - $ref: "#/definitions/types.Namespace" + $ref: '#/definitions/types.Namespace' nickname: type: string path: @@ -1282,23 +1282,23 @@ definitions: readme: type: string repository: - $ref: "#/definitions/types.Repository" + $ref: '#/definitions/types.Repository' repository_id: type: integer sensitive_check_status: type: string source: - $ref: "#/definitions/types.RepositorySource" + $ref: '#/definitions/types.RepositorySource' sync_status: - $ref: "#/definitions/types.RepositorySyncStatus" + $ref: '#/definitions/types.RepositorySyncStatus' tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array updated_at: type: string user: - $ref: "#/definitions/types.User" + $ref: '#/definitions/types.User' user_likes: type: boolean type: object @@ -1318,7 +1318,7 @@ definitions: type: boolean tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array updated_at: type: string @@ -1329,7 +1329,7 @@ definitions: properties: application: allOf: - - $ref: "#/definitions/types.AccessTokenApp" + - $ref: '#/definitions/types.AccessTokenApp' description: default to csghub expired_at: type: string @@ -1371,7 +1371,7 @@ definitions: id: type: integer user: - $ref: "#/definitions/types.DiscussionResponse_User" + $ref: '#/definitions/types.DiscussionResponse_User' type: object types.DiscussionResponse_User: properties: @@ -1428,7 +1428,7 @@ definitions: properties: datasets: items: - $ref: "#/definitions/types.RepoTags" + $ref: '#/definitions/types.RepoTags' type: array download_url: type: string @@ -1465,7 +1465,7 @@ definitions: task_name: type: string task_type: - $ref: "#/definitions/types.TaskType" + $ref: '#/definitions/types.TaskType' username: type: string type: object @@ -1494,7 +1494,7 @@ definitions: types.File: properties: commit: - $ref: "#/definitions/types.Commit" + $ref: '#/definitions/types.Commit' content: type: string last_commit_sha: @@ -1528,7 +1528,7 @@ definitions: type: string files: items: - $ref: "#/definitions/types.File" + $ref: '#/definitions/types.File' type: array type: object types.InstanceRunReq: @@ -1555,14 +1555,14 @@ definitions: properties: discussions: items: - $ref: "#/definitions/types.CreateDiscussionResponse" + $ref: '#/definitions/types.CreateDiscussionResponse' type: array type: object types.LogsTreeResp: properties: commits: items: - $ref: "#/definitions/types.CommitForTree" + $ref: '#/definitions/types.CommitForTree' type: array type: object types.Member: @@ -1592,7 +1592,7 @@ definitions: local_repo_path: type: string mirror_source: - $ref: "#/definitions/types.MirrorSource" + $ref: '#/definitions/types.MirrorSource' progress: type: integer push_access_token: @@ -1602,27 +1602,27 @@ definitions: push_username: type: string repository: - $ref: "#/definitions/types.Repository" + $ref: '#/definitions/types.Repository' source_repo_path: type: string source_url: type: string status: - $ref: "#/definitions/types.MirrorTaskStatus" + $ref: '#/definitions/types.MirrorTaskStatus' username: description: source user name type: string type: object types.MirrorPriority: enum: - - 3 - - 2 - - 1 + - 3 + - 2 + - 1 type: integer x-enum-varnames: - - HighMirrorPriority - - MediumMirrorPriority - - LowMirrorPriority + - HighMirrorPriority + - MediumMirrorPriority + - LowMirrorPriority types.MirrorRepo: properties: path: @@ -1630,9 +1630,9 @@ definitions: progress: type: integer repo_type: - $ref: "#/definitions/types.RepositoryType" + $ref: '#/definitions/types.RepositoryType' sync_status: - $ref: "#/definitions/types.RepositorySyncStatus" + $ref: '#/definitions/types.RepositorySyncStatus' type: object types.MirrorSource: properties: @@ -1641,20 +1641,20 @@ definitions: type: object types.MirrorTaskStatus: enum: - - waiting - - running - - repo_synced - - finished - - failed - - incomplete + - waiting + - running + - repo_synced + - finished + - failed + - incomplete type: string x-enum-varnames: - - MirrorWaiting - - MirrorRunning - - MirrorRepoSynced - - MirrorFinished - - MirrorFailed - - MirrorIncomplete + - MirrorWaiting + - MirrorRunning + - MirrorRepoSynced + - MirrorFinished + - MirrorFailed + - MirrorIncomplete types.Model: properties: base_model: @@ -1688,7 +1688,7 @@ definitions: name: type: string namespace: - $ref: "#/definitions/types.Namespace" + $ref: '#/definitions/types.Namespace' nickname: type: string path: @@ -1700,33 +1700,33 @@ definitions: recom_op_weight: type: integer repository: - $ref: "#/definitions/types.Repository" + $ref: '#/definitions/types.Repository' repository_id: type: integer sensitive_check_status: type: string source: - $ref: "#/definitions/types.RepositorySource" + $ref: '#/definitions/types.RepositorySource' status: description: url to interact with the model example: RUNNING type: string sync_status: - $ref: "#/definitions/types.RepositorySyncStatus" + $ref: '#/definitions/types.RepositorySyncStatus' tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array updated_at: type: string user: - $ref: "#/definitions/types.User" + $ref: '#/definitions/types.User' user_likes: type: boolean widget_type: allOf: - - $ref: "#/definitions/types.ModelWidgetType" - description: "widget UI style: generation,chat" + - $ref: '#/definitions/types.ModelWidgetType' + description: 'widget UI style: generation,chat' example: generation type: object types.ModelResp: @@ -1745,7 +1745,7 @@ definitions: type: boolean tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array updated_at: type: string @@ -1773,12 +1773,12 @@ definitions: type: object types.ModelWidgetType: enum: - - generation - - chat + - generation + - chat type: string x-enum-varnames: - - ModelWidgetTypeGeneration - - ModelWidgetTypeChat + - ModelWidgetTypeGeneration + - ModelWidgetTypeChat types.Namespace: properties: avatar: @@ -1786,8 +1786,7 @@ definitions: path: type: string type: - description: - namespace types like 'user' for normal user, and 'school', 'company' + description: namespace types like 'user' for normal user, and 'school', 'company' for orgs etc. type: string type: object @@ -1841,7 +1840,7 @@ definitions: name: type: string namespace: - $ref: "#/definitions/types.Namespace" + $ref: '#/definitions/types.Namespace' nickname: type: string path: @@ -1851,21 +1850,21 @@ definitions: readme: type: string repository: - $ref: "#/definitions/types.Repository" + $ref: '#/definitions/types.Repository' repository_id: type: integer source: - $ref: "#/definitions/types.RepositorySource" + $ref: '#/definitions/types.RepositorySource' sync_status: - $ref: "#/definitions/types.RepositorySyncStatus" + $ref: '#/definitions/types.RepositorySyncStatus' tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array updated_at: type: string user: - $ref: "#/definitions/types.User" + $ref: '#/definitions/types.User' user_likes: type: boolean type: object @@ -1897,23 +1896,23 @@ definitions: properties: codes: items: - $ref: "#/definitions/types.Code" + $ref: '#/definitions/types.Code' type: array datasets: items: - $ref: "#/definitions/types.Dataset" + $ref: '#/definitions/types.Dataset' type: array models: items: - $ref: "#/definitions/types.Model" + $ref: '#/definitions/types.Model' type: array prompts: items: - $ref: "#/definitions/types.PromptRes" + $ref: '#/definitions/types.PromptRes' type: array spaces: items: - $ref: "#/definitions/types.Space" + $ref: '#/definitions/types.Space' type: array type: object types.RepoBranchCommit: @@ -1944,7 +1943,7 @@ definitions: type: string tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array type: object types.Repository: @@ -1956,50 +1955,50 @@ definitions: type: object types.RepositorySource: enum: - - opencsg - - local - - huggingface + - opencsg + - local + - huggingface type: string x-enum-varnames: - - OpenCSGSource - - LocalSource - - HuggingfaceSource + - OpenCSGSource + - LocalSource + - HuggingfaceSource types.RepositorySyncStatus: enum: - - pending - - inprogress - - failed - - completed + - pending + - inprogress + - failed + - completed type: string x-enum-varnames: - - SyncStatusPending - - SyncStatusInProgress - - SyncStatusFailed - - SyncStatusCompleted + - SyncStatusPending + - SyncStatusInProgress + - SyncStatusFailed + - SyncStatusCompleted types.RepositoryType: enum: - - model - - dataset - - space - - code - - prompt - - "" + - model + - dataset + - space + - code + - prompt + - "" type: string x-enum-varnames: - - ModelRepo - - DatasetRepo - - SpaceRepo - - CodeRepo - - PromptRepo - - UnknownRepo + - ModelRepo + - DatasetRepo + - SpaceRepo + - CodeRepo + - PromptRepo + - UnknownRepo types.ResourceType: enum: - - cpu - - gpu + - cpu + - gpu type: string x-enum-varnames: - - ResourceTypeCPU - - ResourceTypeGPU + - ResourceTypeCPU + - ResourceTypeGPU types.Response: properties: data: {} @@ -2066,11 +2065,11 @@ definitions: type: object types.SensitiveCheckStatus: enum: - - -1 - - 0 - - 1 - - 2 - - 3 + - -1 + - 0 + - 1 + - 2 + - 3 type: integer x-enum-comments: SensitiveCheckException: error happen @@ -2079,25 +2078,25 @@ definitions: SensitiveCheckPending: default SensitiveCheckSkip: skip x-enum-varnames: - - SensitiveCheckFail - - SensitiveCheckPending - - SensitiveCheckPass - - SensitiveCheckSkip - - SensitiveCheckException + - SensitiveCheckFail + - SensitiveCheckPending + - SensitiveCheckPass + - SensitiveCheckSkip + - SensitiveCheckException types.ShowDiscussionResponse: properties: comment_count: type: integer comments: items: - $ref: "#/definitions/types.DiscussionResponse_Comment" + $ref: '#/definitions/types.DiscussionResponse_Comment' type: array id: type: integer title: type: string user: - $ref: "#/definitions/types.DiscussionResponse_User" + $ref: '#/definitions/types.DiscussionResponse_User' type: object types.Space: properties: @@ -2133,7 +2132,7 @@ definitions: example: space_name_1 type: string namespace: - $ref: "#/definitions/types.Namespace" + $ref: '#/definitions/types.Namespace' nickname: example: "" type: string @@ -2143,7 +2142,7 @@ definitions: private: type: boolean repository: - $ref: "#/definitions/types.Repository" + $ref: '#/definitions/types.Repository' repository_id: type: integer sdk: @@ -2160,24 +2159,24 @@ definitions: sku: type: string source: - $ref: "#/definitions/types.RepositorySource" + $ref: '#/definitions/types.RepositorySource' status: description: deploying, running, failed type: string svc_name: type: string sync_status: - $ref: "#/definitions/types.RepositorySyncStatus" + $ref: '#/definitions/types.RepositorySyncStatus' tags: items: - $ref: "#/definitions/types.RepoTag" + $ref: '#/definitions/types.RepoTag' type: array template: type: string updated_at: type: string user: - $ref: "#/definitions/types.User" + $ref: '#/definitions/types.User' user_likes: type: boolean username: @@ -2195,7 +2194,7 @@ definitions: resources: type: string type: - $ref: "#/definitions/types.ResourceType" + $ref: '#/definitions/types.ResourceType' type: object types.SpaceSdk: properties: @@ -2215,9 +2214,9 @@ definitions: repo_path: type: string repo_type: - $ref: "#/definitions/types.RepositoryType" + $ref: '#/definitions/types.RepositoryType' source_id: - description: "0: opencsg, 1: HF" + description: '0: opencsg, 1: HF' type: integer version: type: integer @@ -2230,7 +2229,7 @@ definitions: type: boolean versions: items: - $ref: "#/definitions/types.SyncVersion" + $ref: '#/definitions/types.SyncVersion' type: array type: object msg: @@ -2238,16 +2237,16 @@ definitions: type: object types.TaskType: enum: - - evaluation - - training - - comparison - - leaderboard + - evaluation + - training + - comparison + - leaderboard type: string x-enum-varnames: - - TaskTypeEvaluation - - TaskTypeTraining - - TaskTypeComparison - - TaskTypeLeaderBoard + - TaskTypeEvaluation + - TaskTypeTraining + - TaskTypeComparison + - TaskTypeLeaderBoard types.UpdateCategory: properties: enabled: @@ -2259,8 +2258,8 @@ definitions: show_name: type: string required: - - name - - scope + - name + - scope type: object types.UpdateCodeReq: properties: @@ -2285,7 +2284,7 @@ definitions: content: type: string required: - - content + - content type: object types.UpdateDatasetReq: properties: @@ -2303,7 +2302,7 @@ definitions: title: type: string required: - - title + - title type: object types.UpdateFileReq: properties: @@ -2323,9 +2322,9 @@ definitions: type: integer type: array pointer: - $ref: "#/definitions/types.Pointer" + $ref: '#/definitions/types.Pointer' repoType: - $ref: "#/definitions/types.RepositoryType" + $ref: '#/definitions/types.RepositoryType' sha: type: string type: object @@ -2353,7 +2352,7 @@ definitions: source_name: type: string required: - - source_name + - source_name type: object types.UpdateModelReq: properties: @@ -2437,9 +2436,9 @@ definitions: show_name: type: string required: - - category - - name - - scope + - category + - name + - scope type: object types.UpdateUserRequest: properties: @@ -2455,8 +2454,7 @@ definitions: description: Display name of the user type: string new_username: - description: - if use want to change username, this should be the only field + description: if use want to change username, this should be the only field to send in request body type: string phone: @@ -2464,9 +2462,9 @@ definitions: roles: description: should be updated by admin example: - - "[super_user" - - " admin" - - " personal_user]" + - '[super_user' + - ' admin' + - ' personal_user]' items: type: string type: array @@ -2493,7 +2491,7 @@ definitions: type: string orgs: items: - $ref: "#/definitions/types.Organization" + $ref: '#/definitions/types.Organization' type: array phone: type: string @@ -2512,1269 +2510,1268 @@ paths: /{repo_type}/{namespace}/{name}/blob/{file_path}: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: file path - in: path - name: file_path - required: true - type: string - - description: branch or tag - in: query - name: ref - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: file path + in: path + name: file_path + required: true + type: string + - description: branch or tag + in: query + name: ref + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.File" - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.File' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey or JWT: [] + - ApiKey or JWT: [] summary: Get the repo file information like size, content, sha etc tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/branches: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: branch or tag - in: query - name: ref - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: branch or tag + in: query + name: ref + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Branch" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Branch' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get the branches of repository tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/commit/{commit_id}: get: consumes: - - application/json - parameters: - - description: models,datasets,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: commit id - in: path - name: commit_id - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,datasets,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: commit id + in: path + name: commit_id + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.CommitResponse" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.CommitResponse' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] - summary: - Get commit diff of repository and data field of response need to be + - ApiKey: [] + summary: Get commit diff of repository and data field of response need to be decode with base64 tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/commits: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: branch or tag - in: query - name: ref - required: true - type: string - - description: current user name - in: query - name: current_user - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: branch or tag + in: query + name: ref + required: true + type: string + - description: current user name + in: query + name: current_user + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Commit" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Commit' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all commits of repository tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/discussions: get: consumes: - - application/json + - application/json description: list repo discussions parameters: - - description: current user - in: query - name: current_user - type: string - - description: repository type - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: query - name: name - required: true - type: string + - description: current user + in: query + name: current_user + type: string + - description: repository type + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: query + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.ListRepoDiscussionResponse" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.ListRepoDiscussionResponse' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List repo discussions tags: - - Discussion + - Discussion post: consumes: - - application/json + - application/json description: create a new repo discussion parameters: - - description: current user, the owner - in: query - name: current_user - required: true - type: string - - description: repository type - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateRepoDiscussionRequest" + - description: current user, the owner + in: query + name: current_user + required: true + type: string + - description: repository type + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateRepoDiscussionRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.CreateDiscussionResponse" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.CreateDiscussionResponse' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new repo discussion tags: - - Discussion + - Discussion /{repo_type}/{namespace}/{name}/download/{file_path}: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: file path - in: path - name: file_path - required: true - type: string - - description: branch or tag - in: query - name: ref - type: string - - description: file name to save as - in: query - name: save_as - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: file path + in: path + name: file_path + required: true + type: string + - description: branch or tag + in: query + name: ref + type: string + - description: file name to save as + in: query + name: save_as + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - type: object - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + type: object + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey or JWT: [] - summary: "Download a repo file [Depricated: use 'resolve' api instead]" + - ApiKey or JWT: [] + summary: 'Download a repo file [Depricated: use ''resolve'' api instead]' tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/incr_downloads: put: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Increase repo download count by 1 tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/last_commit: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: branch or tag - in: query - name: ref - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: branch or tag + in: query + name: ref + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.Commit" - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.Commit' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get the last commit of repository tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/mirror: delete: consumes: - - application/json - parameters: - - description: models,datasets,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string + - application/json + parameters: + - description: models,datasets,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a mirror tags: - - Repository + - Repository get: consumes: - - application/json - parameters: - - description: models,datasets,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - application/json + parameters: + - description: models,datasets,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Mirror" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Mirror' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get a mirror tags: - - Repository + - Repository post: consumes: - - application/json - parameters: - - description: models,datasets,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateMirrorParams" + - application/json + parameters: + - description: models,datasets,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateMirrorParams' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Mirror" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Mirror' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create mirror for a existing repository tags: - - Repository + - Repository put: consumes: - - application/json - parameters: - - description: models,datasets,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateMirrorParams" + - application/json + parameters: + - description: models,datasets,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateMirrorParams' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Mirror" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Mirror' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a mirror for a existing repository tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/mirror/sync: post: consumes: - - application/json - parameters: - - description: models,datasets,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string + - application/json + parameters: + - description: models,datasets,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Triggers the mirror synchronization tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/mirror_from_saas: post: consumes: - - application/json - parameters: - - description: models,datasets,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string + - application/json + parameters: + - description: models,datasets,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Mirror" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Mirror' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Mirror repo from OpenCSG Saas(only on-premises) tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/raw/{file_path}: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: file path - in: path - name: file_path - required: true - type: string - - description: branch or tag - in: query - name: ref - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: file path + in: path + name: file_path + required: true + type: string + - description: branch or tag + in: query + name: ref + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - type: string - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + type: string + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get the last commit of repository tags: - - Repository + - Repository post: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: the new file relative path - in: path - name: file_path - required: true - type: string - - description: current user name - in: query - name: current_user - type: string - - description: create file request - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.CreateFileReq" + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: the new file relative path + in: path + name: file_path + required: true + type: string + - description: current user name + in: query + name: current_user + type: string + - description: create file request + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.CreateFileReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.CreateFileResp" - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.CreateFileResp' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new file in repository tags: - - Repository + - Repository put: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: the new file relative path - in: path - name: file_path - required: true - type: string - - description: current user name - in: query - name: current_user - type: string - - description: create file request - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.UpdateFileReq" + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: the new file relative path + in: path + name: file_path + required: true + type: string + - description: current user name + in: query + name: current_user + type: string + - description: create file request + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.UpdateFileReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.UpdateFileResp" - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.UpdateFileResp' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update existing file in repository tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/refs/{ref}/logs_tree/{path}: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: dir to list - in: path - name: path - type: string - - description: branch or tag - in: path - name: ref - type: string - - description: limit of records return - in: query - name: limit - type: integer - - description: pagination offset - in: query - name: offset - type: integer + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: dir to list + in: path + name: path + type: string + - description: branch or tag + in: path + name: ref + type: string + - description: limit of records return + in: query + name: limit + type: integer + - description: pagination offset + in: query + name: offset + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.LogsTreeResp" - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.LogsTreeResp' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get last commit for file tree tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/refs/{ref}/tree/{path}: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: dir to list - in: path - name: path - type: string - - description: branch or tag - in: path - name: ref - type: string - - description: limit of records return - in: query - name: limit - type: integer - - description: pagination cursor - in: query - name: cursor - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: dir to list + in: path + name: path + type: string + - description: branch or tag + in: path + name: ref + type: string + - description: limit of records return + in: query + name: limit + type: integer + - description: pagination cursor + in: query + name: cursor + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.GetRepoFileTreeResp" - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.GetRepoFileTreeResp' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get file tree tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/resolve/{file_path}: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: file path - in: path - name: file_path - required: true - type: string - - description: branch or tag - in: query - name: ref - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: file path + in: path + name: file_path + required: true + type: string + - description: branch or tag + in: query + name: ref + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - type: string - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + type: string + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Download a rep file tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/run: get: consumes: - - application/json + - application/json description: List repo deploys parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -3783,51 +3780,51 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List repo deploys tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/run/{id}: get: consumes: - - application/json + - application/json description: Get repo deploy detail parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: string - - description: current user - in: query - name: current_user - type: string + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -3836,228 +3833,228 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "401": description: Permission denied schema: - $ref: "#/definitions/types.APIUnauthorized" + $ref: '#/definitions/types.APIUnauthorized' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get repo deploy detail tags: - - Repository + - Repository put: consumes: - - application/json + - application/json parameters: - - description: models - enum: - - models - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: deploy id - in: path - name: id - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string - - description: deploy setting of inference - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.DeployUpdateReq" + - description: models + enum: + - models + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: deploy id + in: path + name: id + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string + - description: deploy setting of inference + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.DeployUpdateReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update deploy parameters tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/run/{id}/logs/{instance}: get: consumes: - - application/json + - application/json parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: string - - description: instance - in: path - name: instance - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: string + - description: instance + in: path + name: instance + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "401": description: Permission denied schema: - $ref: "#/definitions/types.APIUnauthorized" + $ref: '#/definitions/types.APIUnauthorized' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: get deploy instance logs tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/run/{id}/status: get: consumes: - - application/json + - application/json parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: deploy id - in: path - name: id - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: deploy id + in: path + name: id + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "401": description: Permission denied schema: - $ref: "#/definitions/types.APIUnauthorized" + $ref: '#/definitions/types.APIUnauthorized' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: get deploy status tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/runtime_framework: get: consumes: - - application/json + - application/json description: List repo runtime framework parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - default: 1 - description: deploy_type - enum: - - 0 - - 1 - - 2 - - 4 - in: query - name: deploy_type - type: integer + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - default: 1 + description: deploy_type + enum: + - 0 + - 1 + - 2 + - 4 + in: query + name: deploy_type + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -4066,1533 +4063,1673 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List repo runtime framework tags: - - RuntimeFramework + - RuntimeFramework /{repo_type}/{namespace}/{name}/tags: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/database.Tag" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/database.Tag' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get the tags of repository tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/tags/{category}: post: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: tag category - enum: - - task - - license - - framework - - language - - industry - in: path - name: category - required: true - type: string - - description: tag names in array - in: body - name: tags - required: true - schema: - items: - type: string - type: array + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: tag category + enum: + - task + - license + - framework + - language + - industry + in: path + name: category + required: true + type: string + - description: tag names in array + in: body + name: tags + required: true + schema: + items: + type: string + type: array produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: update the tags of a certain category tags: - - Repository + - Repository /{repo_type}/{namespace}/{name}/tree: get: consumes: - - application/json - parameters: - - description: models,dataset,codes or spaces - enum: - - models - - datasets - - codes - - spaces - in: path - name: repo_type - required: true - type: string - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: root dir - in: query - name: path - type: string - - description: branch or tag - in: query - name: ref - type: string + - application/json + parameters: + - description: models,dataset,codes or spaces + enum: + - models + - datasets + - codes + - spaces + in: path + name: repo_type + required: true + type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: root dir + in: query + name: path + type: string + - description: branch or tag + in: query + name: ref + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.File" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.File' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get repository file tree tags: - - Repository + - Repository /accounting/metering/{id}/statements: - get: - consumes: - - application/json - description: List meterings by user uuid and start time and end time - parameters: - - description: user uuid - in: path - name: id - required: true - type: string - - default: 10 - description: scene - enum: - - 10 - - 11 - - 12 - - 20 - in: query - name: scene - type: integer - - description: instance name - in: query - name: instance_name - required: true - type: string - - description: "start_time, format: '2024-06-12 08:27:22'" - in: query - name: start_time - required: true - type: string - - description: "end_time, format: '2024-06-12 17:17:22'" - in: query - name: end_time - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + get: + consumes: + - application/json + description: List meterings by user uuid and start time and end time + parameters: + - description: user uuid + in: path + name: id + required: true + type: string + - default: 10 + description: scene + enum: + - 10 + - 11 + - 12 + - 20 + in: query + name: scene + type: integer + - description: instance name + in: query + name: instance_name + required: true + type: string + - description: 'start_time, format: ''2024-06-12 08:27:22''' + in: query + name: start_time + required: true + type: string + - description: 'end_time, format: ''2024-06-12 17:17:22''' + in: query + name: end_time + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List meterings by user uuid and start time and end time tags: - - Accounting + - Accounting /cluster: get: consumes: - - application/json + - application/json description: Get cluster list produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get cluster list tags: - - Cluster + - Cluster /cluster/{id}: get: consumes: - - application/json + - application/json description: Get cluster by id produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get cluster by id tags: - - Cluster + - Cluster /codes: get: consumes: - - application/json + - application/json description: get visiable codes for current user parameters: - - description: current user - in: query - name: current_user - type: string - - description: search text - in: query - name: search - type: string - - description: filter by task tag - in: query - name: task_tag - type: string - - description: filter by framework tag - in: query - name: framework_tag - type: string - - description: filter by license tag - in: query - name: license_tag - type: string - - description: filter by language tag - in: query - name: language_tag - type: string - - description: sort by - in: query - name: sort - type: string - - description: source - enum: - - opencsg - - huggingface - - local - in: query - name: source - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: current user + in: query + name: current_user + type: string + - description: search text + in: query + name: search + type: string + - description: filter by task tag + in: query + name: task_tag + type: string + - description: filter by framework tag + in: query + name: framework_tag + type: string + - description: filter by license tag + in: query + name: license_tag + type: string + - description: filter by language tag + in: query + name: language_tag + type: string + - description: sort by + in: query + name: sort + type: string + - description: source + enum: + - opencsg + - huggingface + - local + in: query + name: source + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Code" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Code' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get Visiable codes for current user tags: - - Code + - Code post: consumes: - - application/json + - application/json description: create a new code parameters: - - description: current user, the owner - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateCodeReq" + - description: current user, the owner + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateCodeReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Code" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Code' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new code tags: - - Code + - Code /codes/{namespace}/{name}: delete: consumes: - - application/json + - application/json description: delete a exists code parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exists code tags: - - Code + - Code get: consumes: - - application/json + - application/json description: get code detail parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Code" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Code' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get code detail tags: - - Code + - Code put: consumes: - - application/json + - application/json description: update a exists code parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateCodeReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateCodeReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Code" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Code' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a exists code tags: - - Code + - Code /codes/{namespace}/{name}/relations: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Relations" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Relations' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get code related assets tags: - - Code + - Code /collections: get: consumes: - - application/json + - application/json description: get all collections parameters: - - description: search text - in: query - name: search - type: string - - default: '"trending"' - description: sort by - in: query - name: sort - type: string - - default: 50 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: search text + in: query + name: search + type: string + - default: '"trending"' + description: sort by + in: query + name: sort + type: string + - default: 50 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Collection" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Collection' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' summary: get all collections tags: - - Collection + - Collection post: consumes: - - application/json + - application/json description: create a collection parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateCollectionReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateCollectionReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Collection" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Collection' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: create a collection tags: - - Collection + - Collection /collections/{id}: delete: consumes: - - application/json + - application/json description: delete a exists collection parameters: - - description: id - in: path - name: id - required: true - type: string + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: Delete a exists collection tags: - - Collection + - Collection get: consumes: - - application/json + - application/json description: get a collection detail parameters: - - description: id - in: path - name: id - required: true - type: string + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Collection" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Collection' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' summary: get a collection detail tags: - - Collection + - Collection put: consumes: - - application/json + - application/json description: update a collection parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateCollectionReq" - - description: id - in: path - name: id - required: true - type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateCollectionReq' + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Collection" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Collection' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: update a collection tags: - - Collection + - Collection /collections/{id}/repos: delete: consumes: - - application/json + - application/json description: remove repos from a collection parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateCollectionReposReq" - - description: id - in: path - name: id - required: true - type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateCollectionReposReq' + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Collection" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Collection' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: remove repos from a collection tags: - - Collection + - Collection post: consumes: - - application/json + - application/json description: Add repos to a collection parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateCollectionReposReq" - - description: id - in: path - name: id - required: true - type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateCollectionReposReq' + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Collection" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Collection' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: Add repos to a collection tags: - - Collection + - Collection /comments/{id}: delete: consumes: - - application/json + - application/json description: delete a comment by id parameters: - - description: the comment id - in: path - name: id - required: true - type: string - - description: current user, the owner of the comment - in: query - name: current_user - required: true - type: string + - description: the comment id + in: path + name: id + required: true + type: string + - description: current user, the owner of the comment + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a comment by id tags: - - Discussion + - Discussion put: consumes: - - application/json + - application/json description: update a comment content by id parameters: - - description: the comment id - in: path - name: id - required: true - type: string - - description: current user, the owner of the comment - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateCommentRequest" + - description: the comment id + in: path + name: id + required: true + type: string + - description: current user, the owner of the comment + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateCommentRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a comment content by id tags: - - Discussion + - Discussion /datasets: get: consumes: - - application/json + - application/json description: get visiable datasets for current user parameters: - - description: current user - in: query - name: current_user - type: string - - description: search text - in: query - name: search - type: string - - description: filter by task tag - in: query - name: task_tag - type: string - - description: filter by framework tag - in: query - name: framework_tag - type: string - - description: filter by license tag - in: query - name: license_tag - type: string - - description: filter by language tag - in: query - name: language_tag - type: string - - description: sort by - in: query - name: sort - type: string - - description: source - enum: - - opencsg - - huggingface - - local - in: query - name: source - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: current user + in: query + name: current_user + type: string + - description: search text + in: query + name: search + type: string + - description: filter by task tag + in: query + name: task_tag + type: string + - description: filter by framework tag + in: query + name: framework_tag + type: string + - description: filter by license tag + in: query + name: license_tag + type: string + - description: filter by language tag + in: query + name: language_tag + type: string + - description: sort by + in: query + name: sort + type: string + - description: source + enum: + - opencsg + - huggingface + - local + in: query + name: source + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Dataset" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Dataset' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get Visiable datasets for current user tags: - - Dataset + - Dataset post: consumes: - - application/json + - application/json description: create a new dataset parameters: - - description: current user, the owner - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateDatasetReq" + - description: current user, the owner + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateDatasetReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Dataset" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Dataset' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new dataset tags: - - Dataset + - Dataset /datasets/{namespace}/{name}: delete: consumes: - - application/json + - application/json description: delete a exists dataset parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exists dataset tags: - - Dataset + - Dataset get: consumes: - - application/json + - application/json description: get dataset detail parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Dataset" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Dataset' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get dataset detail tags: - - Dataset + - Dataset put: consumes: - - application/json + - application/json description: update a exists dataset parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateDatasetReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateDatasetReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Dataset" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Dataset' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a exists dataset tags: - - Dataset + - Dataset /datasets/{namespace}/{name}/all_files: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.File" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.File' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all files of a dataset tags: - - Dataset + - Dataset + /datasets/{namespace}/{name}/dataviewer/catalog: + get: + consumes: + - application/json + description: get catalog of the dataset + parameters: + - description: namespace + in: path + name: namespace + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/types.Response' + "400": + description: Bad request + schema: + $ref: '#/definitions/types.APIBadRequest' + "500": + description: Internal server error + schema: + $ref: '#/definitions/types.APIInternalServerError' + security: + - ApiKey: [] + summary: Get catalog of the dataset + tags: + - Dataset + /datasets/{namespace}/{name}/dataviewer/rows: + get: + consumes: + - application/json + description: get catalog of the dataset + parameters: + - description: namespace + in: path + name: namespace + required: true + type: string + - description: config + in: query + name: config + required: true + type: string + - description: split + in: query + name: split + required: true + type: string + - description: search + in: query + name: search + type: string + - description: where + in: query + name: where + type: string + - description: orderby + in: query + name: orderby + type: string + - default: 50 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/types.Response' + "400": + description: Bad request + schema: + $ref: '#/definitions/types.APIBadRequest' + "500": + description: Internal server error + schema: + $ref: '#/definitions/types.APIInternalServerError' + security: + - ApiKey: [] + summary: Get catalog of the dataset + tags: + - Dataset /datasets/{namespace}/{name}/relations: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Relations" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Relations' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get dataset related assets tags: - - Dataset + - Dataset + /datasets/{namespace}/{name}/viewer/{file_path}: + get: + consumes: + - application/json + description: get the demo data of the dataset + parameters: + - description: namespace + in: path + name: namespace + required: true + type: string + - description: file_path + in: path + name: file_path + required: true + type: string + - default: 50 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/types.Response' + "400": + description: Bad request + schema: + $ref: '#/definitions/types.APIBadRequest' + "500": + description: Internal server error + schema: + $ref: '#/definitions/types.APIInternalServerError' + security: + - ApiKey: [] + summary: Get the demo data of the dataset + tags: + - Dataset /discussions/{id}: delete: consumes: - - application/json + - application/json description: delete a discussion parameters: - - description: the discussion id - in: path - name: id - required: true - type: string - - description: current user, the owner of the discussion - in: query - name: current_user - required: true - type: string + - description: the discussion id + in: path + name: id + required: true + type: string + - description: current user, the owner of the discussion + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a discussion tags: - - Discussion + - Discussion get: consumes: - - application/json + - application/json description: show a discussion parameters: - - description: the discussion id - in: path - name: id - required: true - type: string + - description: the discussion id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.ShowDiscussionResponse" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.ShowDiscussionResponse' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Show a discussion and its comments tags: - - Discussion + - Discussion put: consumes: - - application/json + - application/json description: update a discussion parameters: - - description: the discussion id - in: path - name: id - required: true - type: string - - description: current user, the owner - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateDiscussionRequest" + - description: the discussion id + in: path + name: id + required: true + type: string + - description: current user, the owner + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateDiscussionRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a discussion tags: - - Discussion + - Discussion /discussions/{id}/comments: get: consumes: - - application/json + - application/json description: list discussion comments parameters: - - description: the discussion id - in: path - name: id - required: true - type: string + - description: the discussion id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.DiscussionResponse_Comment" - type: array - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.DiscussionResponse_Comment' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List discussion comments tags: - - Discussion + - Discussion post: consumes: - - application/json + - application/json description: create a new discussion comment parameters: - - description: the discussion id - in: path - name: id - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateCommentRequest" + - description: the discussion id + in: path + name: id + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateCommentRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.CreateCommentResponse" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.CreateCommentResponse' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new discussion comment tags: - - Discussion + - Discussion /evaluations: post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: body setting of evaluation - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.EvaluationReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: body setting of evaluation + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.EvaluationReq' produces: - - application/json + - application/json responses: "200": description: OK @@ -5601,28 +5738,28 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: run model evaluation tags: - - Evaluation + - Evaluation /evaluations/{id}: delete: consumes: - - application/json + - application/json parameters: - - description: id - in: path - name: id - required: true - type: string + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -5631,60 +5768,60 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: delete model evaluation tags: - - Evaluation + - Evaluation get: consumes: - - application/json + - application/json parameters: - - description: id - in: path - name: id - required: true - type: string + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.EvaluationRes" + $ref: '#/definitions/types.EvaluationRes' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: get model evaluation tags: - - Evaluation + - Evaluation /events: post: consumes: - - application/json + - application/json parameters: - - description: Events - in: body - name: events - required: true - schema: - items: - $ref: "#/definitions/types.Event" - type: array + - description: Events + in: body + name: events + required: true + schema: + items: + $ref: '#/definitions/types.Event' + type: array produces: - - application/json + - application/json responses: "200": description: OK @@ -5693,816 +5830,816 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' summary: Report client events tags: - - Events + - Events /jwt/{token}: get: consumes: - - application/json + - application/json parameters: - - description: token - in: path - name: token - required: true - type: string + - description: token + in: path + name: token + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.User" + $ref: '#/definitions/types.User' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: verify jwt token and return user info tags: - - JWT + - JWT /jwt/token: post: consumes: - - application/json + - application/json parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateJWTReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateJWTReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.CreateJWTResp" + $ref: '#/definitions/types.CreateJWTResp' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: generate jwt token for user tags: - - JWT + - JWT /list/datasets_by_path: post: consumes: - - application/json + - application/json description: list datasets by paths parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.ListByPathReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.ListByPathReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.DatasetResp" - type: array - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.DatasetResp' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List datasets by paths tags: - - List + - List /list/models_by_path: post: consumes: - - application/json + - application/json description: list models by paths parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.ListByPathReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.ListByPathReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.ModelResp" - type: array - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.ModelResp' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List models by paths tags: - - List + - List /list/spaces_by_path: post: consumes: - - application/json + - application/json parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.ListByPathReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.ListByPathReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.Space" - type: array - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.Space' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List spaces by paths tags: - - List + - List /mirror/repo: post: consumes: - - application/json + - application/json parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateMirrorRepoReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateMirrorRepoReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create mirror repo tags: - - Mirror + - Mirror /mirror/repos: get: consumes: - - application/json + - application/json parameters: - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: page - in: query - name: page - type: integer + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.MirrorRepo" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.MirrorRepo' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get mirror repos tags: - - Mirror + - Mirror /mirror/sources: get: consumes: - - application/json + - application/json produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/database.MirrorSource" - type: array - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/database.MirrorSource' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get mirror sources tags: - - Mirror + - Mirror post: consumes: - - application/json + - application/json parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateMirrorSourceReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateMirrorSourceReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.MirrorSource" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.MirrorSource' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create mirror source tags: - - Mirror + - Mirror /mirror/sources/{id}: delete: consumes: - - application/json + - application/json parameters: - - description: id - in: path - name: id - required: true - type: string + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete mirror source tags: - - Mirror + - Mirror get: consumes: - - application/json + - application/json parameters: - - description: id - in: path - name: id - required: true - type: string + - description: id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.MirrorSource" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.MirrorSource' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get mirror source tags: - - Mirror + - Mirror put: consumes: - - application/json + - application/json parameters: - - description: id - in: path - name: id - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateMirrorSourceReq" + - description: id + in: path + name: id + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateMirrorSourceReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.MirrorSource" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.MirrorSource' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update mirror source tags: - - Mirror + - Mirror /mirrors: get: consumes: - - application/json + - application/json parameters: - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: page - in: query - name: page - type: integer + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.Mirror" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.Mirror' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get mirrors tags: - - Mirror + - Mirror /models: get: consumes: - - application/json + - application/json description: get visiable models for current user parameters: - - description: current user - in: query - name: current_user - type: string - - description: search text - in: query - name: search - type: string - - description: filter by task tag, deprecated - in: query - name: task_tag - type: string - - description: filter by framework tag, deprecated - in: query - name: framework_tag - type: string - - description: filter by license tag, deprecated - in: query - name: license_tag - type: string - - description: filter by language tag, deprecated - in: query - name: language_tag - type: string - - description: filter by tag category - in: query - name: tag_category - type: string - - description: filter by tag name - in: query - name: tag_name - type: string - - description: sort by - in: query - name: sort - type: string - - description: source - enum: - - opencsg - - huggingface - - local - in: query - name: source - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: current user + in: query + name: current_user + type: string + - description: search text + in: query + name: search + type: string + - description: filter by task tag, deprecated + in: query + name: task_tag + type: string + - description: filter by framework tag, deprecated + in: query + name: framework_tag + type: string + - description: filter by license tag, deprecated + in: query + name: license_tag + type: string + - description: filter by language tag, deprecated + in: query + name: language_tag + type: string + - description: filter by tag category + in: query + name: tag_category + type: string + - description: filter by tag name + in: query + name: tag_name + type: string + - description: sort by + in: query + name: sort + type: string + - description: source + enum: + - opencsg + - huggingface + - local + in: query + name: source + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Model" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Model' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get Visiable models for current user tags: - - Model + - Model post: consumes: - - application/json + - application/json description: create a new model parameters: - - description: current user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateModelReq" + - description: current user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateModelReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Model" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Model' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new model tags: - - Model + - Model /models/{namespace}/{name}: delete: consumes: - - application/json + - application/json description: delete a exists model parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the model owner - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the model owner + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exists model tags: - - Model + - Model get: consumes: - - application/json + - application/json description: get model detail parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Model" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Model' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get model detail tags: - - Model + - Model put: consumes: - - application/json + - application/json description: update a exists model parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the model owner - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateModelReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the model owner + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateModelReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Model" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Model' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a exists model tags: - - Model + - Model /models/{namespace}/{name}/all_files: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.File" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.File' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all files of a model tags: - - Model + - Model /models/{namespace}/{name}/finetune: post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string - - description: deploy setting of instance - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.InstanceRunReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string + - description: deploy setting of instance + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.InstanceRunReq' produces: - - application/json + - application/json responses: "200": description: OK @@ -6511,361 +6648,361 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: create a finetune instance tags: - - Model + - Model /models/{namespace}/{name}/finetune/{id}: delete: consumes: - - application/json + - application/json description: delete a finetune instance parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a finetune instance tags: - - Model + - Model /models/{namespace}/{name}/finetune/{id}/start: put: consumes: - - application/json + - application/json description: Start a finetune instance parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: deploy id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: deploy id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Start a finetune instance tags: - - Model + - Model /models/{namespace}/{name}/finetune/{id}/stop: put: consumes: - - application/json + - application/json description: Stop a finetune instance parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Stop a finetune instance tags: - - Model + - Model /models/{namespace}/{name}/relations: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Relations" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Relations' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get model related assets tags: - - Model + - Model put: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: set dataset relation - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.RelationDatasets" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: set dataset relation + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.RelationDatasets' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Relations" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Relations' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Set dataset relation for model tags: - - Model + - Model /models/{namespace}/{name}/relations/dataset: delete: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: delelet dataset relation - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.RelationDataset" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: delelet dataset relation + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.RelationDataset' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: delete dataset relation for model tags: - - Model + - Model post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: add dataset relation - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.RelationDataset" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: add dataset relation + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.RelationDataset' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: add dataset relation for model tags: - - Model + - Model /models/{namespace}/{name}/run: post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string - - description: deploy setting of inference - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.ModelRunReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string + - description: deploy setting of inference + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.ModelRunReq' produces: - - application/json + - application/json responses: "200": description: OK @@ -6874,168 +7011,168 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: run model as inference tags: - - Model + - Model /models/{namespace}/{name}/run/{id}: delete: consumes: - - application/json + - application/json description: delete a model inference parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a model inference tags: - - Model + - Model /models/{namespace}/{name}/run/{id}/start: put: consumes: - - application/json + - application/json description: Start a model inference parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: deploy id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: deploy id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Start a model inference tags: - - Model + - Model /models/{namespace}/{name}/run/{id}/stop: put: consumes: - - application/json + - application/json description: Stop a model inference parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Stop a model inference tags: - - Model + - Model /models/{namespace}/{name}/serverless: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -7044,43 +7181,43 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: get model serverless tags: - - Model + - Model post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string - - description: deploy setting of serverless - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.ModelRunReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string + - description: deploy setting of serverless + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.ModelRunReq' produces: - - application/json + - application/json responses: "200": description: OK @@ -7089,43 +7226,43 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: run model as serverless service tags: - - Model + - Model /models/{namespace}/{name}/serverless/{id}: get: consumes: - - application/json + - application/json description: Get repo serverless detail parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: string - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -7134,288 +7271,288 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get repo serverless detail tags: - - Model + - Model put: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: deploy id - in: path - name: id - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string - - description: deploy setting of Serverless - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.DeployUpdateReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: deploy id + in: path + name: id + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string + - description: deploy setting of Serverless + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.DeployUpdateReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update serverless parameters tags: - - Model + - Model /models/{namespace}/{name}/serverless/{id}/logs/{instance}: get: consumes: - - application/json + - application/json parameters: - - description: models - enum: - - models - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: string - - description: instance - in: path - name: instance - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: models + enum: + - models + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: string + - description: instance + in: path + name: instance + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: get serverless logs tags: - - Model + - Model /models/{namespace}/{name}/serverless/{id}/start: put: consumes: - - application/json + - application/json description: Start a model serverless parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: deploy id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: deploy id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Start a model serverless tags: - - Model + - Model /models/{namespace}/{name}/serverless/{id}/status: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: deploy id - in: path - name: id - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: deploy id + in: path + name: id + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: get serverless status tags: - - Model + - Model /models/{namespace}/{name}/serverless/{id}/stop: put: consumes: - - application/json + - application/json description: Stop a model serverless parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Stop a model serverless tags: - - Model + - Model /models/runtime_framework: get: consumes: - - application/json + - application/json description: List repo runtime framework parameters: - - description: models - enum: - - models - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - default: 1 - description: deploy_type - enum: - - 0 - - 1 - - 2 - in: query - name: deploy_type - type: integer + - description: models + enum: + - models + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - default: 1 + description: deploy_type + enum: + - 0 + - 1 + - 2 + in: query + name: deploy_type + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -7424,487 +7561,487 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List repo runtime framework tags: - - Repository + - Repository /namespace/{path}: get: consumes: - - application/json + - application/json description: get namespace info parameters: - - description: namespace - in: path - name: path - required: true - type: string + - description: namespace + in: path + name: path + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Namespace" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Namespace' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get namespace info [Internal Only]. tags: - - Namespace - - InternalOnly + - Namespace + - InternalOnly /organization/{namespace}: delete: consumes: - - application/json + - application/json description: delete organization parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: the op user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.DeleteOrgReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: the op user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.DeleteOrgReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete organization tags: - - Organization + - Organization get: consumes: - - application/json + - application/json parameters: - - description: the op user - in: query - name: current_user - type: string - - description: namespace - in: path - name: namespace - required: true - type: string + - description: the op user + in: query + name: current_user + type: string + - description: namespace + in: path + name: namespace + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Organization" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Organization' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization info tags: - - Organization + - Organization put: consumes: - - application/json + - application/json description: update organization parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: the op user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.EditOrgReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: the op user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.EditOrgReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.Organization" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.Organization' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update organization tags: - - Organization + - Organization /organization/{namespace}/codes: get: consumes: - - application/json + - application/json parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: page size - in: query - name: per - type: integer - - description: current page number - in: query - name: page - type: integer + - description: org name + in: path + name: namespace + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: page size + in: query + name: per + type: integer + - description: current page number + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Code" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Code' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization codes tags: - - Organization + - Organization /organization/{namespace}/collections: get: consumes: - - application/json + - application/json parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: page size - in: query - name: per - type: integer - - description: current page number - in: query - name: page - type: integer + - description: org name + in: path + name: namespace + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: page size + in: query + name: per + type: integer + - description: current page number + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Collection" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Collection' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization Collections tags: - - Organization + - Organization /organization/{namespace}/datasets: get: consumes: - - application/json + - application/json description: get organization datasets parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: page size - in: query - name: per - type: integer - - description: current page number - in: query - name: page - type: integer + - description: org name + in: path + name: namespace + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: page size + in: query + name: per + type: integer + - description: current page number + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Dataset" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Dataset' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization datasets tags: - - Organization + - Organization /organization/{namespace}/members: get: consumes: - - application/json + - application/json parameters: - - description: the op user - in: query - name: current_user - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - default: 50 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: the op user + in: query + name: current_user + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - default: 50 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - " total": - type: integer - data: - $ref: "#/definitions/types.Member" - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + ' total': + type: integer + data: + $ref: '#/definitions/types.Member' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization members. Org member can get more details. tags: - - Member + - Member post: consumes: - - application/json + - application/json description: user will be added to org with a role parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: the op user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/handler.Create.addMemberRequest" + - description: org name + in: path + name: namespace + required: true + type: string + - description: the op user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/handler.Create.addMemberRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create new membership between org and user tags: - - Member + - Member /organization/{namespace}/members/{username}: delete: consumes: - - application/json + - application/json description: user's role will be remove from org parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: user name - in: path - name: username - required: true - type: string - - description: the op user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/handler.Delete.removeMemberRequest" + - description: org name + in: path + name: namespace + required: true + type: string + - description: user name + in: path + name: username + required: true + type: string + - description: the op user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/handler.Delete.removeMemberRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Remove membership between org and user tags: - - Member + - Member get: consumes: - - application/json + - application/json parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: user name - in: path - name: username - required: true - type: string - - description: the op user - in: query - name: current_user - type: string + - description: org name + in: path + name: namespace + required: true + type: string + - description: user name + in: path + name: username + required: true + type: string + - description: the op user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -7913,2236 +8050,2236 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user's role in an org tags: - - Member + - Member put: consumes: - - application/json + - application/json parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: user name - in: path - name: username - required: true - type: string - - description: the op user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/handler.Update.updateMemberRequest" + - description: org name + in: path + name: namespace + required: true + type: string + - description: user name + in: path + name: username + required: true + type: string + - description: the op user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/handler.Update.updateMemberRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: update user membership tags: - - Member + - Member /organization/{namespace}/models: get: consumes: - - application/json + - application/json description: get organization models parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: page size - in: query - name: per - type: integer - - description: current page number - in: query - name: page - type: integer + - description: org name + in: path + name: namespace + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: page size + in: query + name: per + type: integer + - description: current page number + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Model" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Model' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization models tags: - - Organization + - Organization /organization/{namespace}/prompts: get: consumes: - - application/json + - application/json description: get organization prompts parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: page size - in: query - name: per - type: integer - - description: current page number - in: query - name: page - type: integer + - description: org name + in: path + name: namespace + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: page size + in: query + name: per + type: integer + - description: current page number + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.PromptRes" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.PromptRes' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization prompts tags: - - Organization + - Organization /organization/{namespace}/spaces: get: consumes: - - application/json + - application/json parameters: - - description: org name - in: path - name: namespace - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: page size - in: query - name: per - type: integer - - description: current page number - in: query - name: page - type: integer + - description: org name + in: path + name: namespace + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: page size + in: query + name: per + type: integer + - description: current page number + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Space" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Space' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organization Spaces tags: - - Organization + - Organization /organizations: get: consumes: - - application/json + - application/json description: get organizations produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.Organization" - type: array - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.Organization' + type: array + type: object "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get organizations tags: - - Organization + - Organization post: consumes: - - application/json + - application/json description: create a new organization parameters: - - description: the op user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateOrgReq" + - description: the op user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateOrgReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Organization" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Organization' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new organization tags: - - Organization + - Organization /prompts: get: consumes: - - application/json + - application/json description: get visiable Prompt repos for current user parameters: - - description: current user - in: query - name: current_user - type: string - - description: search text - in: query - name: search - type: string - - description: filter by task tag - in: query - name: task_tag - type: string - - description: filter by framework tag - in: query - name: framework_tag - type: string - - description: filter by license tag - in: query - name: license_tag - type: string - - description: filter by language tag - in: query - name: language_tag - type: string - - description: sort by - in: query - name: sort - type: string - - description: source - enum: - - opencsg - - huggingface - - local - in: query - name: source - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: current user + in: query + name: current_user + type: string + - description: search text + in: query + name: search + type: string + - description: filter by task tag + in: query + name: task_tag + type: string + - description: filter by framework tag + in: query + name: framework_tag + type: string + - description: filter by license tag + in: query + name: license_tag + type: string + - description: filter by language tag + in: query + name: language_tag + type: string + - description: sort by + in: query + name: sort + type: string + - description: source + enum: + - opencsg + - huggingface + - local + in: query + name: source + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.PromptRes" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.PromptRes' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get Visiable Prompt repos for current user tags: - - Prompt + - Prompt post: consumes: - - application/json + - application/json description: create a new prompt repo parameters: - - description: current user, the owner - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreatePromptRepoReq" + - description: current user, the owner + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreatePromptRepoReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new prompt repo tags: - - Prompt + - Prompt /prompts/{namespace}/{name}: delete: consumes: - - application/json + - application/json description: delete a exists prompt repo parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exists prompt repo tags: - - Prompt + - Prompt get: consumes: - - application/json + - application/json description: List prompts parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: List prompts tags: - - Prompt + - Prompt put: consumes: - - application/json + - application/json description: update a exists prompt repo parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdatePromptRepoReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdatePromptRepoReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a exists prompt repo tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/branches: get: consumes: - - application/json + - application/json parameters: - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: branch or tag - in: query - name: ref - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: branch or tag + in: query + name: ref + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Branch" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Branch' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get the branches of prompt repository tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/prompt/file: post: consumes: - - application/json + - application/json description: Create prompt in repo parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create prompt in repo tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/prompt/file/{file_path}: delete: consumes: - - application/json + - application/json description: Delete prompt in repo parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: the file relative path - in: path - name: file_path - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: the file relative path + in: path + name: file_path + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete prompt in repo tags: - - Prompt + - Prompt put: consumes: - - application/json + - application/json description: Update prompt in repo parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: the file relative path - in: path - name: file_path - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: the file relative path + in: path + name: file_path + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update prompt in repo tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/prompt/view/{file_path}: get: consumes: - - application/json + - application/json description: Get prompts by file parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: the file relative path - in: path - name: file_path - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: the file relative path + in: path + name: file_path + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get prompts by file tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/relations: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Relations" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Relations' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get prompt related assets tags: - - Prompt + - Prompt put: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: set model relation - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.RelationModels" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: set model relation + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.RelationModels' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Set model relation for prompt tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/relations/model: delete: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: delelet model relation - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.RelationModel" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: delelet model relation + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.RelationModel' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: delete model relation for prompt tags: - - Prompt + - Prompt post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: add model relation - in: body - name: req - required: true - schema: - $ref: "#/definitions/types.RelationModel" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: add model relation + in: body + name: req + required: true + schema: + $ref: '#/definitions/types.RelationModel' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: add model relation for prompt tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/tags: get: consumes: - - application/json + - application/json parameters: - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: current user name - in: query - name: current_user - type: string + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: current user name + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/database.Tag" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/database.Tag' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get the tags of prompt repository tags: - - Prompt + - Prompt /prompts/{namespace}/{name}/tags/{category}: post: consumes: - - application/json - parameters: - - description: repo owner name - in: path - name: namespace - required: true - type: string - - description: repo name - in: path - name: name - required: true - type: string - - description: current user name - in: query - name: current_user - required: true - type: string - - description: tag category - enum: - - task - - license - - framework - - language - - industry - in: path - name: category - required: true - type: string - - description: tag names in array - in: body - name: tags - required: true - schema: - items: - type: string - type: array + - application/json + parameters: + - description: repo owner name + in: path + name: namespace + required: true + type: string + - description: repo name + in: path + name: name + required: true + type: string + - description: current user name + in: query + name: current_user + required: true + type: string + - description: tag category + enum: + - task + - license + - framework + - language + - industry + in: path + name: category + required: true + type: string + - description: tag names in array + in: body + name: tags + required: true + schema: + items: + type: string + type: array produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: update the tags of a certain category tags: - - Prompt + - Prompt /recom/opweight: post: consumes: - - application/json + - application/json parameters: - - description: json request body - in: body - name: body - required: true - schema: - $ref: "#/definitions/handler.SetOpWeight.SetOpWeightReq" + - description: json request body + in: body + name: body + required: true + schema: + $ref: '#/definitions/handler.SetOpWeight.SetOpWeightReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: set op weight for repo recommendation tags: - - Recommendation + - Recommendation /runtime_framework: get: consumes: - - application/json + - application/json description: get all runtime frameworks for current user parameters: - - description: current user - in: query - name: current_user - type: string + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all runtime frameworks for current user tags: - - RuntimeFramework + - RuntimeFramework post: consumes: - - application/json + - application/json description: create runtime framework parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.RuntimeFrameworkReq" + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.RuntimeFrameworkReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.RuntimeFramework" + $ref: '#/definitions/types.RuntimeFramework' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create runtime framework tags: - - RuntimeFramework + - RuntimeFramework /runtime_framework/{id}: delete: consumes: - - application/json + - application/json description: delete a exist RuntimeFramework parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exist RuntimeFramework tags: - - RuntimeFramework + - RuntimeFramework put: consumes: - - application/json + - application/json description: Update runtime framework parameters: - - description: models,spaces - enum: - - models - - spaces - in: path - name: repo_type - required: true - type: string - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.RuntimeFrameworkReq" + - description: models,spaces + enum: + - models + - spaces + in: path + name: repo_type + required: true + type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.RuntimeFrameworkReq' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.RuntimeFramework" + $ref: '#/definitions/types.RuntimeFramework' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update runtime framework tags: - - RuntimeFramework + - RuntimeFramework /runtime_framework/{id}/architecture: delete: consumes: - - application/json + - application/json description: Delete runtime framework architectures parameters: - - description: runtime framework id - in: path - name: id - required: true - type: integer - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.RuntimeArchitecture" + - description: runtime framework id + in: path + name: id + required: true + type: integer + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.RuntimeArchitecture' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete runtime framework architectures tags: - - RuntimeFramework + - RuntimeFramework get: consumes: - - application/json + - application/json description: get runtime framework architectures parameters: - - description: runtime framework id - in: path - name: id - required: true - type: integer + - description: runtime framework id + in: path + name: id + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get runtime framework architectures tags: - - RuntimeFramework + - RuntimeFramework put: consumes: - - application/json + - application/json description: set runtime framework architectures parameters: - - description: runtime framework id - in: path - name: id - required: true - type: integer - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.RuntimeArchitecture" + - description: runtime framework id + in: path + name: id + required: true + type: integer + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.RuntimeArchitecture' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Set runtime framework architectures tags: - - RuntimeFramework + - RuntimeFramework /runtime_framework/{id}/models: delete: consumes: - - application/json + - application/json description: set model runtime frameworks parameters: - - description: runtime framework id - in: path - name: id - required: true - type: integer - - default: 1 - description: deploy_type - enum: - - 0 - - 1 - - 2 - in: query - name: deploy_type - type: integer - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.RuntimeFrameworkModels" + - description: runtime framework id + in: path + name: id + required: true + type: integer + - default: 1 + description: deploy_type + enum: + - 0 + - 1 + - 2 + in: query + name: deploy_type + type: integer + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.RuntimeFrameworkModels' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "403": description: Forbidden schema: - $ref: "#/definitions/types.APIForbidden" + $ref: '#/definitions/types.APIForbidden' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Set model runtime frameworks tags: - - RuntimeFramework + - RuntimeFramework get: consumes: - - application/json + - application/json description: get visible models by runtime framework for current user parameters: - - description: runtime framework id - in: path - name: id - required: true - type: integer - - description: current user - in: query - name: current_user - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer - - default: 1 - description: deploy_type - enum: - - 0 - - 1 - - 2 - in: query - name: deploy_type - type: integer + - description: runtime framework id + in: path + name: id + required: true + type: integer + - description: current user + in: query + name: current_user + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer + - default: 1 + description: deploy_type + enum: + - 0 + - 1 + - 2 + in: query + name: deploy_type + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get Visible models by runtime framework for current user tags: - - RuntimeFramework + - RuntimeFramework put: consumes: - - application/json + - application/json description: set model runtime frameworks parameters: - - description: runtime framework id - in: path - name: id - required: true - type: integer - - default: 1 - description: deploy_type - enum: - - 0 - - 1 - - 2 - in: query - name: deploy_type - type: integer - - description: current user - in: query - name: current_user - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.RuntimeFrameworkModels" + - description: runtime framework id + in: path + name: id + required: true + type: integer + - default: 1 + description: deploy_type + enum: + - 0 + - 1 + - 2 + in: query + name: deploy_type + type: integer + - description: current user + in: query + name: current_user + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.RuntimeFrameworkModels' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "403": description: Forbidden schema: - $ref: "#/definitions/types.APIForbidden" + $ref: '#/definitions/types.APIForbidden' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Set model runtime frameworks tags: - - RuntimeFramework + - RuntimeFramework /runtime_framework/{id}/scan: post: consumes: - - application/json + - application/json description: Scan runtime architecture parameters: - - description: runtime framework id - in: path - name: id - required: true - type: integer - - description: scan_type(0:all models, 1:new models, 2:old models) - enum: - - 0 - - 1 - - 2 - in: query - name: scan_type - type: integer - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.RuntimeFrameworkModels" + - description: runtime framework id + in: path + name: id + required: true + type: integer + - description: scan_type(0:all models, 1:new models, 2:old models) + enum: + - 0 + - 1 + - 2 + in: query + name: scan_type + type: integer + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.RuntimeFrameworkModels' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Scan runtime architecture tags: - - RuntimeFramework + - RuntimeFramework /runtime_framework/models: get: consumes: - - application/json + - application/json description: get visible models for all runtime frameworks for current user parameters: - - description: search text - in: query - name: search - type: string - - description: sort by - in: query - name: sort - type: string - - description: current user - in: query - name: current_user - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer - - default: 1 - description: deploy_type - enum: - - 1 - - 2 - in: query - name: deploy_type - type: integer + - description: search text + in: query + name: search + type: string + - description: sort by + in: query + name: sort + type: string + - description: current user + in: query + name: current_user + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer + - default: 1 + description: deploy_type + enum: + - 1 + - 2 + in: query + name: deploy_type + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get Visible models for all runtime frameworks for current user tags: - - RuntimeFramework + - RuntimeFramework /space_resources: get: consumes: - - application/json + - application/json description: get space resources parameters: - - description: cluster_id - in: query - name: cluster_id - type: string - - default: 1 - description: deploy type(0-space,1-inference,2-finetune) - enum: - - 0 - - 1 - - 2 - in: query - name: deploy_type - type: integer + - description: cluster_id + in: query + name: cluster_id + type: string + - default: 1 + description: deploy type(0-space,1-inference,2-finetune) + enum: + - 0 + - 1 + - 2 + in: query + name: deploy_type + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.SpaceResource" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.SpaceResource' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get space resources tags: - - SpaceReource + - SpaceReource post: consumes: - - application/json + - application/json description: create space resource parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateSpaceResourceReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateSpaceResourceReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.SpaceResource" - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.SpaceResource' + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create space resource tags: - - SpaceReource + - SpaceReource /space_resources/{id}: delete: consumes: - - application/json + - application/json description: delete a exist space resource parameters: - - description: id - in: path - name: id - required: true - type: integer + - description: id + in: path + name: id + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exist space resource tags: - - SpaceReource + - SpaceReource put: consumes: - - application/json + - application/json description: update a exist space resource parameters: - - description: id - in: path - name: id - required: true - type: integer - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateSpaceResourceReq" + - description: id + in: path + name: id + required: true + type: integer + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateSpaceResourceReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.SpaceResource" - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.SpaceResource' + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a exist space resource tags: - - SpaceReource + - SpaceReource /space_sdks: get: consumes: - - application/json + - application/json description: get space sdks produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.SpaceSdk" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.SpaceSdk' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get space sdks tags: - - SpaceSdk + - SpaceSdk post: consumes: - - application/json + - application/json description: create space sdk parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateSpaceSdkReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateSpaceSdkReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.SpaceSdk" - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.SpaceSdk' + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create space sdk tags: - - SpaceSdk + - SpaceSdk /space_sdks/{id}: delete: consumes: - - application/json + - application/json description: delete a exist space sdk parameters: - - description: id - in: path - name: 写id - required: true - type: integer + - description: id + in: path + name: 写id + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exist space sdk tags: - - SpaceSdk + - SpaceSdk put: consumes: - - application/json + - application/json description: update a exist space sdk parameters: - - description: id - in: path - name: id - required: true - type: integer - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateSpaceSdkReq" + - description: id + in: path + name: id + required: true + type: integer + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateSpaceSdkReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - $ref: "#/definitions/types.SpaceSdk" - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + $ref: '#/definitions/types.SpaceSdk' + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a exist space sdk tags: - - SpaceSdk + - SpaceSdk /spaces: get: consumes: - - application/json + - application/json description: get spaces visible to current user parameters: - - description: current user - in: query - name: current_user - type: string - - description: search text - in: query - name: search - type: string - - description: filter by task tag - in: query - name: task_tag - type: string - - description: filter by framework tag - in: query - name: framework_tag - type: string - - description: filter by license tag - in: query - name: license_tag - type: string - - description: filter by language tag - in: query - name: language_tag - type: string - - description: sort by - in: query - name: sort - type: string - - description: source - enum: - - opencsg - - huggingface - - local - in: query - name: source - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: current user + in: query + name: current_user + type: string + - description: search text + in: query + name: search + type: string + - description: filter by task tag + in: query + name: task_tag + type: string + - description: filter by framework tag + in: query + name: framework_tag + type: string + - description: filter by license tag + in: query + name: license_tag + type: string + - description: filter by language tag + in: query + name: language_tag + type: string + - description: sort by + in: query + name: sort + type: string + - description: source + enum: + - opencsg + - huggingface + - local + in: query + name: source + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Space" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Space' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get spaces visible to current user tags: - - Space + - Space post: consumes: - - application/json + - application/json description: create a new space parameters: - - description: current_user - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateSpaceReq" + - description: current_user + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateSpaceReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Space" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Space' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new space tags: - - Space + - Space /spaces/{namespace}/{name}: delete: consumes: - - application/json + - application/json description: delete a exists space parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a exists space tags: - - Space + - Space get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Space" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Space' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: show space detail tags: - - Space + - Space put: consumes: - - application/json + - application/json description: update a exists space parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateSpaceReq" + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateSpaceReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.Space" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.Space' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a exists space tags: - - Space + - Space /spaces/{namespace}/{name}/logs: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: get space logs tags: - - Space + - Space /spaces/{namespace}/{name}/run: post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -10151,1913 +10288,1911 @@ paths: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: run space app tags: - - Space + - Space /spaces/{namespace}/{name}/status: get: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: get space status tags: - - Space + - Space /spaces/{namespace}/{name}/stop: post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: stop space app tags: - - Space + - Space /spaces/{namespace}/{name}/wakeup: post: consumes: - - application/json + - application/json parameters: - - description: namespace - in: path - name: namespace - required: true - type: string - - description: name - in: path - name: name - required: true - type: string + - description: namespace + in: path + name: namespace + required: true + type: string + - description: name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - JWT token: [] + - JWT token: [] summary: wake up space app tags: - - Space + - Space /sync/client_setting: get: consumes: - - application/json + - application/json description: Get sync client setting produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.SyncClientSetting" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.SyncClientSetting' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get sync client setting tags: - - Sync + - Sync post: consumes: - - application/json + - application/json description: Create sync client setting or update an existing sync client setting parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateSyncClientSettingReq" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateSyncClientSettingReq' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.SyncClientSetting" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.SyncClientSetting' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create sync client setting or update an existing sync client setting tags: - - Sync + - Sync /sync/version/latest: get: parameters: - - description: current version - in: query - name: cur - required: true - type: string - - description: current_user - in: query - name: current_user - required: true - type: string + - description: current version + in: query + name: cur + required: true + type: string + - description: current_user + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.SyncVersionResponse" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.SyncVersionResponse' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get latest version tags: - - Sync + - Sync /tags: get: consumes: - - application/json + - application/json description: Get all tags parameters: - - description: category name - in: query - name: category - type: string - - description: scope name - enum: - - model - - dataset - in: query - name: scope - type: string + - description: category name + in: query + name: category + type: string + - description: scope name + enum: + - model + - dataset + in: query + name: scope + type: string produces: - - application/json + - application/json responses: "200": description: tags schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/database.Tag" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/database.Tag' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all tags tags: - - Tag + - Tag post: consumes: - - application/json + - application/json description: Create new tag parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateTag" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateTag' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create new tag tags: - - Tag + - Tag /tags/{id}: delete: consumes: - - application/json + - application/json description: Delete a tag by id parameters: - - description: id of the tag - in: path - name: id - required: true - type: string + - description: id of the tag + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a tag by id tags: - - Tag + - Tag get: consumes: - - application/json + - application/json description: Get a tag by id parameters: - - description: id of the tag - in: path - name: id - required: true - type: string + - description: id of the tag + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get a tag by id tags: - - Tag + - Tag put: consumes: - - application/json + - application/json description: Update a tag by id parameters: - - description: id of the tag - in: path - name: id - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateTag" + - description: id of the tag + in: path + name: id + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateTag' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Update a tag by id tags: - - Tag + - Tag /tags/categories: get: consumes: - - application/json + - application/json description: Get all Categories produces: - - application/json + - application/json responses: "200": description: categores schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/database.TagCategory" - type: array - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/database.TagCategory' + type: array + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all Categories tags: - - Tag + - Tag post: consumes: - - application/json + - application/json description: Create new category parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateCategory" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateCategory' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create new category tags: - - Tag + - Tag /tags/categories/id: delete: consumes: - - application/json + - application/json description: Delete a category by id produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete a category by id tags: - - Tag + - Tag put: consumes: - - application/json + - application/json description: Create new category parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateCategory" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateCategory' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create new category tags: - - Tag + - Tag /telemetry/usage: post: consumes: - - application/json + - application/json parameters: - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/telemetry.Usage" + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/telemetry.Usage' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Submit telemetry data for a client tags: - - Telemetry + - Telemetry /token/{app}/{token_name}: delete: consumes: - - application/json + - application/json parameters: - - description: application - enum: - - git - - starship - in: path - name: app - required: true - type: string - - description: token_name - in: path - name: token_name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - required: true - type: string + - description: application + enum: + - git + - starship + in: path + name: app + required: true + type: string + - description: token_name + in: path + name: token_name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete access token of a app tags: - - Access token + - Access token post: consumes: - - application/json + - application/json parameters: - - description: token name - in: path - name: token_name - required: true - type: string - - description: application - enum: - - git - - starship - in: path - name: app - required: true - type: string - - description: current user, the owner - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateUserTokenRequest" + - description: token name + in: path + name: token_name + required: true + type: string + - description: application + enum: + - git + - starship + in: path + name: app + required: true + type: string + - description: current user, the owner + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateUserTokenRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.AccessToken" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.AccessToken' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create access token for an special application tags: - - Access token + - Access token put: consumes: - - application/json + - application/json parameters: - - description: application - enum: - - git - - starship - in: path - name: app - required: true - type: string - - description: token_name - in: path - name: token_name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - required: true - type: string - - description: new expire time, in format RFC3339, like 2006-01-02T15:04:05Z07:00 - in: query - name: expired_at - type: string + - description: application + enum: + - git + - starship + in: path + name: app + required: true + type: string + - description: token_name + in: path + name: token_name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + required: true + type: string + - description: new expire time, in format RFC3339, like 2006-01-02T15:04:05Z07:00 + in: query + name: expired_at + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Refresh a access token for a user tags: - - Access token + - Access token /token/{token_value}: get: consumes: - - application/json + - application/json parameters: - - description: token_value - in: path - name: token_value - required: true - type: string - - description: application - enum: - - git - - starship - in: query - name: app - type: string + - description: token_value + in: path + name: token_value + required: true + type: string + - description: application + enum: + - git + - starship + in: query + name: app + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get token and owner's detail by the token value tags: - - Access token + - Access token /user/{username}: delete: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string - - description: current user - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateUserRequest" + - description: username + in: path + name: username + required: true + type: string + - description: current user + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateUserRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete user tags: - - User + - User get: consumes: - - application/json + - application/json parameters: - - description: username or uuid, defined by the query string 'type' - in: path - name: username - required: true - type: string - - description: current user - in: query - name: current_user - type: string - - description: path param is usernam or uuid, default to username - enum: - - username - - uuid - in: query - name: type - type: string + - description: username or uuid, defined by the query string 'type' + in: path + name: username + required: true + type: string + - description: current user + in: query + name: current_user + type: string + - description: path param is usernam or uuid, default to username + enum: + - username + - uuid + in: query + name: type + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/types.User" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/types.User' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] - summary: - Get user info. Admin and the user self can see full info, other users + - ApiKey: [] + summary: Get user info. Admin and the user self can see full info, other users can only see basic info. tags: - - User + - User put: consumes: - - application/json + - application/json description: update user parameters: - - description: username - in: path - name: username - required: true - type: string - - description: current user - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.UpdateUserRequest" + - description: username + in: path + name: username + required: true + type: string + - description: current user + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.UpdateUserRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] - summary: - Update user. If change user name, should only send 'new_username' in + - ApiKey: [] + summary: Update user. If change user name, should only send 'new_username' in the request body. tags: - - User + - User /user/{username}/codes: get: consumes: - - application/json + - application/json description: get user codes parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Code" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Code' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user codes tags: - - User + - User /user/{username}/collections: get: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Collection" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Collection' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user's collections tags: - - User + - User /user/{username}/datasets: get: consumes: - - application/json + - application/json description: get user datasets parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Dataset" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Dataset' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user datasets tags: - - User + - User /user/{username}/evaluations: get: consumes: - - application/json + - application/json description: get user evaluations parameters: - - description: username - in: path - name: username - required: true - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: username + in: path + name: username + required: true + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user evaluations tags: - - User + - User /user/{username}/finetune/instances: get: consumes: - - application/json + - application/json description: Get user running notebook instances parameters: - - description: username - in: path - name: username - required: true - type: string - - default: 50 - description: per - in: query - name: per - type: integer - - default: 1 - description: page index - in: query - name: page - type: integer - - description: current user - in: query - name: current_user - type: string + - description: username + in: path + name: username + required: true + type: string + - default: 50 + description: per + in: query + name: per + type: integer + - default: 1 + description: page index + in: query + name: page + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user running notebook instances tags: - - User + - User /user/{username}/likes/{repoid}: delete: consumes: - - application/json + - application/json description: Delete user likes parameters: - - description: username - in: path - name: username - required: true - type: string - - description: repo id - in: path - name: repo_id - required: true - type: string + - description: username + in: path + name: username + required: true + type: string + - description: repo id + in: path + name: repo_id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete user likes tags: - - User + - User put: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string - - description: repo id - in: path - name: repo_id - required: true - type: string + - description: username + in: path + name: username + required: true + type: string + - description: repo id + in: path + name: repo_id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Add user likes tags: - - User + - User /user/{username}/likes/codes: get: consumes: - - application/json + - application/json description: get user likes codes parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Code" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Code' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user likes codes tags: - - User + - User /user/{username}/likes/collections: get: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Collection" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Collection' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user likes collections tags: - - User + - User /user/{username}/likes/collections/{id}: delete: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string - - description: collection id - in: path - name: id - required: true - type: string + - description: username + in: path + name: username + required: true + type: string + - description: collection id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: delete collection likes tags: - - User + - User put: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string - - description: collection id - in: path - name: id - required: true - type: string + - description: username + in: path + name: username + required: true + type: string + - description: collection id + in: path + name: id + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Add collection likes tags: - - User + - User /user/{username}/likes/datasets: get: consumes: - - application/json + - application/json description: get user likes datasets parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Dataset" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Dataset' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user likes datasets tags: - - User + - User /user/{username}/likes/models: get: consumes: - - application/json + - application/json description: get user likes models parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Model" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Model' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user likes models tags: - - User + - User /user/{username}/likes/spaces: get: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Space" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Space' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user likes spaces tags: - - User + - User /user/{username}/models: get: consumes: - - application/json + - application/json description: get user models parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Model" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Model' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user models tags: - - User + - User /user/{username}/prompts: get: consumes: - - application/json + - application/json description: get user prompts parameters: - - description: username - in: path - name: username - required: true - type: string - - default: 20 - description: per - in: query - name: per - type: integer - - default: 1 - description: per page - in: query - name: page - type: integer + - description: username + in: path + name: username + required: true + type: string + - default: 20 + description: per + in: query + name: per + type: integer + - default: 1 + description: per page + in: query + name: page + type: integer produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user prompts tags: - - User + - User /user/{username}/run/{repo_type}: get: consumes: - - application/json + - application/json description: Get user running deploys parameters: - - description: username - in: path - name: username - required: true - type: string - - description: model,space - enum: - - model - - space - in: path - name: repo_type - required: true - type: string - - default: 1 - description: deploy type(0-space,1-inference,2-finetune) - enum: - - 0 - - 1 - - 2 - in: query - name: deploy_type - type: integer - - default: 50 - description: per - in: query - name: per - type: integer - - default: 1 - description: page index - in: query - name: page - type: integer - - description: current user - in: query - name: current_user - type: string + - description: username + in: path + name: username + required: true + type: string + - description: model,space + enum: + - model + - space + in: path + name: repo_type + required: true + type: string + - default: 1 + description: deploy type(0-space,1-inference,2-finetune) + enum: + - 0 + - 1 + - 2 + in: query + name: deploy_type + type: integer + - default: 50 + description: per + in: query + name: per + type: integer + - default: 1 + description: page index + in: query + name: page + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user running deploys tags: - - User + - User /user/{username}/run/serverless: get: consumes: - - application/json + - application/json description: Get serverless deploys parameters: - - description: username - in: path - name: username - required: true - type: string - - default: 50 - description: per - in: query - name: per - type: integer - - default: 1 - description: page index - in: query - name: page - type: integer - - description: current user - in: query - name: current_user - type: string + - description: username + in: path + name: username + required: true + type: string + - default: 50 + description: per + in: query + name: per + type: integer + - default: 1 + description: page index + in: query + name: page + type: integer + - description: current user + in: query + name: current_user + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get serverless deploys tags: - - User + - User /user/{username}/spaces: get: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/types.Space" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/types.Space' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get user spaces tags: - - User + - User /user/{username}/ssh_key/{name}: delete: consumes: - - application/json + - application/json description: delete specific SSH key for the given user parameters: - - description: username - in: path - name: username - required: true - type: string - - description: key name - in: path - name: name - required: true - type: string + - description: username + in: path + name: username + required: true + type: string + - description: key name + in: path + name: name + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Delete specific SSH key for the given user tags: - - SSH Key + - SSH Key /user/{username}/ssh_keys: get: consumes: - - application/json + - application/json description: get all SSH keys for the given user parameters: - - description: username - in: path - name: username - required: true - type: string + - description: username + in: path + name: username + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.ResponseWithTotal" - - properties: - data: - items: - $ref: "#/definitions/database.SSHKey" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.ResponseWithTotal' + - properties: + data: + items: + $ref: '#/definitions/database.SSHKey' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all SSH keys for the given user tags: - - SSH Key + - SSH Key post: consumes: - - application/json + - application/json description: create a new SSH key for the given user parameters: - - description: username - in: path - name: username - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateSSHKeyRequest" + - description: username + in: path + name: username + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateSSHKeyRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.SSHKey" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.SSHKey' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Create a new SSH key for the given user tags: - - SSH Key + - SSH Key /user/{username}/tokens: get: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string - - description: current user name - in: query - name: current_user - type: string - - description: application - enum: - - git - - starship - in: query - name: app - type: string + - description: username + in: path + name: username + required: true + type: string + - description: current user name + in: query + name: current_user + type: string + - description: application + enum: + - git + - starship + in: query + name: app + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get all access tokens for a user tags: - - Access token + - Access token post: consumes: - - application/json + - application/json description: create access token for a user parameters: - - description: username - in: path - name: username - required: true - type: string - - description: current user, the owner - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.CreateUserTokenRequest" + - description: username + in: path + name: username + required: true + type: string + - description: current user, the owner + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.CreateUserTokenRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - $ref: "#/definitions/database.AccessToken" - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + $ref: '#/definitions/database.AccessToken' + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] - summary: "[Deprecated: use POST:/token/{app}/{username} instead]" + - ApiKey: [] + summary: '[Deprecated: use POST:/token/{app}/{username} instead]' tags: - - Access token + - Access token /user/{username}/tokens/{token_name}: delete: consumes: - - application/json + - application/json parameters: - - description: username - in: path - name: username - required: true - type: string - - description: token_name - in: path - name: token_name - required: true - type: string - - description: current user, the owner - in: query - name: current_user - required: true - type: string - - description: body - in: body - name: body - required: true - schema: - $ref: "#/definitions/types.DeleteUserTokenRequest" + - description: username + in: path + name: username + required: true + type: string + - description: token_name + in: path + name: token_name + required: true + type: string + - description: current user, the owner + in: query + name: current_user + required: true + type: string + - description: body + in: body + name: body + required: true + schema: + $ref: '#/definitions/types.DeleteUserTokenRequest' produces: - - application/json + - application/json responses: "200": description: OK schema: - $ref: "#/definitions/types.Response" + $ref: '#/definitions/types.Response' "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] - summary: "[Deprecated: use DELETE:/token/{app}/{token_name} instead]" + - ApiKey: [] + summary: '[Deprecated: use DELETE:/token/{app}/{token_name} instead]' tags: - - Access token + - Access token /users: get: consumes: - - application/json + - application/json parameters: - - description: search - in: query - name: search - required: true - type: string + - description: search + in: query + name: search + required: true + type: string produces: - - application/json + - application/json responses: "200": description: OK schema: allOf: - - $ref: "#/definitions/types.Response" - - properties: - data: - items: - $ref: "#/definitions/types.User" - type: array - total: - type: integer - type: object + - $ref: '#/definitions/types.Response' + - properties: + data: + items: + $ref: '#/definitions/types.User' + type: array + total: + type: integer + type: object "400": description: Bad request schema: - $ref: "#/definitions/types.APIBadRequest" + $ref: '#/definitions/types.APIBadRequest' "500": description: Internal server error schema: - $ref: "#/definitions/types.APIInternalServerError" + $ref: '#/definitions/types.APIInternalServerError' security: - - ApiKey: [] + - ApiKey: [] summary: Get users info. Only Admin tags: - - User + - User securityDefinitions: ApiKey: description: Bearer token diff --git a/go.mod b/go.mod index 9b0b5765..f219f479 100644 --- a/go.mod +++ b/go.mod @@ -215,6 +215,7 @@ require ( require ( github.com/KyleBanks/depth v1.2.1 // indirect + github.com/XSAM/otelsql v0.36.0 github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 // indirect github.com/alibabacloud-go/debug v1.0.0 // indirect github.com/alibabacloud-go/endpoint-util v1.1.1 // indirect @@ -226,7 +227,7 @@ require ( github.com/argoproj/argo-workflows/v3 v3.5.12 github.com/blendle/zapdriver v1.3.1 // indirect github.com/bwmarrin/snowflake v0.3.0 - github.com/bytedance/sonic v1.12.5 // indirect + github.com/bytedance/sonic v1.12.6 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -237,6 +238,7 @@ require ( github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fatih/color v1.18.0 // indirect github.com/gabriel-vasile/mimetype v1.4.7 // indirect + github.com/gin-contrib/pprof v1.5.2 github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-fed/httpsig v1.1.0 // indirect github.com/go-logr/logr v1.4.2 // indirect @@ -300,7 +302,7 @@ require ( go.uber.org/zap v1.27.0 // indirect golang.org/x/arch v0.12.0 // indirect golang.org/x/crypto v0.31.0 - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.29.0 // indirect @@ -309,7 +311,7 @@ require ( golang.org/x/time v0.6.0 // indirect golang.org/x/tools v0.28.0 gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/protobuf v1.35.2 + google.golang.org/protobuf v1.36.1 gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect k8s.io/klog/v2 v2.130.1 // indirect diff --git a/go.sum b/go.sum index 082e6cdc..2ba8075d 100644 --- a/go.sum +++ b/go.sum @@ -50,6 +50,8 @@ github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA github.com/OpenCSGs/gitea-go-sdk/gitea v0.0.0-20240618091626-54fa52f1cec6 h1:akkXbOCa0CVnLNUrnu+qr3LoRmuVG4+eajsBogSh0Lk= github.com/OpenCSGs/gitea-go-sdk/gitea v0.0.0-20240618091626-54fa52f1cec6/go.mod h1:QDTH3lw9zQNfXxqapFE894/37UEE2KGVk5K0fzO0tXs= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/XSAM/otelsql v0.36.0 h1:SvrlOd/Hp0ttvI9Hu0FUWtISTTDNhQYwxe8WB4J5zxo= +github.com/XSAM/otelsql v0.36.0/go.mod h1:fo4M8MU+fCn/jDfu+JwTQ0n6myv4cZ+FU5VxrllIlxY= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 h1:iC9YFYKDGEy3n/FtqJnOkZsene9olVspKmkX5A2YBEo= github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4/go.mod h1:sCavSAvdzOjul4cEqeVtvlSaSScfNsTQ+46HwlTL1hc= @@ -117,6 +119,8 @@ github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgIS github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w= github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic v1.12.6 h1:/isNmCUF2x3Sh8RAp/4mh4ZGkcFAX/hLrzrK3AvpRzk= +github.com/bytedance/sonic v1.12.6/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E= github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= @@ -223,6 +227,8 @@ github.com/gin-contrib/cors v1.7.0 h1:wZX2wuZ0o7rV2/1i7gb4Jn+gW7HBqaP91fizJkBUJO github.com/gin-contrib/cors v1.7.0/go.mod h1:cI+h6iOAyxKRtUtC6iF/Si1KSFvGm/gK+kshxlCi8ro= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= +github.com/gin-contrib/pprof v1.5.2 h1:Kcq5W2bA2PBcVtF0MqkQjpvCpwJr+pd7zxcQh2csg7E= +github.com/gin-contrib/pprof v1.5.2/go.mod h1:a1W4CDXwAPm2zql2AKdnT7OVCJdV/oFPhJXVOrDs5Ns= github.com/gin-contrib/sessions v0.0.5 h1:CATtfHmLMQrMNpJRgzjWXD7worTh7g7ritsQfmF+0jE= github.com/gin-contrib/sessions v0.0.5/go.mod h1:vYAuaUPqie3WUSsft6HUlCjlwwoJQs97miaG2+7neKY= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -908,6 +914,8 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1080,6 +1088,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/DataDog/dd-trace-go.v1 v1.32.0 h1:DkD0plWEVUB8v/Ru6kRBW30Hy/fRNBC8hPdcExuBZMc= gopkg.in/DataDog/dd-trace-go.v1 v1.32.0/go.mod h1:wRKMf/tRASHwH/UOfPQ3IQmVFhTz2/1a1/mpXoIjF54= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=