fix: correct rainyunServer JSON field names to match actual API (PascalCase)
This commit is contained in:
@@ -16,15 +16,15 @@ type ServerService struct {
|
||||
// rainyunServer mirrors the Rainyun RCS API JSON fields (PascalCase).
|
||||
type rainyunServer struct {
|
||||
ID int `json:"ID"`
|
||||
Name string `json:"name"`
|
||||
HostName string `json:"HostName"`
|
||||
Status string `json:"status"`
|
||||
IP string `json:"ip"`
|
||||
VCPU int `json:"vcpu"`
|
||||
MainIPv4 string `json:"MainIPv4"`
|
||||
CPU int `json:"CPU"`
|
||||
Memory int `json:"memory"`
|
||||
Disk int `json:"disk"`
|
||||
OS string `json:"os"`
|
||||
Region string `json:"zone_name"`
|
||||
ExpireDate int64 `json:"ExpDate"` // Unix timestamp
|
||||
OsName string `json:"OsName"`
|
||||
Zone string `json:"Zone"`
|
||||
ExpireDate int64 `json:"ExpDate"`
|
||||
}
|
||||
|
||||
func (s *ServerService) List(ctx context.Context) ([]provider.Server, error) {
|
||||
@@ -90,14 +90,14 @@ func toServer(r rainyunServer) provider.Server {
|
||||
expire := time.Unix(r.ExpireDate, 0)
|
||||
return provider.Server{
|
||||
ID: fmt.Sprintf("%d", r.ID),
|
||||
Name: r.Name,
|
||||
Name: r.HostName,
|
||||
Status: r.Status,
|
||||
IP: r.IP,
|
||||
CPU: r.VCPU,
|
||||
IP: r.MainIPv4,
|
||||
CPU: r.CPU,
|
||||
Memory: r.Memory,
|
||||
Disk: r.Disk,
|
||||
OS: r.OS,
|
||||
Region: r.Region,
|
||||
OS: r.OsName,
|
||||
Region: r.Zone,
|
||||
ExpireAt: expire,
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
@@ -18,15 +18,16 @@ func TestServerList(t *testing.T) {
|
||||
"data": map[string]any{
|
||||
"Records": []map[string]any{
|
||||
{
|
||||
"ID": 12001,
|
||||
"name": "web-server",
|
||||
"status": "running",
|
||||
"ip": "1.2.3.4",
|
||||
"vcpu": 2,
|
||||
"memory": 4096,
|
||||
"disk": 50,
|
||||
"os": "Ubuntu 22.04",
|
||||
"ExpDate": 1756656000,
|
||||
"ID": 12001,
|
||||
"HostName": "web-server",
|
||||
"status": "running",
|
||||
"MainIPv4": "1.2.3.4",
|
||||
"CPU": 2,
|
||||
"memory": 4096,
|
||||
"disk": 50,
|
||||
"OsName": "Ubuntu 22.04",
|
||||
"Zone": "cn-sy1",
|
||||
"ExpDate": 1756656000,
|
||||
},
|
||||
},
|
||||
"TotalRecords": 1,
|
||||
|
||||
Reference in New Issue
Block a user