package main import ( "time" "gorm.io/gorm" ) type CPU struct { gorm.Model `json:"-"` ID uint `json:"id" gorm:"primary_key"` Time time.Time `json:"time" gorm:"autoCreateTime"` Name string `json:"name"` Socket int `json:"socket"` Cores int `json:"cores"` HostID uint `json:"host_id"` Host Host `json:"-" gorm:"foreignKey:ID;references:HostID"` } type CPUUsage struct { gorm.Model `json:"-"` ID uint `json:"id" gorm:"primary_key"` Time time.Time `json:"time" gorm:"autoCreateTime"` Core int `json:"core"` Usage float64 `json:"usage"` HostID uint `json:"host_id"` Host Host `json:"-" gorm:"foreignKey:ID;references:HostID"` } type Memory struct { gorm.Model `json:"-"` ID uint `json:"id" gorm:"primary_key"` Time time.Time `json:"time" gorm:"autoCreateTime"` Type string `json:"type"` Total int `json:"total"` Used int `json:"used"` Usage float64 `json:"usage"` HostID uint `json:"host_id"` Host Host `json:"-" gorm:"foreignKey:ID;references:HostID"` } type Host struct { gorm.Model `json:"-"` ID uint `json:"id" gorm:"primary_key;autoIncrement"` Hostname string `json:"hostname" gorm:"unique"` Description string `json:"description"` Cpus []CPU `json:"cpus" gorm:"foreignKey:ID"` Memory []Memory `json:"memory" gorm:"foreignKey:ID"` CPUUsageID uint `json:"cpu_usage_id"` } type AddHost struct { Hostname string `json:"hostname"` } type Error struct { Status string `json:"status"` Error string `json:"error"` }