Files
XingfenD b8490ef422 feat(rcs): migrate all RCS APIs from rainyun-go-sdk
- 35 endpoints across 14 files, response structs split for reuse
- Reuse RcsRecord/Node/Plan/OsInfo/UsageData across list/detail/create
- Fix source bugs: {id} path placeholders, missing / in firewall pos path,
  missing body in ChargeRcsTrafic, resp vs &resp
- Add HTTPMethod_PATCH, common.BasicOperationResponse, VncConnectionInfo
2026-08-05 22:35:28 +08:00

65 lines
1.9 KiB
Go

package rcs
import (
"fmt"
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
type ResetRcsPasswordRequest struct {
Password string `json:"password"` // 新密码,留空则自动生成
}
type SetRcsTagRequest struct {
TagName string `json:"tag_name"`
}
func (s *RcsService) FreeRcs(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rcs/%d/free", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
func (s *RcsService) RebootRcs(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rcs/%d/reboot", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
func (s *RcsService) ResetRcsPassword(id int, newPass string) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rcs/%d/reset-password", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, ResetRcsPasswordRequest{Password: newPass}, &resp)
return &resp, err
}
func (s *RcsService) StartRcs(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rcs/%d/start", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
func (s *RcsService) StopRcs(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rcs/%d/stop", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
func (s *RcsService) SetRcsTag(id int, tag string) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rcs/%d/tag", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, SetRcsTagRequest{TagName: tag}, &resp)
return &resp, err
}