diff --git a/venus-shared/api/market/api.go b/venus-shared/api/market/api.go index 9dfb543f5b..0d51069564 100644 --- a/venus-shared/api/market/api.go +++ b/venus-shared/api/market/api.go @@ -147,4 +147,12 @@ type IMarket interface { GetWriteUrl(ctx context.Context, resource string) (string, error) //perm:read ImportV1Data(ctx context.Context, src string) error //perm:write + + AddFsPieceStorage(ctx context.Context, readonly bool, path string, name string) error //perm:admin + + AddS3PieceStorage(ctx context.Context, readonly bool, endpoit, name, key, secret, token string) error //perm:admin + + RemovePieceStorage(ctx context.Context, name string) error //perm:admin + + GetPieceStorages(ctx context.Context) market.PieceStorageList //perm:read } diff --git a/venus-shared/api/market/method.md b/venus-shared/api/market/method.md index 610338a021..e7006bf078 100644 --- a/venus-shared/api/market/method.md +++ b/venus-shared/api/market/method.md @@ -4,6 +4,8 @@ * [ActorExist](#ActorExist) * [ActorList](#ActorList) * [ActorSectorSize](#ActorSectorSize) + * [AddFsPieceStorage](#AddFsPieceStorage) + * [AddS3PieceStorage](#AddS3PieceStorage) * [AssignUnPackedDeals](#AssignUnPackedDeals) * [DagstoreGC](#DagstoreGC) * [DagstoreInitializeAll](#DagstoreInitializeAll) @@ -26,6 +28,7 @@ * [DealsSetConsiderVerifiedStorageDeals](#DealsSetConsiderVerifiedStorageDeals) * [DealsSetPieceCidBlocklist](#DealsSetPieceCidBlocklist) * [GetDeals](#GetDeals) + * [GetPieceStorages](#GetPieceStorages) * [GetReadUrl](#GetReadUrl) * [GetUnPackedDeals](#GetUnPackedDeals) * [GetWriteUrl](#GetWriteUrl) @@ -65,6 +68,7 @@ * [PiecesGetPieceInfo](#PiecesGetPieceInfo) * [PiecesListCidInfos](#PiecesListCidInfos) * [PiecesListPieces](#PiecesListPieces) + * [RemovePieceStorage](#RemovePieceStorage) * [ResponseMarketEvent](#ResponseMarketEvent) * [SectorGetSealDelay](#SectorGetSealDelay) * [SectorSetExpectedSealDuration](#SectorSetExpectedSealDuration) @@ -119,6 +123,41 @@ Inputs: Response: `34359738368` +### AddFsPieceStorage + + +Perms: admin + +Inputs: +```json +[ + true, + "string value", + "string value" +] +``` + +Response: `{}` + +### AddS3PieceStorage + + +Perms: admin + +Inputs: +```json +[ + true, + "string value", + "string value", + "string value", + "string value", + "string value" +] +``` + +Response: `{}` + ### AssignUnPackedDeals @@ -538,6 +577,33 @@ Response: ] ``` +### GetPieceStorages + + +Perms: read + +Inputs: `[]` + +Response: +```json +{ + "FsStorage": [ + { + "Path": "string value", + "Name": "string value", + "ReadOnly": true + } + ], + "S3Storage": [ + { + "Name": "string value", + "ReadOnly": true, + "EndPoint": "string value" + } + ] +} +``` + ### GetReadUrl piece storage @@ -1663,6 +1729,20 @@ Response: ] ``` +### RemovePieceStorage + + +Perms: admin + +Inputs: +```json +[ + "string value" +] +``` + +Response: `{}` + ### ResponseMarketEvent market event diff --git a/venus-shared/api/market/mock/mock_imarket.go b/venus-shared/api/market/mock/mock_imarket.go index 8ffd4d7baf..bbedc2ae8b 100644 --- a/venus-shared/api/market/mock/mock_imarket.go +++ b/venus-shared/api/market/mock/mock_imarket.go @@ -94,6 +94,34 @@ func (mr *MockIMarketMockRecorder) ActorSectorSize(arg0, arg1 interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ActorSectorSize", reflect.TypeOf((*MockIMarket)(nil).ActorSectorSize), arg0, arg1) } +// AddFsPieceStorage mocks base method. +func (m *MockIMarket) AddFsPieceStorage(arg0 context.Context, arg1 bool, arg2, arg3 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddFsPieceStorage", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddFsPieceStorage indicates an expected call of AddFsPieceStorage. +func (mr *MockIMarketMockRecorder) AddFsPieceStorage(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddFsPieceStorage", reflect.TypeOf((*MockIMarket)(nil).AddFsPieceStorage), arg0, arg1, arg2, arg3) +} + +// AddS3PieceStorage mocks base method. +func (m *MockIMarket) AddS3PieceStorage(arg0 context.Context, arg1 bool, arg2, arg3, arg4, arg5, arg6 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddS3PieceStorage", arg0, arg1, arg2, arg3, arg4, arg5, arg6) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddS3PieceStorage indicates an expected call of AddS3PieceStorage. +func (mr *MockIMarketMockRecorder) AddS3PieceStorage(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddS3PieceStorage", reflect.TypeOf((*MockIMarket)(nil).AddS3PieceStorage), arg0, arg1, arg2, arg3, arg4, arg5, arg6) +} + // AssignUnPackedDeals mocks base method. func (m *MockIMarket) AssignUnPackedDeals(arg0 context.Context, arg1 abi.SectorID, arg2 abi.SectorSize, arg3 *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) { m.ctrl.T.Helper() @@ -414,6 +442,20 @@ func (mr *MockIMarketMockRecorder) GetDeals(arg0, arg1, arg2, arg3 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeals", reflect.TypeOf((*MockIMarket)(nil).GetDeals), arg0, arg1, arg2, arg3) } +// GetPieceStorages mocks base method. +func (m *MockIMarket) GetPieceStorages(arg0 context.Context) market.PieceStorageList { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPieceStorages", arg0) + ret0, _ := ret[0].(market.PieceStorageList) + return ret0 +} + +// GetPieceStorages indicates an expected call of GetPieceStorages. +func (mr *MockIMarketMockRecorder) GetPieceStorages(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPieceStorages", reflect.TypeOf((*MockIMarket)(nil).GetPieceStorages), arg0) +} + // GetReadUrl mocks base method. func (m *MockIMarket) GetReadUrl(arg0 context.Context, arg1 string) (string, error) { m.ctrl.T.Helper() @@ -989,6 +1031,20 @@ func (mr *MockIMarketMockRecorder) PiecesListPieces(arg0 interface{}) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PiecesListPieces", reflect.TypeOf((*MockIMarket)(nil).PiecesListPieces), arg0) } +// RemovePieceStorage mocks base method. +func (m *MockIMarket) RemovePieceStorage(arg0 context.Context, arg1 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemovePieceStorage", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemovePieceStorage indicates an expected call of RemovePieceStorage. +func (mr *MockIMarketMockRecorder) RemovePieceStorage(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemovePieceStorage", reflect.TypeOf((*MockIMarket)(nil).RemovePieceStorage), arg0, arg1) +} + // ResponseMarketEvent mocks base method. func (m *MockIMarket) ResponseMarketEvent(arg0 context.Context, arg1 *gateway.ResponseEvent) error { m.ctrl.T.Helper() diff --git a/venus-shared/api/market/proxy_gen.go b/venus-shared/api/market/proxy_gen.go index beda8a19fc..bf53789639 100644 --- a/venus-shared/api/market/proxy_gen.go +++ b/venus-shared/api/market/proxy_gen.go @@ -25,6 +25,8 @@ type IMarketStruct struct { ActorExist func(ctx context.Context, addr address.Address) (bool, error) `perm:"read"` ActorList func(context.Context) ([]market.User, error) `perm:"read"` ActorSectorSize func(context.Context, address.Address) (abi.SectorSize, error) `perm:"read"` + AddFsPieceStorage func(ctx context.Context, readonly bool, path string, name string) error `perm:"admin"` + AddS3PieceStorage func(ctx context.Context, readonly bool, endpoit, name, key, secret, token string) error `perm:"admin"` AssignUnPackedDeals func(ctx context.Context, sid abi.SectorID, ssize abi.SectorSize, spec *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) `perm:"write"` DagstoreGC func(ctx context.Context) ([]market.DagstoreShardResult, error) `perm:"admin"` DagstoreInitializeAll func(ctx context.Context, params market.DagstoreInitializeAllParams) (<-chan market.DagstoreInitializeAllEvent, error) `perm:"write"` @@ -47,6 +49,7 @@ type IMarketStruct struct { DealsSetConsiderVerifiedStorageDeals func(context.Context, bool) error `perm:"admin"` DealsSetPieceCidBlocklist func(context.Context, []cid.Cid) error `perm:"admin"` GetDeals func(ctx context.Context, miner address.Address, pageIndex, pageSize int) ([]*market.DealInfo, error) `perm:"read"` + GetPieceStorages func(ctx context.Context) market.PieceStorageList `perm:"read"` GetReadUrl func(context.Context, string) (string, error) `perm:"read"` GetUnPackedDeals func(ctx context.Context, miner address.Address, spec *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) `perm:"read"` GetWriteUrl func(ctx context.Context, resource string) (string, error) `perm:"read"` @@ -86,6 +89,7 @@ type IMarketStruct struct { PiecesGetPieceInfo func(ctx context.Context, pieceCid cid.Cid) (*piecestore.PieceInfo, error) `perm:"read"` PiecesListCidInfos func(ctx context.Context) ([]cid.Cid, error) `perm:"read"` PiecesListPieces func(ctx context.Context) ([]cid.Cid, error) `perm:"read"` + RemovePieceStorage func(ctx context.Context, name string) error `perm:"admin"` ResponseMarketEvent func(ctx context.Context, resp *gateway.ResponseEvent) error `perm:"read"` SectorGetSealDelay func(context.Context) (time.Duration, error) `perm:"read"` SectorSetExpectedSealDuration func(context.Context, time.Duration) error `perm:"write"` @@ -104,6 +108,12 @@ func (s *IMarketStruct) ActorList(p0 context.Context) ([]market.User, error) { func (s *IMarketStruct) ActorSectorSize(p0 context.Context, p1 address.Address) (abi.SectorSize, error) { return s.Internal.ActorSectorSize(p0, p1) } +func (s *IMarketStruct) AddFsPieceStorage(p0 context.Context, p1 bool, p2 string, p3 string) error { + return s.Internal.AddFsPieceStorage(p0, p1, p2, p3) +} +func (s *IMarketStruct) AddS3PieceStorage(p0 context.Context, p1 bool, p2, p3, p4, p5, p6 string) error { + return s.Internal.AddS3PieceStorage(p0, p1, p2, p3, p4, p5, p6) +} func (s *IMarketStruct) AssignUnPackedDeals(p0 context.Context, p1 abi.SectorID, p2 abi.SectorSize, p3 *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) { return s.Internal.AssignUnPackedDeals(p0, p1, p2, p3) } @@ -170,6 +180,9 @@ func (s *IMarketStruct) DealsSetPieceCidBlocklist(p0 context.Context, p1 []cid.C func (s *IMarketStruct) GetDeals(p0 context.Context, p1 address.Address, p2, p3 int) ([]*market.DealInfo, error) { return s.Internal.GetDeals(p0, p1, p2, p3) } +func (s *IMarketStruct) GetPieceStorages(p0 context.Context) market.PieceStorageList { + return s.Internal.GetPieceStorages(p0) +} func (s *IMarketStruct) GetReadUrl(p0 context.Context, p1 string) (string, error) { return s.Internal.GetReadUrl(p0, p1) } @@ -285,6 +298,9 @@ func (s *IMarketStruct) PiecesListCidInfos(p0 context.Context) ([]cid.Cid, error func (s *IMarketStruct) PiecesListPieces(p0 context.Context) ([]cid.Cid, error) { return s.Internal.PiecesListPieces(p0) } +func (s *IMarketStruct) RemovePieceStorage(p0 context.Context, p1 string) error { + return s.Internal.RemovePieceStorage(p0, p1) +} func (s *IMarketStruct) ResponseMarketEvent(p0 context.Context, p1 *gateway.ResponseEvent) error { return s.Internal.ResponseMarketEvent(p0, p1) } diff --git a/venus-shared/types/market/piecestorage.go b/venus-shared/types/market/piecestorage.go new file mode 100644 index 0000000000..830bb85d6a --- /dev/null +++ b/venus-shared/types/market/piecestorage.go @@ -0,0 +1,18 @@ +package market + +type PieceStorageList struct { + FsStorage []FsStorage + S3Storage []S3Storage +} + +type FsStorage struct { + Path string + Name string + ReadOnly bool +} + +type S3Storage struct { + Name string + ReadOnly bool + EndPoint string +}