Files
netmaker/ee/types.go
Gabriel de Souza Seibel 8ce7da2ce9 [NET-494 / ACC-322] New free tier limits (#2495)
* Rename var

* Rename consts and use iota

* Use switch instead of repeated else if

* Rename limits related vars

* Introduce new free tier limits

* Measure new limits and report on license validation

* Separate usage and limits, have new ones

* Don't check for hosts and clients limits, but for machines instead

* Error on egress creation @ free tier w/ internet gateways

* Remove clients and hosts limit from code

* Rename var

* Rename consts and use iota

* Use switch instead of repeated else if

* Rename limits related vars

* Introduce new free tier limits

* Measure new limits and report on license validation

* Separate usage and limits, have new ones

* Don't check for hosts and clients limits, but for machines instead

* Error on egress creation @ free tier w/ internet gateways

* Remove clients and hosts limit from code
2023-08-08 23:17:49 +05:30

84 lines
2.9 KiB
Go

package ee
import (
"fmt"
)
// constants for accounts api hosts
const (
// accountsHostDevelopment is the accounts api host for development environment
accountsHostDevelopment = "https://api.dev.accounts.netmaker.io"
// accountsHostStaging is the accounts api host for staging environment
accountsHostStaging = "https://api.staging.accounts.netmaker.io"
// accountsHostProduction is the accounts api host for production environment
accountsHostProduction = "https://api.accounts.netmaker.io"
)
const (
license_cache_key = "license_response_cache"
license_validation_err_msg = "invalid license"
server_id_key = "nm-server-id"
)
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"`
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
type ValidatedLicense struct {
LicenseValue string `json:"license_value" binding:"required"` // license that validation is being requested for
EncryptedLicense string `json:"encrypted_license" binding:"required"` // to be decrypted by Netmaker using Netmaker server's private key
}
// 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
Usage Usage `json:"usage" binding:"required"`
}
// 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"`
Ingresses int `json:"ingresses"`
Egresses int `json:"egresses"`
}
// 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.Ingresses = 0
l.Egresses = 0
}
// ValidateLicenseRequest - used for request to validate license endpoint
type ValidateLicenseRequest struct {
LicenseKey string `json:"license_key" binding:"required"`
NmServerPubKey string `json:"nm_server_pub_key" binding:"required"` // Netmaker server public key used to send data back to Netmaker for the Netmaker server to decrypt (eg output from validating license)
EncryptedPart string `json:"secret" binding:"required"`
}
type licenseResponseCache struct {
Body []byte `json:"body" binding:"required"`
}