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