|
@@ -13,15 +13,17 @@ var errValidation = fmt.Errorf(license_validation_err_msg)
|
|
|
|
|
|
// LicenseKey - the license key struct representation with associated data
|
|
|
type LicenseKey struct {
|
|
|
- LicenseValue string `json:"license_value"` // actual (public) key and the unique value for the key
|
|
|
- Expiration int64 `json:"expiration"`
|
|
|
- LimitServers int `json:"limit_servers"`
|
|
|
- LimitUsers int `json:"limit_users"`
|
|
|
- LimitHosts int `json:"limit_hosts"`
|
|
|
- LimitNetworks int `json:"limit_networks"`
|
|
|
- LimitClients int `json:"limit_clients"`
|
|
|
- Metadata string `json:"metadata"`
|
|
|
- IsActive bool `json:"is_active"` // yes if active
|
|
|
+ LicenseValue string `json:"license_value"` // actual (public) key and the unique value for the key
|
|
|
+ Expiration int64 `json:"expiration"`
|
|
|
+ UsageServers int `json:"usage_servers"`
|
|
|
+ UsageUsers int `json:"usage_users"`
|
|
|
+ UsageClients int `json:"usage_clients"`
|
|
|
+ UsageHosts int `json:"usage_hosts"`
|
|
|
+ UsageNetworks int `json:"usage_networks"`
|
|
|
+ UsageIngresses int `json:"usage_ingresses"`
|
|
|
+ UsageEgresses int `json:"usage_egresses"`
|
|
|
+ Metadata string `json:"metadata"`
|
|
|
+ IsActive bool `json:"is_active"` // yes if active
|
|
|
}
|
|
|
|
|
|
// ValidatedLicense - the validated license struct
|
|
@@ -32,30 +34,28 @@ type ValidatedLicense struct {
|
|
|
|
|
|
// LicenseSecret - the encrypted struct for sending user-id
|
|
|
type LicenseSecret struct {
|
|
|
- AssociatedID string `json:"associated_id" binding:"required"` // UUID for user foreign key to User table
|
|
|
- Limits LicenseLimits `json:"limits" binding:"required"`
|
|
|
+ AssociatedID string `json:"associated_id" binding:"required"` // UUID for user foreign key to User table
|
|
|
+ Usage Usage `json:"usage" binding:"required"`
|
|
|
}
|
|
|
|
|
|
-// LicenseLimits - struct license limits
|
|
|
-type LicenseLimits struct {
|
|
|
+// Usage - struct for license usage
|
|
|
+type Usage struct {
|
|
|
Servers int `json:"servers"`
|
|
|
Users int `json:"users"`
|
|
|
Hosts int `json:"hosts"`
|
|
|
Clients int `json:"clients"`
|
|
|
Networks int `json:"networks"`
|
|
|
- Machines int `json:"machines"`
|
|
|
Ingresses int `json:"ingresses"`
|
|
|
Egresses int `json:"egresses"`
|
|
|
}
|
|
|
|
|
|
-// LicenseLimits.SetDefaults - sets the default values for limits
|
|
|
-func (l *LicenseLimits) SetDefaults() {
|
|
|
+// Usage.SetDefaults - sets the default values for usage
|
|
|
+func (l *Usage) SetDefaults() {
|
|
|
l.Clients = 0
|
|
|
l.Servers = 1
|
|
|
l.Hosts = 0
|
|
|
l.Users = 1
|
|
|
l.Networks = 0
|
|
|
- l.Machines = 0
|
|
|
l.Ingresses = 0
|
|
|
l.Egresses = 0
|
|
|
}
|