Merge branch 'feat/verbose-debug' into master
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) ([]model.Server, error) {
|
||||
@@ -40,12 +40,14 @@ func (s *ServerService) List(ctx context.Context) ([]model.Server, error) {
|
||||
}
|
||||
|
||||
func (s *ServerService) Get(ctx context.Context, id string) (*model.Server, error) {
|
||||
var raw rainyunServer
|
||||
var resp struct {
|
||||
Data rainyunServer `json:"Data"`
|
||||
}
|
||||
path := fmt.Sprintf("/product/rcs/%s/", id)
|
||||
if err := s.client.get(ctx, path, &raw); err != nil {
|
||||
if err := s.client.get(ctx, path, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sv := toServer(raw)
|
||||
sv := toServer(resp.Data)
|
||||
return &sv, nil
|
||||
}
|
||||
|
||||
@@ -90,14 +92,14 @@ func toServer(r rainyunServer) model.Server {
|
||||
expire := time.Unix(r.ExpireDate, 0)
|
||||
return model.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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user