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:
@@ -0,0 +1,68 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 游戏云创建备份
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
//
|
||||
// label: 备份标签
|
||||
func (s *RgsService) CreateRgsBackup(id int, label string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/backup", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, rcs.CreateRcsBackupRequest{Label: label}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云删除备份
|
||||
//
|
||||
// id: 游戏云 ID, bid: 备份ID
|
||||
func (s *RgsService) DeleteRgsBackup(id, bid int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/backup/%d", id, bid)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_DELETE, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云取消备份
|
||||
//
|
||||
// id: RGS ID, bid: 备份ID
|
||||
func (s *RgsService) CancelRgsBackup(id, bid int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/backup/%d/cancel", id, bid)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云还原备份
|
||||
//
|
||||
// id: 游戏云 ID, bid: 备份ID
|
||||
func (s *RgsService) RestoreRgsBackup(id, bid int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/backup/%d/restore", id, bid)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云设置备份选项
|
||||
//
|
||||
// id: RGS ID
|
||||
//
|
||||
// 没错就是Rcs,这俩是一样的
|
||||
func (s *RgsService) EnableRgsAutoBackup(id int, req *rcs.RcsSetBackupOptionsRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/backup/setting", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 游戏云重装系统
|
||||
//
|
||||
// id: RGS ID
|
||||
func (s *RgsService) ReinstallRgs(id int, req *rcs.ReinstallRcsRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/changeos", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package rgs
|
||||
|
||||
import "github.com/XingfenD/rainyun_api_go_sdk/apis"
|
||||
|
||||
type RgsService struct {
|
||||
client *apis.RyClient
|
||||
}
|
||||
|
||||
func NewRgsService(c *apis.RyClient) *RgsService {
|
||||
return &RgsService{client: c}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package rgs
|
||||
|
||||
import "github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
|
||||
// 创建游戏云请求
|
||||
type CreateRgsRequest struct {
|
||||
AppVars []RgsAppVar `json:"app_vars"` // 当空数组时,进行单次任务下发(可选)
|
||||
Config RgsConfig `json:"config"`
|
||||
CPULimitMode bool `json:"cpu_limit_mode"`
|
||||
Duration int `json:"duration"` // 创建时长(月)
|
||||
EggTypeID int `json:"egg_type_id"` // 游戏类型
|
||||
NodeUUID string `json:"node_uuid"`
|
||||
OnlineMode bool `json:"online_mode"`
|
||||
OsID int `json:"os_id"`
|
||||
PanelUser string `json:"panel_user"` // 游戏云面板用户
|
||||
PayMode string `json:"pay_mode"`
|
||||
PlanID int `json:"plan_id"`
|
||||
Subtype string `json:"subtype"` // kvm/mcsm
|
||||
Try bool `json:"try"`
|
||||
WithCouponID int `json:"with_coupon_id"`
|
||||
WithEipFlags string `json:"with_eip_flags"` // 是否开启高防,us_ddosip -> 美国高防,nb_ddosip -> 宁波高防
|
||||
WithEipNum int `json:"with_eip_num"`
|
||||
WithEipType string `json:"with_eip_type"`
|
||||
Zone string `json:"zone"`
|
||||
}
|
||||
|
||||
type RgsAppVar struct {
|
||||
AppID int `json:"app_id"`
|
||||
Retry bool `json:"retry"` // 重发之前的任务,此项存在时,无需传入参数
|
||||
Vars any `json:"vars"`
|
||||
}
|
||||
|
||||
// 游戏云配置信息
|
||||
type RgsConfig struct {
|
||||
CPU int `json:"cpu"`
|
||||
Memory int `json:"memory"`
|
||||
NetOut int `json:"net_out"`
|
||||
NetIn int `json:"net_in"`
|
||||
BaseDisk int `json:"base_disk"`
|
||||
DataDisk int `json:"data_disk"`
|
||||
Allocation int `json:"allocation"`
|
||||
Database int `json:"database"`
|
||||
Backup int `json:"backup"`
|
||||
}
|
||||
|
||||
// 创建游戏云响应
|
||||
type CreateRgsResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RgsCreateData `json:"data"`
|
||||
}
|
||||
|
||||
// RgsCreateData 创建游戏云返回的完整实例数据
|
||||
type RgsCreateData struct {
|
||||
RgsRecord
|
||||
Node RgsNode `json:"Node"` // 节点信息
|
||||
Plan RgsPlan `json:"Plan"`
|
||||
EggTypeID int `json:"EggTypeId"`
|
||||
EggType any `json:"EggType"`
|
||||
PteroUserName string `json:"PteroUserName"`
|
||||
PteroUser any `json:"PteroUser"`
|
||||
ServerID int `json:"ServerID"`
|
||||
AllocationID int `json:"AllocationID"`
|
||||
ServerUUID string `json:"ServerUUID"`
|
||||
DaemonUUID string `json:"DaemonUUID"`
|
||||
GameInfo any `json:"GameInfo"`
|
||||
}
|
||||
|
||||
type RgsNode struct {
|
||||
UUID string `json:"UUID"`
|
||||
AuthKey string `json:"AuthKey"`
|
||||
Region string `json:"Region"`
|
||||
IPRegion string `json:"IpRegion"`
|
||||
Machine string `json:"Machine"`
|
||||
Product string `json:"Product"`
|
||||
Subtype string `json:"Subtype"`
|
||||
ChineseName string `json:"ChineseName"`
|
||||
PhysicalNode string `json:"PhysicalNode"`
|
||||
Config string `json:"Config"`
|
||||
Stock any `json:"Stock"`
|
||||
StatusData string `json:"StatusData"`
|
||||
ShowMonitorData string `json:"ShowMonitorData"`
|
||||
UpdateTime string `json:"UpdateTime"`
|
||||
GitRepositoryName string `json:"GitRepositoryName"`
|
||||
CertifyRequired bool `json:"CertifyRequired"`
|
||||
IsDisableBackup bool `json:"IsDisableBackup"`
|
||||
IsHidden bool `json:"IsHidden"`
|
||||
NodeName string `json:"NodeName"`
|
||||
}
|
||||
|
||||
type RgsPlan struct {
|
||||
ID int `json:"id"`
|
||||
Region string `json:"region"`
|
||||
Subtype string `json:"subtype"`
|
||||
PlanName string `json:"plan_name"`
|
||||
Machine string `json:"machine"`
|
||||
ChargeType string `json:"charge_type"`
|
||||
Chinese string `json:"chinese"`
|
||||
IsFree bool `json:"is_free"`
|
||||
PointRenewPrice any `json:"point_renew_price"`
|
||||
IsSelling bool `json:"is_selling"`
|
||||
StockDiscount int `json:"stock_discount"`
|
||||
EipStockDiscount int `json:"eip_stock_discount"`
|
||||
IPPrices any `json:"ip_prices"`
|
||||
IPSelling any `json:"ip_selling"`
|
||||
CPUPrice int `json:"cpu_price"`
|
||||
MemoryPrice int `json:"memory_price"`
|
||||
NetInPrice int `json:"net_in_price"`
|
||||
NetOutPrice int `json:"net_out_price"`
|
||||
BaseDiskPrice int `json:"base_disk_price"`
|
||||
DataDiskPrice int `json:"data_disk_price"`
|
||||
Config []RgsPlanConfig `json:"config"` // 这里不知道为什么要返还一堆套餐列表
|
||||
AutoRestock int `json:"auto_restock"`
|
||||
AvailableStock int `json:"available_stock"`
|
||||
CPUPointDefault int `json:"cpu_point_default"`
|
||||
CPUPointConsume int `json:"cpu_point_consume"`
|
||||
CPUPointPrice float64 `json:"cpu_point_price"`
|
||||
CPUBase float64 `json:"cpu_base"`
|
||||
CPUMax int `json:"cpu_max"`
|
||||
EipPrice int `json:"eip_price"`
|
||||
DefencePrice int `json:"defence_price"`
|
||||
AllocationPrice int `json:"allocation_price"`
|
||||
DatabasePrice int `json:"database_price"`
|
||||
BackupPrice int `json:"backup_price"`
|
||||
DailyModeSupport bool `json:"daily_mode_support"`
|
||||
DailyPriceScale int `json:"daily_price_scale"`
|
||||
}
|
||||
|
||||
type RgsPlanConfig struct {
|
||||
CPU int `json:"cpu"`
|
||||
Memory int `json:"memory"`
|
||||
NetIn int `json:"net_in,omitempty"`
|
||||
CPUMax int `json:"cpu_max,omitempty"`
|
||||
CPUMin int `json:"cpu_min,omitempty"`
|
||||
NetOut int `json:"net_out"`
|
||||
BaseDisk int `json:"base_disk,omitempty"`
|
||||
DataDisk int `json:"data_disk,omitempty"`
|
||||
BasePrice int `json:"base_price"`
|
||||
MemoryMax int `json:"memory_max"`
|
||||
MemoryMin int `json:"memory_min"`
|
||||
NetInMax int `json:"net_in_max,omitempty"`
|
||||
NetInMin int `json:"net_in_min,omitempty"`
|
||||
NetOutMax int `json:"net_out_max,omitempty"`
|
||||
NetOutMin int `json:"net_out_min"`
|
||||
BaseDiskMax int `json:"base_disk_max,omitempty"`
|
||||
BaseDiskMin int `json:"base_disk_min,omitempty"`
|
||||
DataDiskMax int `json:"data_disk_max,omitempty"`
|
||||
DataDiskMin int `json:"data_disk_min,omitempty"`
|
||||
}
|
||||
|
||||
// 创建游戏云
|
||||
func (s *RgsService) CreateRgs(req *CreateRgsRequest) (*CreateRgsResponse, error) {
|
||||
path := "/product/rgs"
|
||||
|
||||
var resp CreateRgsResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 创建并绑定弹性IP到游戏云
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) CreateAndBindElasticIpToRgs(id int, req *rcs.CreateAndBindIpToRcsRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/eip", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 更换游戏云IP
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) ChangeRgsIP(id int, req *rcs.ChangeRcsIPRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/eip/change", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 放弃游戏云IP
|
||||
//
|
||||
// id: 游戏云ID
|
||||
func (s *RgsService) DisCardRgsIP(id int, req rcs.DisCardRcsIPRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/eip/discard", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
type GetRgsFirewallRulesRequest struct {
|
||||
Options common.StandQueryParameters `json:"options"`
|
||||
}
|
||||
|
||||
type GetRgsFirewallRulesResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data rcs.RcsFirewallRuleList `json:"data"`
|
||||
}
|
||||
|
||||
// 获取游戏云防火墙规则列表
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) GetRgsFirewallRules(id int, req *GetRgsFirewallRulesRequest) (*GetRgsFirewallRulesResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/firewall/rule", id)
|
||||
|
||||
var resp GetRgsFirewallRulesResponse
|
||||
querys, err := common.MarshalQueryParams(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 创建/设置游戏云防火墙规则
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) SetRgsFirewallRule(id int, req *rcs.SetRcsFirewallRuleRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/firewall/rule", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 删除游戏云防火墙规则
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) DeleteRgsFirewallRule(id, ruleID int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/firewall/rule/%d", id, ruleID)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_DELETE, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 移动游戏云防火墙规则优先级
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) MobileRgsFirewallRulePriority(id, ruleID int, req rcs.MobileRcsFirewallRulePriorityRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/firewall/rule/%d/pos", id, ruleID)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PUT, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 游戏云详情
|
||||
// 由于响应实在过于庞大,我们只维护部分必要的响应,如有扩展需求,请在项目的data文件夹下寻找响应实例自行解码
|
||||
type GetRgsDetailResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RgsDetailData `json:"data"`
|
||||
}
|
||||
|
||||
type RgsDetailData struct {
|
||||
Data RgsRecord `json:"Data"`
|
||||
NatList []RgsNatItem `json:"NatList"` // 端口映射列表
|
||||
EIPList any `json:"EIPList"`
|
||||
ConfigPrice int `json:"ConfigPrice"`
|
||||
RenewPointPrice RgsRenewPointPrice `json:"RenewPointPrice"` // 积分续费
|
||||
}
|
||||
|
||||
type RgsNatItem struct {
|
||||
ID int `json:"ID"`
|
||||
PortIn int `json:"PortIn"`
|
||||
PortOut int `json:"PortOut"`
|
||||
PortType string `json:"PortType"`
|
||||
Tag string `json:"Tag"`
|
||||
}
|
||||
|
||||
type RgsRenewPointPrice struct {
|
||||
Num7 int `json:"7"` // 积分续费七天
|
||||
Num31 int `json:"31"` // 积分续费31天
|
||||
}
|
||||
|
||||
// 获取游戏云详情
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) GetRgsDetail(id int) (*GetRgsDetailResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d", id)
|
||||
|
||||
var resp GetRgsDetailResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
type GetRgsListRequest struct {
|
||||
Options common.StandQueryParameters `json:"options"`
|
||||
}
|
||||
|
||||
type GetRgsListResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RgsListData `json:"data"`
|
||||
}
|
||||
|
||||
type RgsListData struct {
|
||||
TotalRecords int `json:"TotalRecords"`
|
||||
Records []RgsRecord `json:"Records"`
|
||||
}
|
||||
|
||||
// 游戏云记录信息
|
||||
// 由于响应实在过于庞大,我们只维护部分必要的响应,如有扩展需求,请在项目的data文件夹下寻找响应实例自行解码
|
||||
type RgsRecord struct {
|
||||
ExpDate int `json:"ExpDate"`
|
||||
ExpireNotice int `json:"ExpireNotice"`
|
||||
AutoRenew bool `json:"AutoRenew"`
|
||||
UnsubscribeAble bool `json:"UnsubscribeAble"`
|
||||
Try bool `json:"Try"`
|
||||
ID int `json:"ID"`
|
||||
UID int `json:"UID"`
|
||||
PlanID int `json:"PlanID"`
|
||||
CreateDate int `json:"CreateDate"`
|
||||
Status string `json:"Status"`
|
||||
StopReason string `json:"StopReason"`
|
||||
RewardPointsToBeCollect int `json:"RewardPointsToBeCollect"` // 待领取的积分
|
||||
Tag string `json:"Tag"`
|
||||
OsID int `json:"OsID"`
|
||||
OsName string `json:"OsName"`
|
||||
HostName string `json:"HostName"`
|
||||
DefaultPass string `json:"DefaultPass"`
|
||||
MainIPv4 string `json:"MainIPv4"`
|
||||
IntIPv4 string `json:"IntIPv4"`
|
||||
UsageData RgsUsageData `json:"UsageData"`
|
||||
Zone string `json:"Zone"`
|
||||
NatPublicIP string `json:"NatPublicIP"`
|
||||
NatPublicDomain string `json:"NatPublicDomain"`
|
||||
NATSpareDomain string `json:"NATSpareDomain"`
|
||||
NetIn int `json:"NetIn"`
|
||||
NetOut int `json:"NetOut"`
|
||||
NowNetIn int `json:"NowNetIn"`
|
||||
NowNetOut int `json:"NowNetOut"`
|
||||
NetMode string `json:"NetMode"`
|
||||
BridgeSyncing bool `json:"BridgeSyncing"`
|
||||
VnetID int `json:"VnetID"`
|
||||
UpdateTime int `json:"UpdateTime"`
|
||||
FwSyncTime int `json:"FwSyncTime"`
|
||||
FwMode string `json:"FwMode"`
|
||||
AbCPULimit int `json:"AbCpuLimit"`
|
||||
AbNetLimit int `json:"AbNetLimit"`
|
||||
AbWhiteReason string `json:"AbWhiteReason"`
|
||||
OsInfo RgsOsInfo `json:"OsInfo"`
|
||||
CPU int `json:"CPU"`
|
||||
Memory int `json:"Memory"`
|
||||
BaseDisk int `json:"BaseDisk"`
|
||||
DataDisk int `json:"DataDisk"`
|
||||
InitedDate int `json:"InitedDate"`
|
||||
Allocation int `json:"Allocation"`
|
||||
Database int `json:"Database"`
|
||||
Backup int `json:"Backup"`
|
||||
CPULimitMode bool `json:"CpuLimitMode"`
|
||||
CPULimitStatus bool `json:"CpuLimitStatus"`
|
||||
CPUPoint int `json:"CpuPoint"`
|
||||
DailyMode bool `json:"DailyMode"` // 是否日付模式
|
||||
RBSKeepLast int `json:"RBSKeepLast"`
|
||||
RBSAutoBackup string `json:"RBSAutoBackup"`
|
||||
RBSLastAutoBackupDate int `json:"RBSLastAutoBackupDate"`
|
||||
McsmUserName string `json:"McsmUserName"`
|
||||
McsmUser McsmUser `json:"McsmUser"`
|
||||
}
|
||||
|
||||
type RgsUsageData struct {
|
||||
CPU int `json:"CPU"`
|
||||
Mem int `json:"Mem"`
|
||||
MemUsage int `json:"MemUsage"`
|
||||
DiskRead int `json:"DiskRead"`
|
||||
DiskWrite int `json:"DiskWrite"`
|
||||
Disk int `json:"Disk"`
|
||||
NetOut int `json:"NetOut"`
|
||||
NetIn int `json:"NetIn"`
|
||||
UpdateTime int `json:"UpdateTime"`
|
||||
}
|
||||
|
||||
type RgsOsInfo struct {
|
||||
ID int `json:"id"`
|
||||
Region string `json:"region"`
|
||||
Subtype string `json:"subtype"`
|
||||
Machine string `json:"machine"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
SyncStatus string `json:"sync_status"`
|
||||
OsType string `json:"os_type"`
|
||||
ChineseName string `json:"chinese_name"`
|
||||
Icon string `json:"icon"`
|
||||
IsWithBbr bool `json:"is_with_bbr"`
|
||||
IsEol bool `json:"is_eol"`
|
||||
IsAvailable bool `json:"is_available"`
|
||||
Order int `json:"order"`
|
||||
LatestFilename string `json:"latest_filename"`
|
||||
NoVMAgent bool `json:"no_vm_agent"`
|
||||
}
|
||||
|
||||
// 获取游戏云列表
|
||||
//
|
||||
// options: 查询参数 可以用 common.StandQueryParameters 获取
|
||||
func (s *RgsService) GetRgsList(req *GetRgsListRequest) (*GetRgsListResponse, error) {
|
||||
path := "/product/rgs"
|
||||
|
||||
var resp GetRgsListResponse
|
||||
querys, err := common.MarshalQueryParams(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 通用模式切换请求
|
||||
type RgsSwitchModeRequest struct {
|
||||
Mode bool `json:"mode"`
|
||||
}
|
||||
|
||||
// 游戏云CPU充电请求
|
||||
type ChargeRgsCPURequest struct {
|
||||
Mode string `json:"mode"` // 支付方式(money/point)
|
||||
Money int `json:"money"` // 消耗用户余额(支付方式为point时0)
|
||||
Points int `json:"points"` // 消耗用户积分(支付方式为money时0)
|
||||
}
|
||||
|
||||
// 游戏云更换egg(游戏类型)请求
|
||||
type ChangeRgsEggRequest struct {
|
||||
EggTypeID int `json:"egg_type_id"` // 蛋ID
|
||||
SaveDirs []string `json:"save_dirs"` // 要保留的目录
|
||||
}
|
||||
|
||||
// 释放游戏云
|
||||
//
|
||||
// id: 游戏云ID
|
||||
func (s *RgsService) FreeRgs(id int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/free", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云重启操作
|
||||
//
|
||||
// id: RGS ID
|
||||
func (s *RgsService) RebootRgs(id int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/reboot", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云重置密码
|
||||
//
|
||||
// id: 游戏云ID
|
||||
//
|
||||
// newPass: 新密码,留空则自动生成
|
||||
func (s *RgsService) ResetRgsPassword(id int, newPass string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/reset-password", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, rcs.ResetRcsPasswordRequest{Password: newPass}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云开机
|
||||
//
|
||||
// id: 游戏云ID
|
||||
func (s *RgsService) StartRgs(id int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/start", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云关机
|
||||
//
|
||||
// id: 游戏云ID
|
||||
func (s *RgsService) StopRgs(id int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/stop", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 设置游戏云标签
|
||||
//
|
||||
// id: 游戏云ID
|
||||
//
|
||||
// tag: 标签
|
||||
func (s *RgsService) SetRgsTag(id int, tag string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/tag", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, rcs.SetRcsTagRequest{TagName: tag}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云限制模式(是否用余额结算)切换
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
//
|
||||
// useMoney: 是否用余额结算CPU电量
|
||||
func (s *RgsService) SwitchRgsBalanceMode(id int, useMoney bool) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/cpu-limit-mode", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, RgsSwitchModeRequest{Mode: useMoney}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云日付模式开关
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
//
|
||||
// dailyMode: true: 开启日付模式,false: 关闭日付模式
|
||||
func (s *RgsService) SwitchRgsDailyMode(id int, dailyMode bool) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/daily-mode", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, RgsSwitchModeRequest{Mode: dailyMode}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云CPU充电
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) ChargeRgsCPU(id int, req *ChargeRgsCPURequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/cpu-charge", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云升级
|
||||
//
|
||||
// id: 游戏云ID
|
||||
//
|
||||
// plan: 升级到的套餐ID
|
||||
//
|
||||
// coupon: 优惠券ID,默认为0
|
||||
func (s *RgsService) UpgradeRgs(id, plan, coupon int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/upgrade", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, rcs.UpgradeRcsRequest{DestPlan: plan, WithCouponID: coupon}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云更换egg(游戏类型)
|
||||
//
|
||||
// 此操作需要二步验证
|
||||
//
|
||||
// eggTypeID: 游戏类型ID
|
||||
//
|
||||
// saveDirs: 要保留的目录
|
||||
func (s *RgsService) ChangeRgsEgg(id int, eggTypeID int, saveDirs []string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/change-egg", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, ChangeRgsEggRequest{EggTypeID: eggTypeID, SaveDirs: saveDirs}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// MCSM面板用户
|
||||
type McsmUser struct {
|
||||
Name string `json:"name"`
|
||||
Password string `json:"password"`
|
||||
UserID int `json:"user_id,omitempty"`
|
||||
PanelUUID string `json:"panel_uuid,omitempty"`
|
||||
}
|
||||
|
||||
// 创建MCSM面板用户
|
||||
//
|
||||
// name: 用户名
|
||||
//
|
||||
// password: 密码
|
||||
func (s *RgsService) CreateMcsmUser(name, password string) (*common.BasicOperationResponse, error) {
|
||||
path := "/product/rgs/mcsm/panel_user"
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, McsmUser{Name: name, Password: password}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 编辑MCSM面板用户
|
||||
//
|
||||
// name: 用户名
|
||||
//
|
||||
// password: 密码
|
||||
func (s *RgsService) EditMcsmUser(name, password string) (*common.BasicOperationResponse, error) {
|
||||
path := "/product/rgs/mcsm/panel_user"
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, McsmUser{Name: name, Password: password}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 删除MCSM面板用户
|
||||
//
|
||||
// name: 用户名
|
||||
func (s *RgsService) DeleteMcsmUser(name string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/mcsm/panel_user/%s", name)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_DELETE, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
type GetRgsMonitorDataRequest struct {
|
||||
StartDate int `json:"start_date"` // 开始时间(时间戳)
|
||||
EndDate int `json:"end_date"` // 结束时间(时间戳)
|
||||
}
|
||||
|
||||
type GetRgsMonitorDataResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data rcs.RcsMonitorData `json:"data"`
|
||||
}
|
||||
|
||||
// 获取游戏云监控数据
|
||||
//
|
||||
// id: 游戏云ID
|
||||
//
|
||||
// startDate: 开始时间
|
||||
//
|
||||
// endDate: 结束时间
|
||||
func (s *RgsService) GetRgsMonitorData(id int, req *GetRgsMonitorDataRequest) (*GetRgsMonitorDataResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/monitor", id)
|
||||
|
||||
var resp GetRgsMonitorDataResponse
|
||||
querys, err := common.MarshalQueryParams(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 添加游戏云NAT端口映射
|
||||
//
|
||||
// id: 游戏云 ID
|
||||
func (s *RgsService) AddRgsNatPortMapping(id int, req *rcs.AddRcsNatPortMappingRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/nat", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/rcs"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
type GetRgsRenewPriceRequest struct {
|
||||
ProductID int `json:"product_id"`
|
||||
Duration int `json:"duration"`
|
||||
WithCouponID int `json:"with_coupon_id"`
|
||||
}
|
||||
|
||||
type GetRgsRenewPriceResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data rcs.RcsRenewPrice `json:"data"`
|
||||
}
|
||||
|
||||
type GetRgsUpgradePriceRequest struct {
|
||||
ProductID int `json:"product_id"`
|
||||
Duration int `json:"duration"`
|
||||
WithCouponID int `json:"with_coupon_id"`
|
||||
Config RgsConfig `json:"config"`
|
||||
}
|
||||
|
||||
// 游戏云升级价格
|
||||
type GetRgsUpgradePriceResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RgsUpgradePriceData `json:"data"`
|
||||
}
|
||||
|
||||
type RgsUpgradePriceData struct {
|
||||
Detail RgsUpgradePriceDetail `json:"detail"`
|
||||
Price int `json:"price"`
|
||||
}
|
||||
|
||||
type RgsUpgradePriceDetail struct {
|
||||
Price int `json:"price"`
|
||||
AgentPrice int `json:"agent_price"`
|
||||
StockPrice int `json:"stock_price"`
|
||||
DefaultPrice int `json:"default_price"`
|
||||
CouponValue int `json:"coupon_value"`
|
||||
SaleReward int `json:"sale_reward"`
|
||||
AgentReward int `json:"agent_reward"`
|
||||
AgentID int `json:"agent_id"`
|
||||
IgnoreAgent bool `json:"ignore_agent"`
|
||||
PerScene RgsUpgradePerScene `json:"per_scene"`
|
||||
}
|
||||
|
||||
type RgsUpgradePerScene struct {
|
||||
Upgrade int `json:"upgrade"`
|
||||
}
|
||||
|
||||
// 获取游戏云续费价格
|
||||
//
|
||||
// id: RGS ID, duration: 续费时长(月), coupon: 优惠券ID
|
||||
func (s *RgsService) GetRgsRenewPrice(req *GetRgsRenewPriceRequest) (*GetRgsRenewPriceResponse, error) {
|
||||
path := "/product/rgs/price"
|
||||
|
||||
var resp GetRgsRenewPriceResponse
|
||||
querys, err := common.MarshalQueryParams(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
querys["scene"] = "renew"
|
||||
querys["is_old"] = "true"
|
||||
err = s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云续费
|
||||
//
|
||||
// id: 游戏云ID
|
||||
func (s *RgsService) RenewRgs(id int, req rcs.RenewRcsRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/renew", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 游戏云自动续费选项
|
||||
//
|
||||
// id: 游戏云ID
|
||||
func (s *RgsService) EnableRgsAutoRenew(id int, req rcs.EnableRcsAutoRenewRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/renew/option", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 获取游戏云升级价格
|
||||
//
|
||||
// id: RGS ID, duration: 续费时长(月), coupon: 优惠券ID
|
||||
func (s *RgsService) GetRgsUpgradePrice(req *GetRgsUpgradePriceRequest) (*GetRgsUpgradePriceResponse, error) {
|
||||
path := "/product/rgs/price"
|
||||
|
||||
var resp GetRgsUpgradePriceResponse
|
||||
querys, err := common.MarshalQueryParams(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
querys["scene"] = "upgrade"
|
||||
querys["is_old"] = "true"
|
||||
err = s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package rgs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 游戏云连接VNC
|
||||
//
|
||||
// id: 游戏云ID
|
||||
//
|
||||
// consoleType: 控制台类型,可选值: novnc,xtermjs
|
||||
func (s *RgsService) GetRgsVnc(id int, consoleType string) (*common.VncConnectionInfo, error) {
|
||||
path := fmt.Sprintf("/product/rgs/%d/vnc", id)
|
||||
|
||||
var resp common.VncConnectionInfo
|
||||
querys := map[string]string{"console_type": consoleType}
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 获取游戏云对应的PVE地址
|
||||
//
|
||||
// id: 游戏云ID
|
||||
func (s *RgsService) GetRgsPveAddress(id int) (string, error) {
|
||||
v, err := s.GetRgsVnc(id, "novnc")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
parsedURL, err := url.Parse(v.Data.RequestURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return parsedURL.Hostname(), nil
|
||||
}
|
||||
Reference in New Issue
Block a user