This commit is contained in:
Lizandro Guarnizo
2026-05-21 22:37:31 -05:00
parent 154a2fa245
commit 0cf7c6d279
7 changed files with 218 additions and 2 deletions
+3
View File
@@ -26,6 +26,9 @@ type Servidor struct {
AgentToken string `json:"agent_token" gorm:"column:agent_token;uniqueIndex"`
AgentLastSeen *time.Time `json:"agent_last_seen" gorm:"column:agent_last_seen"`
MetricasJson string `json:"metricas_json" gorm:"column:metricas_json;type:text"`
// Integración Hostinger
HostingerVpsID *int `json:"hostinger_vps_id" gorm:"column:hostinger_vps_id"`
HostingerState string `json:"hostinger_state" gorm:"column:hostinger_state"`
}
func (Servidor) TableName() string {
+14
View File
@@ -191,6 +191,20 @@ type HostingerHosting struct {
// ─── Métodos de la API ───────────────────────────────────────────────────────
// GetVPSByID obtiene una VM específica por su ID.
func (c *HostingerClient) GetVPSByID(vmID int) (*HostingerVPS, error) {
path := fmt.Sprintf("/vps/v1/virtual-machines/%d", vmID)
body, err := c.getRaw(context.Background(), path)
if err != nil {
return nil, err
}
var vps HostingerVPS
if err := json.Unmarshal(body, &vps); err != nil {
return nil, fmt.Errorf("hostinger: no se pudo interpretar respuesta VPS: %w", err)
}
return &vps, nil
}
// GetVPSList obtiene la lista de VPS/VMs.
func (c *HostingerClient) GetVPSList() ([]HostingerVPS, error) {
body, err := c.getRaw(context.Background(), "/vps/v1/virtual-machines")