SDKs
Python SDK
API Client Usage Examples
28min
Python
1import licensespring
2
3licensespring.app_version = "MyApp 1.0.0"
Python
1from licensespring.api import APIClient
2
3api_client = APIClient(api_key="_your_api_key_", shared_key="_your_shared_key_")
Python
1product = "lkprod1"
2license_key = "GPB7-279T-6MNK-CQLK"
3license_data = api_client.activate_license(product=product, license_key=license_key)
4
5print(license_data)
Python
1product = "uprod1"
2username = "[email protected]"
3password = "nq64k1!@"
4
5license_data = api_client.activate_license(
6 product=product, username=username, password=password
7)
8
9print(license_data)
Python
1product = "lkprod1"
2license_key = "GPUB-J4PH-CGNK-C7LK"
3api_client.deactivate_license(product=product, license_key=license_key)
Python
1product = "uprod1"
2username = "[email protected]"
3password = "nq64k1!@"
4
5api_client.deactivate_license(
6 product=product, username=username, password=password
7)
Python
1product = "lkprod1"
2license_key = "GPBQ-DZCP-E9SK-CQLK"
3
4license_data = api_client.check_license(product=product, license_key=license_key)
5
6print(license_data)
Python
1product = "uprod1"
2username = "[email protected]"
3password = "1l48y#!b"
4
5license_data = api_client.check_license(product=product, username=username)
6
7print(license_data)
Python
1product = "lkprod1"
2license_key = "GPSU-QTKQ-HSSK-C9LK"
3
4# Add 1 consumption
5consumption_data = api_client.add_consumption(
6 product=product, license_key=license_key
7)
8
9print(consumption_data)
10
11# Add 3 consumptions
12consumption_data = api_client.add_consumption(
13 product=product, license_key=license_key, consumptions=3
14)
15
16print(consumption_data)
17
18# Add 1 consumption, allow overages and define max overages
19consumption_data = api_client.add_consumption(
20 product=product, license_key=license_key, allow_overages=True, max_overages=10
21)
22
23print(consumption_data)
Python
1product = "lkprod1"
2license_key = "GPTJ-LSYZ-USEK-C8LK"
3feature = "lkprod1cf1"
4
5# Add 1 consumption
6feature_consumption_data = api_client.add_feature_consumption(
7 product=product, license_key=license_key, feature=feature
8)
9
10# Add 3 consumptions
11feature_consumption_data = api_client.add_feature_consumption(
12 product=product, license_key=license_key, feature=feature, consumptions=3
13)
14
15print(feature_consumption_data)
Python
1product = "lkprod2"
2
3trial_license_data = api_client.trial_key(product=product)
4
5print(trial_license_data)
Python
1product = "lkprod1"
2
3product_data = api_client.product_details(product=product)
4
5print(product_data)
Python
1product = "lkprod1"
2license_key = "GPUB-SZF9-AB2K-C7LK"
3variables = {"variable_1_key": "variable_1_value", "variable_2_key": "variable_2_value"}
4
5device_variables = api_client.track_device_variables(product=product, license_key=license_key, variables=variables)
6
7print(device_variables)
Python
1product = "lkprod1"
2license_key = "GPUB-SZF9-AB2K-C7LK"
3
4device_variables = api_client.get_device_variables(product=product, license_key=license_key)
5
6print(device_variables)
Python
1product = "lkprod1"
2license_key = "GPUC-NGWU-3NJK-C7LK"
3
4# Borrow for 2 hours
5borrowed_until = (datetime.utcnow() + timedelta(hours=2)).isoformat()
6floating_borrow_data = api_client.floating_borrow(product=product, license_key=license_key, borrowed_until=borrowed_until)
7
8print(floating_borrow_data)
Python
1product = "lkprod1"
2license_key = "GPUC-NGWU-3NJK-C7LK"
3
4api_client.floating_release(product=product, license_key=license_key)
Python
1username = "[email protected]"
2password = "_old_password_"
3new_password = "_new_password_"
4
5is_password_changed = api_client.change_password(username=username, password=password, new_password=new_password)
6
7print(is_password_changed)
Python
1product = "lkprod1"
2license_key = "GPB7-279T-6MNK-CQLK"
3
4# Get versions for all environments
5versions_data = api_client.versions(product=product, license_key=license_key)
6
7# Get versions for mac environment
8mac_versions_data = api_client.versions(
9 product=product, license_key=license_key, env="mac"
10)
11
12print(versions_data)
Python
1product = "lkprod1"
2license_key = "GPB7-279T-6MNK-CQLK"
3
4# Get the latest installation file
5installation_file_data = api_client.installation_file(
6 product=product, license_key=license_key
7)
8
9# Get the latest installation file for linux environment
10installation_file_data = api_client.installation_file(
11 product=product, license_key=license_key, env="linux"
12)
13
14# Get the latest installation file for version 1.0.0
15installation_file_data = api_client.installation_file(
16 product=product, license_key=license_key, version="1.0.0"
17)
18
19print(installation_file_data)
Python
1product = "uprod1"
2customer = '[email protected]'
3
4customer_license_users_data = api_client.customer_license_users(
5 product=product, customer=customer
6)
7
8print(customer_license_users_data)
Python
1product = "uprod1"
2customer_account_code = "ccorp"
3
4sso_url_data = api_client.sso_url(
5 product=product, customer_account_code=customer_account_code
6)
7
8print(sso_url_data)
Python
1product = "uprod1"
2customer_account_code = "ccorp"
3
4sso_url_data = api_client.sso_url(
5 product=product,
6 customer_account_code=customer_account_code,
7 response_type="code",
8)
9
10print(sso_url_data)
Python
1product = "lkprod1"
2license_key = "GPY7-VHX9-MDSK-C3LK"
3
4# Generate data for offline activation
5activate_offline_data = api_client.activate_offline_dump(
6 product=product, license_key=license_key
7)
8
9# Write to file
10with open('activate_offline.req', mode='w') as f:
11 print(activate_offline_data, file=f)
12
13# Activate offline
14license_data = api_client.activate_offline(data=activate_offline_data)
15
16print(license_data)
Python
1# Read from file
2with open('./ls_activation.lic') as file:
3 ls_activation_data = file.read()
4
5license_data = api_client.activate_offline_load(ls_activation_data)
6
7print(license_data)
Python
1product = "lkprod1"
2license_key = "GPYC-X5J2-L5SK-C3LK"
3
4# Generate data for offline deactivation
5deactivate_offline_data = api_client.deactivate_offline_dump(
6 product=product, license_key=license_key
7)
8
9# Write to file
10with open('deactivate_offline.req', mode='w') as f:
11 print(deactivate_offline_data, file=f)
12
13# Deactivate offline
14api_client.deactivate_offline(data=deactivate_offline_data)
Python
1product = "lkprod1"
2license_key = "GPB7-279T-6MNK-CQLK"
3feature = "lkprod1f1"
4
5license_feature_data = api_client.check_license_feature(
6 product=product, feature=feature, license_key=license_key
7)
8
9print(license_feature_data)
Python
1product = "lkprod1"
2license_key = "GPB7-279T-6MNK-CQLK"
3feature = "lkprod1f1"
4
5api_client.floating_feature_release(
6 product=product, feature=feature, license_key=license_key
7)
Python
1product = "lkprod1"
2license_key = "GPB7-279T-6MNK-CQLK"
3feature = "lkprod1f1"
4
5is_released = api_client.floating_feature_release(
6 product=product, feature=feature, license_key=license_key
7)
8
9print(is_released)
Updated 22 Mar 2024
Did this page help you?