up
This commit is contained in:
@@ -27,8 +27,9 @@ type Servidor struct {
|
||||
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"`
|
||||
HostingerVpsID *int `json:"hostinger_vps_id" gorm:"column:hostinger_vps_id"`
|
||||
HostingerState string `json:"hostinger_state" gorm:"column:hostinger_state"`
|
||||
HostingerSubscriptionID string `json:"hostinger_subscription_id" gorm:"column:hostinger_subscription_id"`
|
||||
}
|
||||
|
||||
func (Servidor) TableName() string {
|
||||
|
||||
@@ -111,16 +111,17 @@ type HostingerIPAddress struct {
|
||||
|
||||
// HostingerVPS representa una máquina virtual VPS.
|
||||
type HostingerVPS struct {
|
||||
ID int `json:"id"`
|
||||
Hostname string `json:"hostname"`
|
||||
State string `json:"state"`
|
||||
Plan string `json:"plan"`
|
||||
DataCenter string `json:"data_center"`
|
||||
CPU int `json:"cpus"`
|
||||
RAMBytes int64 `json:"memory"`
|
||||
DiskBytes int64 `json:"disk"`
|
||||
IPV4 []HostingerIPAddress `json:"ipv4"`
|
||||
IPV6 []HostingerIPAddress `json:"ipv6"`
|
||||
ID int `json:"id"`
|
||||
Hostname string `json:"hostname"`
|
||||
State string `json:"state"`
|
||||
Plan string `json:"plan"`
|
||||
DataCenter string `json:"data_center"`
|
||||
CPU int `json:"cpus"`
|
||||
RAMBytes int64 `json:"memory"`
|
||||
DiskBytes int64 `json:"disk"`
|
||||
IPV4 []HostingerIPAddress `json:"ipv4"`
|
||||
IPV6 []HostingerIPAddress `json:"ipv6"`
|
||||
SubscriptionID string `json:"subscription_id"`
|
||||
}
|
||||
|
||||
// HostingerDomain representa un dominio en el portafolio.
|
||||
@@ -303,6 +304,20 @@ func (c *HostingerClient) GetDomainNameServers(domain string) (*HostingerNameSer
|
||||
return &resp.NameServers, nil
|
||||
}
|
||||
|
||||
// GetSubscriptionByID obtiene una suscripción de billing por su ID.
|
||||
func (c *HostingerClient) GetSubscriptionByID(subID string) (*HostingerSubscription, error) {
|
||||
path := fmt.Sprintf("/billing/v1/subscriptions/%s", subID)
|
||||
body, err := c.getRaw(context.Background(), path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var sub HostingerSubscription
|
||||
if err := json.Unmarshal(body, &sub); err != nil {
|
||||
return nil, fmt.Errorf("hostinger: no se pudo interpretar suscripción: %w", err)
|
||||
}
|
||||
return &sub, nil
|
||||
}
|
||||
|
||||
// GetOrders obtiene las suscripciones de facturación.
|
||||
func (c *HostingerClient) GetOrders() ([]HostingerSubscription, error) {
|
||||
body, err := c.getRaw(context.Background(), "/billing/v1/subscriptions")
|
||||
|
||||
Reference in New Issue
Block a user