SDKs
Python SDK
API Client Usage Examples
28min
set app version import licensespring licensespring app version = "myapp 1 0 0" create apiclient an api client can use either api keys ( shared key and api key ) or oauth ( client id and client secret ) for authorization from licensespring api import apiclient api client = apiclient(api key=" your api key ", shared key=" your shared key ") from licensespring api import apiclient api client = apiclient(client=" your client id ", client secret=" your client secret ") activate key based license product = "lkprod1" license key = "gpb7 279t 6mnk cqlk" license data = api client activate license(product=product, license key=license key) print(license data) activate user based license product = "uprod1" username = "user1\@email com" password = "nq64k1!@" license data = api client activate license( product=product, username=username, password=password ) print(license data) deactivate key based license product = "lkprod1" license key = "gpub j4ph cgnk c7lk" api client deactivate license(product=product, license key=license key) deactivate user based license product = "uprod1" username = "user1\@email com" password = "nq64k1!@" api client deactivate license( product=product, username=username, password=password ) check key based license product = "lkprod1" license key = "gpbq dzcp e9sk cqlk" license data = api client check license(product=product, license key=license key) print(license data) check user based license product = "uprod1" username = "user2\@email com" password = "1l48y#!b" license data = api client check license(product=product, username=username) print(license data) add consumption product = "lkprod1" license key = "gpsu qtkq hssk c9lk" \# add 1 consumption consumption data = api client add consumption( product=product, license key=license key ) print(consumption data) \# add 3 consumptions consumption data = api client add consumption( product=product, license key=license key, consumptions=3 ) print(consumption data) \# add 1 consumption, allow overages and define max overages consumption data = api client add consumption( product=product, license key=license key, allow overages=true, max overages=10 ) print(consumption data) add feature consumption product = "lkprod1" license key = "gptj lsyz usek c8lk" feature = "lkprod1cf1" \# add 1 consumption feature consumption data = api client add feature consumption( product=product, license key=license key, feature=feature ) \# add 3 consumptions feature consumption data = api client add feature consumption( product=product, license key=license key, feature=feature, consumptions=3 ) print(feature consumption data) trial key product = "lkprod2" trial license data = api client trial key(product=product) print(trial license data) product details product = "lkprod1" product data = api client product details(product=product) print(product data) track device variables product = "lkprod1" license key = "gpub szf9 ab2k c7lk" variables = {"variable 1 key" "variable 1 value", "variable 2 key" "variable 2 value"} device variables = api client track device variables(product=product, license key=license key, variables=variables) print(device variables) get device variables product = "lkprod1" license key = "gpub szf9 ab2k c7lk" device variables = api client get device variables(product=product, license key=license key) print(device variables) floating borrow product = "lkprod1" license key = "gpuc ngwu 3njk c7lk" \# borrow for 2 hours borrowed until = (datetime utcnow() + timedelta(hours=2)) isoformat() floating borrow data = api client floating borrow(product=product, license key=license key, borrowed until=borrowed until) print(floating borrow data) floating release product = "lkprod1" license key = "gpuc ngwu 3njk c7lk" api client floating release(product=product, license key=license key) change password username = "user4\@email com" password = " old password " new password = " new password " is password changed = api client change password(username=username, password=password, new password=new password) print(is password changed) versions product = "lkprod1" license key = "gpb7 279t 6mnk cqlk" \# get versions for all environments versions data = api client versions(product=product, license key=license key) \# get versions for mac environment mac versions data = api client versions( product=product, license key=license key, env="mac" ) print(versions data) installation file product = "lkprod1" license key = "gpb7 279t 6mnk cqlk" \# get the latest installation file installation file data = api client installation file( product=product, license key=license key ) \# get the latest installation file for linux environment installation file data = api client installation file( product=product, license key=license key, env="linux" ) \# get the latest installation file for version 1 0 0 installation file data = api client installation file( product=product, license key=license key, version="1 0 0" ) print(installation file data) customer license users product = "uprod1" customer = 'c1\@c com' customer license users data = api client customer license users( product=product, customer=customer ) print(customer license users data) sso url product = "uprod1" customer account code = "ccorp" sso url data = api client sso url( product=product, customer account code=customer account code ) print(sso url data) sso url with code response type product = "uprod1" customer account code = "ccorp" sso url data = api client sso url( product=product, customer account code=customer account code, response type="code", ) print(sso url data) activate offline product = "lkprod1" license key = "gpy7 vhx9 mdsk c3lk" \# generate data for offline activation activate offline data = api client activate offline dump( product=product, license key=license key ) \# write to file with open('activate offline req', mode='w') as f print(activate offline data, file=f) \# activate offline license data = api client activate offline(data=activate offline data) print(license data) activate offline load \# read from file with open(' /ls activation lic') as file ls activation data = file read() license data = api client activate offline load(ls activation data) print(license data) deactivate offline product = "lkprod1" license key = "gpyc x5j2 l5sk c3lk" \# generate data for offline deactivation deactivate offline data = api client deactivate offline dump( product=product, license key=license key ) \# write to file with open('deactivate offline req', mode='w') as f print(deactivate offline data, file=f) \# deactivate offline api client deactivate offline(data=deactivate offline data) key based license feature check product = "lkprod1" license key = "gpb7 279t 6mnk cqlk" feature = "lkprod1f1" license feature data = api client check license feature( product=product, feature=feature, license key=license key ) print(license feature data) key based license floating feature release product = "lkprod1" license key = "gpb7 279t 6mnk cqlk" feature = "lkprod1f1" api client floating feature release( product=product, feature=feature, license key=license key ) product = "lkprod1" license key = "gpb7 279t 6mnk cqlk" feature = "lkprod1f1" is released = api client floating feature release( product=product, feature=feature, license key=license key ) print(is released)