Documentation
¶
Index ¶
- Constants
- Variables
- func Genuine(licenseKey string, signingScheme string) ([]byte, error)
- type Artifact
- type Client
- func (c *Client) Delete(path string, params interface{}, model interface{}) (*Response, error)
- func (c *Client) Get(path string, params interface{}, model interface{}) (*Response, error)
- func (c *Client) Patch(path string, params interface{}, model interface{}) (*Response, error)
- func (c *Client) Post(path string, params interface{}, model interface{}) (*Response, error)
- func (c *Client) Put(path string, params interface{}, model interface{}) (*Response, error)
- type Entitlement
- type Entitlements
- type ErrorCode
- type License
- func (l *License) Activate(fingerprint string) (*Machine, error)
- func (l *License) Deactivate(id string) error
- func (l *License) Entitlements() (Entitlements, error)
- func (l *License) Genuine() ([]byte, error)
- func (l *License) Machines() (Machines, error)
- func (l *License) SetData(to func(target interface{}) error) error
- func (l *License) SetID(id string) error
- func (l *License) SetRelationships(relationships map[string]interface{}) error
- func (l *License) SetType(t string) error
- func (l *License) Validate(fingerprints ...string) error
- type Machine
- func (m *Machine) Deactivate() error
- func (m Machine) GetData() interface{}
- func (m Machine) GetID() string
- func (m Machine) GetType() string
- func (m *Machine) Monitor() chan error
- func (m *Machine) SetData(to func(target interface{}) error) error
- func (m *Machine) SetID(id string) error
- func (m *Machine) SetType(t string) error
- type Machines
- type Release
- type Response
- type ValidationCode
Constants ¶
const ( APIURL = "https://api.keygen.sh" APIVersion = "v1" )
const (
// Filetype is the release filetype used when checking for upgrades.
Filetype = "binary"
)
const ( // Platform is the release platform used when checking for upgrades // and when activating machines. Platform = runtime.GOOS + "_" + runtime.GOARCH )
const (
SchemeCodeEd25519 = "ED25519_SIGN"
)
Variables ¶
var ( ErrLicenseTokenInvalid = errors.New("authentication token is invalid") ErrMachineAlreadyActivated = errors.New("machine is already activated") ErrMachineLimitExceeded = errors.New("machine limit has been exceeded") ErrMachineDead = errors.New("machine does not exist") ErrNotFound = errors.New("resource does not exist") )
var ( // Account is the Keygen account ID used globally in the binding. Account string // Product is the Keygen product ID used globally in the binding. Product string // Token is the Keygen API token used globally in the binding. Token string // PublicKey is the Keygen public key used for verifying license keys // and API response signatures. PublicKey string // Channel is the release channel used when checking for upgrades. Channel = "stable" )
var ( ErrLicenseNotActivated = errors.New("license is not activated") ErrLicenseExpired = errors.New("license is expired") ErrLicenseSuspended = errors.New("license is suspended") ErrLicenseTooManyMachines = errors.New("license has too many machines") ErrLicenseTooManyCores = errors.New("license has too many cores") ErrLicenseNotSigned = errors.New("license is not signed") ErrLicenseInvalid = errors.New("license is invalid") ErrFingerprintMissing = errors.New("fingerprint scope is missing") ErrProductMissing = errors.New("product scope is missing") )
var ( ErrLicenseSchemeNotSupported = errors.New("license scheme is not supported") ErrLicenseSchemeMissing = errors.New("license scheme is missing") ErrLicenseKeyMissing = errors.New("license key is missing") ErrLicenseNotGenuine = errors.New("license key is not genuine") ErrPublicKeyMissing = errors.New("public key is missing") ErrPublicKeyInvalid = errors.New("public key is invalid") )
var (
ErrReleaseLocationMissing = errors.New("release has no download URL")
)
var (
ErrUpgradeNotAvailable = errors.New("no upgrades available (already up-to-date)")
)
Functions ¶
Types ¶
type Artifact ¶
type Artifact struct { ID string `json:"-"` Type string `json:"-"` Key string `json:"key"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` ReleaseId string `json:"-"` }
Artifact represents an Keygen artifact object.
func (*Artifact) SetRelationships ¶
type Client ¶
type Entitlement ¶
type Entitlement struct { ID string `json:"-"` Type string `json:"-"` Code string `json:"code"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Metadata map[string]interface{} `json:"metadata"` }
Entitlement represents an Keygen entitlement object.
func (*Entitlement) SetData ¶
func (e *Entitlement) SetData(to func(target interface{}) error) error
func (*Entitlement) SetID ¶
func (e *Entitlement) SetID(id string) error
Implement jsonapi.UnmarshalData interface
func (*Entitlement) SetType ¶
func (e *Entitlement) SetType(t string) error
type Entitlements ¶
type Entitlements []Entitlement
Entitlements represents an array of entitlement objects.
func (*Entitlements) SetData ¶
func (e *Entitlements) SetData(to func(target interface{}) error) error
Implement jsonapi.UnmarshalData interface
type License ¶
type License struct { ID string `json:"-"` Type string `json:"-"` Name string `json:"name"` Key string `json:"key"` Expiry *time.Time `json:"expiry"` Scheme string `json:"scheme"` LastValidated *time.Time `json:"lastValidated"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Metadata map[string]interface{} `json:"metadata"` PolicyId string `json:"-"` }
License represents an Keygen license object.
func Validate ¶
Validate performs a license validation using the current Token, scoped to any provided fingerprints. It returns a License, and an error if the license is invalid, e.g. ErrLicenseNotActivated or ErrLicenseExpired.
func (*License) Activate ¶
Activate performs a machine activation for the license, identified by the provided fingerprint. If the activation is successful, the new machine will be returned. An error will be returned if the activation fails, e.g. ErrMachineLimitExceeded or ErrMachineAlreadyActivated.
func (*License) Deactivate ¶
Deactivate performs a machine deactivation, identified by the provided ID. The ID can be the machine's UUID or the machine's fingerprint. An error will be returned if the machine deactivation fails.
func (*License) Entitlements ¶
func (l *License) Entitlements() (Entitlements, error)
Machines lists up to 100 entitlements for the license.
func (*License) Genuine ¶
Genuine checks if the license's key is genuine by cryptographically verifying the key using your PublicKey. If the license is genuine, the decoded dataset from the key will be returned. An error will be returned if the license is not genuine, or if the key is not signed, e.g. ErrLicenseNotGenuine or ErrLicenseNotSigned.
func (*License) SetRelationships ¶
type Machine ¶
type Machine struct { ID string `json:"-"` Type string `json:"-"` Name string `json:"name"` Fingerprint string `json:"fingerprint"` Hostname string `json:"hostname"` Platform string `json:"platform"` Cores int `json:"cores"` HeartbeatStatus string `json:"heartbeatStatus"` HeartbeatDuration int `json:"heartbeatDuration"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Metadata map[string]interface{} `json:"metadata"` LicenseID string `json:"-"` }
Machine represents an Keygen machine object.
func (*Machine) Deactivate ¶
Deactivate performs a machine deactivation for the current Machine. An error will be returned if the machine deactivation fails.
func (*Machine) Monitor ¶
Monitor performs, on a loop, a machine hearbeat ping for the current Machine. An error channel will be returned, where any ping errors will be emitted. Pings are sent according to the machine's required heartbeat window.
type Release ¶
type Release struct { ID string `json:"-"` Type string `json:"-"` Version string `json:"version"` Filename string `json:"filename"` Filetype string `json:"filetype"` Filesize string `json:"filesize"` Platform string `json:"platform"` Channel string `json:"channel"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Metadata map[string]interface{} `json:"metadata"` Location string `json:"-"` }
Release represents an Keygen release object.
type ValidationCode ¶
type ValidationCode string
const ( ValidationCodeValid ValidationCode = "VALID" ValidationCodeNotFound ValidationCode = "NOT_FOUND" ValidationCodeSuspended ValidationCode = "SUSPENDED" ValidationCodeExpired ValidationCode = "EXPIRED" ValidationCodeOverdue ValidationCode = "OVERDUE" ValidationCodeNoMachine ValidationCode = "NO_MACHINE" ValidationCodeNoMachines ValidationCode = "NO_MACHINES" ValidationCodeTooManyMachines ValidationCode = "TOO_MANY_MACHINES" ValidationCodeTooManyCores ValidationCode = "TOO_MANY_CORES" ValidationCodeFingerprintScopeRequired ValidationCode = "FINGERPRINT_SCOPE_REQUIRED" ValidationCodeFingerprintScopeMismatch ValidationCode = "FINGERPRINT_SCOPE_MISMATCH" ValidationCodeFingerprintScopeEmpty ValidationCode = "FINGERPRINT_SCOPE_EMPTY" ValidationCodeProductScopeRequired ValidationCode = "PRODUCT_SCOPE_REQUIRED" ValidationCodeProductScopeEmpty ValidationCode = "PRODUCT_SCOPE_MISMATCH" ValidationCodePolicyScopeRequired ValidationCode = "POLICY_SCOPE_REQUIRED" ValidationCodePolicyScopeMismatch ValidationCode = "POLICY_SCOPE_MISMATCH" ValidationCodeMachineScopeRequired ValidationCode = "MACHINE_SCOPE_REQUIRED" ValidationCodeMachineScopeMismatch ValidationCode = "MACHINE_SCOPE_MISMATCH" ValidationCodeEntitlementsMissing ValidationCode = "ENTITLEMENTS_MISSING" ValidationCodeEntitlementsEmpty ValidationCode = "ENTITLEMENTS_SCOPE_EMPTY" )