up
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user