SDKs
...
Go SDK
v1 (legacy)
Go License Client
29min
note read common docid\ u qox n0barrls2ujjs1 before this importing the license client import ( 	"gitlab com/l3178/sdk go/license client" 	"gitlab com/l3178/sdk go/core/auth" 	core request "gitlab com/l3178/sdk go/core/models/request" ) create licenseclient the following function uses the default cryptoprovider and datalocation to encrypt, store, and decrypt the license file you can implement your custom cryptoprovider and datalocation the interface structure config = license client newlicenseclientconfiguration("apikey", "sharedkey", "productcode") client = license client newlicenseclient(config) create custom licenseclient implement the cryptoprovider and datalocation interfaces to create custom implementations for these components, and use them to configure the license client // implement the interface //type cryptoprovider interface { // encrypt(core models licensefile, string) (interface{}, error) // decrypt(interface{}, string) (interface{}, error) //} type customcryptoprovider struct{} func (d customcryptoprovider) encrypt(license file core models licensefile, password string) (interface{}, error) { // your custom implementation } func (d customcryptoprovider) decrypt(data interface{}, password string) (interface{}, error) { // your custom implementation } // implement the interface //type datalocation interface { // datadirectory() (string, error) // licensefilename(string) string //} type customdatalocation struct{} func (d customdatalocation) datadirectory() (string, error) { // your custom implementation } func (d customdatalocation) licensefilename(productcode string) string { // your custom implementation } config = license client newlicenseclientconfigurationcustom(customcryptoprovider, customdatalocation, "apikey", "sharedkey", "productcode") client = license client newlicenseclient(config) activate key based license after activating the license, this function saves the license file in the location specified by the datalocation object the file is securely encrypted using the implementation provided by the cryptoprovider resp = client activatelicense(license client activationrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, 	hostname "hostname", 	appversion "1 1 1", 	 }) activate user based license after activating the license, this function saves the license file in the location specified by the datalocation object the file is securely encrypted using the implementation provided by the cryptoprovider resp = client activatelicense(license client activationrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromusername("username", "password"), 	}, 	hostname "hostname", 	appversion "1 1 1", 	 }) deactivate key based license err = client deactivatelicense(license client licenserequest{ 	auth auth fromkey("licensekey"), }) deactivate user based license err = client deactivatelicense(license client licenserequest{ 	auth auth fromusername("username", "password"), }) check key based license resp = client checklicense(license client activationrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, 	 }) check user based license resp = client checklicense(license client activationrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromusername("username", "password"), 	}, 	 }) activate offline license after activating the license, this function saves the license file in the location specified by the datalocation object the file is securely encrypted using the implementation provided by the cryptoprovider // generate offline license request data resp = client generateofflinelicenserequest(license client activationrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, }, license client offlineactivationrequest) // write to request file if you want to activate license manually encoded, err = resp value encode() ioutil writefile("activate offline req", \[]byte(encoded), os modeperm) // activate offline license using api client activateoffline(offlinelicenserequest) deactivate offline license // generate offline license request data resp = client generateofflinelicenserequest(license client activationrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, }, license client offlinedeactivationrequest) // write to request file if you want to deactivate license manually encoded, err = resp value encode() ioutil writefile("deactivate offline req", \[]byte(encoded), os modeperm) // deactivate offline license using api client deactivateoffline(offlinelicenserequest) local license check this function reads the license file from local memory, validates it by performing checks such as expiration and hardware id matching, and returns the license object along with the results of these checks clientconfig = license client newlicenseclientconfiguration( 	 config apikey, 	 config sharedkey, 	 productcode, 	) clientconfig verbose = config verbose clientconfig verifysignature = config verifysignature client = license client newlicenseclient(clientconfig) resp = client activatelicense(context background(), license client activationrequest{ 	licenserequest core request licenserequest{ 	 product productcode, 	 auth auth fromkey(productauth licensekey), 	}, }) resp2 = client locallicensecheck(context background(), license client locallicensecheckrequest{product productcode}) local license check returns an object of the following type go type localcheckresponse struct { 	licenseresponse 	licenseactive bool `json "license active"` 	licenseenabled bool `json "license enabled"` 	isexpired bool `json "is expired"` 	devicelicensed bool `json "is device licensed"` 	isclocktampered bool `json "is clock tampered"` 	productmismatch bool `json "product mismatch"` 	floatingexpired bool `json "floating expired"` } add consumption \# add 1 consumption resp = client addconsumption(license client consumptionrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, 	consumptions 1, }) \# add 1 consumption, allow overages and define max overages resp = client addconsumption(license client consumptionrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, 	consumptions 1, 	maxoverages 5, 	allowoverages true, }) add feature consumption resp = client addfeatureconsumption(license client featureconsumptionrequest{ 	licenserequest license client licenserequest{ 	 auth core request auth{} fromkey("licensekey"), 	}, 	feature "featurecode", 	consumptions 1, }) trial key resp = client trialkey(license client triallicenserequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, 	email "", 	licensepolicy "", 	firstname "", 	lastname "", 	phone "", 	address "", 	postcode "", 	state "", 	country "", 	city "", 	reference "", }) product details // takes product code from configuration resp = client productdetails() track device variables err = client trackdevicevariables(license client devicevariablesrequest{ 	licenserequest core request licenserequest{ 	 auth auth fromkey("licensekey"), 	}, 	variables map\[string]string{ 	 "key" "var", 	}, }) get device variables resp = client getdevicevariables(license client licenserequest{ 	auth auth fromkey("licensekey"), }) floating borrow resp = client floatingborrow(license client floatingborrowrequest{ 	licenserequest license client licenserequest{ 	 auth auth fromkey("licensekey"), 	}, 	borroweduntil time now() utc() add(time hour 24 5), }) floating release client floatingrelease(license client licenserequest{ 	auth auth fromkey("licensekey"), }) change password client changepassword(license client changepasswordrequest{ 	passwordauth core request passwordauth{ 	 username "username", 	 password "password", 	}, 	newpassword "abcd", }) versions resp = client versions(license client licenserequest{ 	auth auth fromkey("licensekey"), }) installation file resp = client installationfile(license client licenserequest{ 	auth auth fromkey("licensekey"), }) customer license users resp = client customerlicenseusers(license client customerlicenseusersrequest{ 	customer "customer", }) sso url resp = client ssourl(license client ssourlrequest{ 	customeraccountcode "code", }) air gap initialization airgapclient = license client newairgapclient(config, "publickey") activationcode, err = airgapclient airgapinitialization("licensekey", "signingkey") return activationcode, cfg hardwareid air gap activation airgapclient = license client newairgapclient(config, "publickey") license, err = airgapclient airgapactivation("licensepolicy", "confirmationcode", 1234)