From f4deeb1ab65bfbaf07c0286b5d3b7915fa129f21 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 23 Jul 2026 16:23:31 +0000 Subject: [PATCH] add quota related types --- access-types.go | 45 ---------------------------- quota-types.go | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 quota-types.go diff --git a/access-types.go b/access-types.go index 0f24a6e..e3214b7 100644 --- a/access-types.go +++ b/access-types.go @@ -49,48 +49,3 @@ type VMID struct { Min int `json:"min" mapstructure:"min"` Max int `json:"max" mapstructure:"max"` } - -type Backups struct { - MaxPerInstance int `json:"max-per-instance" mapstructure:"max-per-instance"` - MaxTotal int `json:"max-total" mapstructure:"max-total"` -} - -type Templates struct { - Instances struct { - LXC map[string]ResourceTemplate `json:"lxc" mapstructure:"lxc"` - QEMU map[string]ResourceTemplate `json:"qemu" mapstructure:"qemu"` - } `json:"instances"` -} - -type SimpleResource struct { - Limits struct { - Global SimpleLimit `json:"global" mapstructure:"global"` - Nodes map[string]SimpleLimit `json:"nodes" mapstructure:"nodes"` - } `json:"limits"` -} - -type SimpleLimit struct { - Max int `json:"max" mapstructure:"max"` -} - -type MatchResource struct { - Limits struct { - Global []MatchLimit `json:"global" mapstructure:""` - Nodes map[string][]MatchLimit `json:"nodes" mapstructure:""` - } `json:"limits"` -} - -type MatchLimit struct { - Match string `json:"match" mapstructure:""` - Name string `json:"name" mapstructure:""` - Max int `json:"max" mapstructure:""` -} - -type ResourceTemplate struct { - Value string `json:"value" mapstructure:"value"` - Resource struct { - Enabled bool `json:"enabled" mapstructure:"enabled"` - Name string `json:"name" mapstructure:"name"` - Amount int `json:"amount" mapstructure:"amount"` - } `json:"resource" mapstructure:"resource"` -} diff --git a/quota-types.go b/quota-types.go new file mode 100644 index 0000000..d30258a --- /dev/null +++ b/quota-types.go @@ -0,0 +1,78 @@ +package proxmoxaas_common_lib + +// numerical constraint +type Constraint struct { + Max int64 `json:"max" mapstructure:"max"` + Used int64 `json:"used" mapstructure:"used"` + Avail int64 `json:"avail" mapstructure:"avail"` +} + +// match constraint +type Match struct { + Constraint `mapstructure:",squash"` + Name string `json:"name" mapstructure:"name"` + Match string `json:"match" mapstructure:"match"` +} + +// numerical resource +type NumericResource struct { + Type string + Name string + Multiplier int64 + Base uint64 + Compact bool + Unit string + Display bool + Global Constraint + Nodes map[string]Constraint + Total Constraint + Category string +} + +// storage resource +type StorageResource struct { + Type string + Name string + Multiplier int64 + Base uint64 + Compact bool + Unit string + Display bool + Disks []string + Global Constraint + Nodes map[string]Constraint + Total Constraint + Category string +} + +// list resource +type ListResource struct { + Type string + Whitelist bool + Display bool + Global []Match + Nodes map[string][]Match + Total []Match + Category string +} + +type Templates struct { + Instances struct { + LXC map[string]ResourceTemplate `json:"lxc" mapstructure:"lxc"` + QEMU map[string]ResourceTemplate `json:"qemu" mapstructure:"qemu"` + } `json:"instances"` +} + +type ResourceTemplate struct { + Value string `json:"value" mapstructure:"value"` + Resource struct { + Enabled bool `json:"enabled" mapstructure:"enabled"` + Name string `json:"name" mapstructure:"name"` + Amount int `json:"amount" mapstructure:"amount"` + } `json:"resource" mapstructure:"resource"` +} + +type Backups struct { + MaxPerInstance int `json:"max-per-instance" mapstructure:"max-per-instance"` + MaxTotal int `json:"max-total" mapstructure:"max-total"` +}