You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pub_shards.go 2.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package api
  2. import (
  3. "net/http"
  4. "gitlink.org.cn/cloudream/common/sdks"
  5. jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
  6. )
  7. type PubShardsService struct {
  8. *Client
  9. }
  10. func (c *Client) PubShards() *PubShardsService {
  11. return &PubShardsService{
  12. Client: c,
  13. }
  14. }
  15. const PubShardsCreatePath = "/pubShards/create"
  16. type PubShardsCreate struct {
  17. Name string `json:"name"`
  18. Storage jcstypes.StorageType `json:"storage"`
  19. Credential jcstypes.StorageCredential `json:"credential"`
  20. ShardStore jcstypes.ShardStoreUserConfig `json:"shardStore"`
  21. Features []jcstypes.StorageFeature `json:"features"`
  22. WorkingDir string `json:"workingDir"`
  23. Password string `json:"password"`
  24. MasterHub jcstypes.HubID `json:"masterHub"`
  25. }
  26. func (r *PubShardsCreate) MakeParam() *sdks.RequestParam {
  27. return sdks.MakeJSONParam(http.MethodPost, PubShardsCreatePath, r)
  28. }
  29. type PubShardsCreateResp struct {
  30. PubShards jcstypes.PubShards `json:"pubShards"`
  31. }
  32. func (r *PubShardsCreateResp) ParseResponse(resp *http.Response) error {
  33. return sdks.ParseCodeDataJSONResponse(resp, r)
  34. }
  35. func (c *PubShardsService) Create(req PubShardsCreate) (*PubShardsCreateResp, error) {
  36. return JSONAPI(&c.cfg, c.httpCli, &req, &PubShardsCreateResp{})
  37. }
  38. const PubShardsJoinPath = "/pubShards/join"
  39. type PubShardsJoin struct {
  40. Name string `json:"name"`
  41. PubShardsID jcstypes.PubShardsID `json:"pubShardID"`
  42. Password string `json:"password"`
  43. }
  44. func (r *PubShardsJoin) MakeParam() *sdks.RequestParam {
  45. return sdks.MakeJSONParam(http.MethodPost, PubShardsJoinPath, r)
  46. }
  47. type PubShardsJoinResp struct {
  48. PubShards jcstypes.PubShards `json:"pubShards"`
  49. UserSpace jcstypes.UserSpace `json:"userSpace"`
  50. }
  51. func (r *PubShardsJoinResp) ParseResponse(resp *http.Response) error {
  52. return sdks.ParseCodeDataJSONResponse(resp, r)
  53. }
  54. func (c *PubShardsService) Join(req PubShardsJoin) (*PubShardsJoinResp, error) {
  55. return JSONAPI(&c.cfg, c.httpCli, &req, &PubShardsJoinResp{})
  56. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。