|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package api
-
- import (
- "net/http"
-
- "gitlink.org.cn/cloudream/common/sdks"
- jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
- )
-
- type PubShardsService struct {
- *Client
- }
-
- func (c *Client) PubShards() *PubShardsService {
- return &PubShardsService{
- Client: c,
- }
- }
-
- const PubShardsCreatePath = "/pubShards/create"
-
- type PubShardsCreate struct {
- Name string `json:"name"`
- Storage jcstypes.StorageType `json:"storage"`
- Credential jcstypes.StorageCredential `json:"credential"`
- ShardStore jcstypes.ShardStoreUserConfig `json:"shardStore"`
- Features []jcstypes.StorageFeature `json:"features"`
- WorkingDir string `json:"workingDir"`
- Password string `json:"password"`
- MasterHub jcstypes.HubID `json:"masterHub"`
- }
-
- func (r *PubShardsCreate) MakeParam() *sdks.RequestParam {
- return sdks.MakeJSONParam(http.MethodPost, PubShardsCreatePath, r)
- }
-
- type PubShardsCreateResp struct {
- PubShards jcstypes.PubShards `json:"pubShards"`
- }
-
- func (r *PubShardsCreateResp) ParseResponse(resp *http.Response) error {
- return sdks.ParseCodeDataJSONResponse(resp, r)
- }
-
- func (c *PubShardsService) Create(req PubShardsCreate) (*PubShardsCreateResp, error) {
- return JSONAPI(&c.cfg, c.httpCli, &req, &PubShardsCreateResp{})
- }
-
- const PubShardsJoinPath = "/pubShards/join"
-
- type PubShardsJoin struct {
- Name string `json:"name"`
- PubShardsID jcstypes.PubShardsID `json:"pubShardID"`
- Password string `json:"password"`
- }
-
- func (r *PubShardsJoin) MakeParam() *sdks.RequestParam {
- return sdks.MakeJSONParam(http.MethodPost, PubShardsJoinPath, r)
- }
-
- type PubShardsJoinResp struct {
- PubShards jcstypes.PubShards `json:"pubShards"`
- UserSpace jcstypes.UserSpace `json:"userSpace"`
- }
-
- func (r *PubShardsJoinResp) ParseResponse(resp *http.Response) error {
- return sdks.ParseCodeDataJSONResponse(resp, r)
- }
-
- func (c *PubShardsService) Join(req PubShardsJoin) (*PubShardsJoinResp, error) {
- return JSONAPI(&c.cfg, c.httpCli, &req, &PubShardsJoinResp{})
- }
|