feat: migrate all remaining modules from rainyun-go-sdk

- domain(24), product(8), rbm(10), rca(21), rgs(38), ros(19),
  ssl(5), user(10), workorder(11), public remaining 5
- split nested response structs into reusable named types
- rgs reuses rcs request/response types
- fix source bugs: malformed paths, resp vs &resp, missing bodies
- register all 11 services in sdk.New
This commit is contained in:
2026-08-05 23:09:53 +08:00
parent b8490ef422
commit 51b7e2f319
56 changed files with 4267 additions and 2 deletions
+22
View File
@@ -0,0 +1,22 @@
package rbm
import (
"fmt"
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
// RBM实例更换系统请求
type RBMChangeOSRequest struct {
OsID int `json:"os_id"`
}
// RBM实例更换系统
func (s *RbmService) ChangeRBMOS(id int, req *RBMChangeOSRequest) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/changeos", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
return &resp, err
}
+11
View File
@@ -0,0 +1,11 @@
package rbm
import "github.com/XingfenD/rainyun_api_go_sdk/apis"
type RbmService struct {
client *apis.RyClient
}
func NewRbmService(c *apis.RyClient) *RbmService {
return &RbmService{client: c}
}
+60
View File
@@ -0,0 +1,60 @@
package rbm
import (
"fmt"
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
// 创建并绑定弹性IP到RBM请求
type RBMAssociateEIPRequest struct {
WithFlags string `json:"with_flags"` // IP特征(可选)
WithIPNum int `json:"with_ip_num"` // 数量
WithIPType string `json:"with_ip_type"` // IPv4/IPv6
}
// 更换IP请求
type RBMChangeIPRequest struct {
DisableOldIPReason string `json:"disable_old_ip_reason"` // 禁用旧IP的原因(可选)
IP string `json:"ip"` // 旧IP地址
ToIP string `json:"to_ip"` // 不明,可选
}
// 设置IP描述请求
type RBMSetIPDescriptionRequest struct {
Description string `json:"description"`
IP string `json:"ip"`
}
// 放弃IP请求
type RBMReleaseIPRequest struct {
IP string `json:"ip"`
}
// 创建并绑定弹性IP到RBM
func (s *RbmService) AssociateEIP(id int, req *RBMAssociateEIPRequest) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/eip", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
return &resp, err
}
// 设置IP描述
func (s *RbmService) SetIPDescription(id int, req *RBMSetIPDescriptionRequest) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/eip/description", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
return &resp, err
}
// 放弃IP
func (s *RbmService) ReleaseIP(id int, req *RBMReleaseIPRequest) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/eip/discard", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
return &resp, err
}
+44
View File
@@ -0,0 +1,44 @@
package rbm
import (
"fmt"
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
// RBM实例启动KVM代理
func (s *RbmService) StartKVMAgent(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/kvm-proxy", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
// RBM重新启动KVM
func (s *RbmService) RestartKVM(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/kvm-reboot", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
// RBM实例关机
func (s *RbmService) ShutdownRBM(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/poweroff", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
// RBM实例开机
func (s *RbmService) StartRBM(id int) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/poweron", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
return &resp, err
}
+42
View File
@@ -0,0 +1,42 @@
package rbm
import "github.com/XingfenD/rainyun_api_go_sdk/constant"
type GetRbmPlanListResponse struct {
Code int `json:"code"`
Data []RbmPlan `json:"data"`
}
// RbmPlan RBM套餐
type RbmPlan struct {
ID int `json:"id"` // 套餐ID
Region string `json:"region"` // 地域
Line string `json:"line"` // 线路 3c/single/bgp
Subtype string `json:"subtype"` // rbm
PlanName string `json:"plan_name"` // 套餐名称
Machine string `json:"machine"` // 意义不明 generic/generic_2
ChargeType string `json:"charge_type"` // 计费方式 package(流量不限)/package_traffic(流量叠加)
Chinese string `json:"chinese"` // 中文名
IsFree bool `json:"is_free"` // 是否免费(为什么会有这种参数)
PointRenewPrice any `json:"point_renew_price"` // 积分续费价格,全是 null
IsSelling bool `json:"is_selling"` // 是否在售
Price int `json:"price"` // 价格
TrafficBaseGb int `json:"traffic_base_gb"` // 流量基数,单位GB
TrafficPrice any `json:"traffic_price"` // 流量价格,单位GB,package_traffic 计费方式才有值
CPU int `json:"cpu"` // cpu核数
Memory int `json:"memory"` // 内存,单位GB
Storage int `json:"storage"` // 存储,单位GB
NetIn int `json:"net_in"` // 入网带宽,单位Mbps
NetOut int `json:"net_out"` // 出网带宽,单位Mbps
AvailableStock int `json:"available_stock"` // 可用库存
IPPrices any `json:"ip_prices"` // IP价格,单位元/月
}
// 获取RBM套餐列表
func (s *RbmService) GetRBMPlanList() (*GetRbmPlanListResponse, error) {
path := "/product/rbm/models"
var resp GetRbmPlanListResponse
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
return &resp, err
}
+22
View File
@@ -0,0 +1,22 @@
package rbm
import (
"fmt"
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
"github.com/XingfenD/rainyun_api_go_sdk/constant"
)
// 充流量请求
type RBMChargeTrafficRequest struct {
TrafficInGb int `json:"traffic_in_gb"`
}
// 充流量
func (s *RbmService) ChargeTraffic(id int, req *RBMChargeTrafficRequest) (*common.BasicOperationResponse, error) {
path := fmt.Sprintf("/product/rbm/%d/traffic/charge", id)
var resp common.BasicOperationResponse
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
return &resp, err
}