feat(contracts): add published ports, snapshot request, and storage report types

This commit is contained in:
Harivansh Rathi 2026-04-09 14:05:59 +00:00
parent 501ae2abd5
commit 26b5d2966d
20 changed files with 893 additions and 81 deletions

View file

@ -0,0 +1,30 @@
package host
import "time"
type PublishedPortID string
type PublishedPort struct {
ID PublishedPortID `json:"id"`
MachineID MachineID `json:"machine_id"`
Name string `json:"name,omitempty"`
Port uint16 `json:"port"`
HostPort uint16 `json:"host_port"`
Protocol PortProtocol `json:"protocol"`
CreatedAt time.Time `json:"created_at"`
}
type CreatePublishedPortRequest struct {
PublishedPortID PublishedPortID `json:"published_port_id"`
Name string `json:"name,omitempty"`
Port uint16 `json:"port"`
Protocol PortProtocol `json:"protocol"`
}
type CreatePublishedPortResponse struct {
Port PublishedPort `json:"port"`
}
type ListPublishedPortsResponse struct {
Ports []PublishedPort `json:"ports"`
}

View file

@ -10,6 +10,10 @@ type Snapshot struct {
CreatedAt time.Time `json:"created_at"`
}
type CreateSnapshotRequest struct {
SnapshotID SnapshotID `json:"snapshot_id"`
}
type CreateSnapshotResponse struct {
Snapshot Snapshot `json:"snapshot"`
}

View file

@ -13,3 +13,43 @@ type Volume struct {
AttachedMachineID *MachineID `json:"attached_machine_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type StoragePool string
const (
StoragePoolArtifacts StoragePool = "artifacts"
StoragePoolMachineDisks StoragePool = "machine-disks"
StoragePoolPublishedPort StoragePool = "published-ports"
StoragePoolSnapshots StoragePool = "snapshots"
StoragePoolState StoragePool = "state"
)
type StoragePoolUsage struct {
Pool StoragePool `json:"pool"`
Bytes int64 `json:"bytes"`
}
type MachineStorageUsage struct {
MachineID MachineID `json:"machine_id"`
SystemBytes int64 `json:"system_bytes"`
UserBytes int64 `json:"user_bytes"`
RuntimeBytes int64 `json:"runtime_bytes"`
}
type SnapshotStorageUsage struct {
SnapshotID SnapshotID `json:"snapshot_id"`
Bytes int64 `json:"bytes"`
}
type StorageReport struct {
GeneratedAt time.Time `json:"generated_at"`
TotalBytes int64 `json:"total_bytes"`
Pools []StoragePoolUsage `json:"pools,omitempty"`
Machines []MachineStorageUsage `json:"machines,omitempty"`
Snapshots []SnapshotStorageUsage `json:"snapshots,omitempty"`
PublishedPorts int64 `json:"published_ports"`
}
type GetStorageReportResponse struct {
Report StorageReport `json:"report"`
}