SDKs
Go SDK
Go License Client
26min
Go
1
2import (
3 "gitlab.com/l3178/sdk-go/license_client"
4 "gitlab.com/l3178/sdk-go/core/auth"
5 core_request "gitlab.com/l3178/sdk-go/core/models/request"
6)
Go
1config := license_client.NewLicenseClientConfiguration("apiKey", "sharedKey", "productCode")
2client := license_client.NewLicenseClient(config)
Go
1resp := client.ActivateLicense(license_client.ActivationRequest{
2 LicenseRequest: core_request.LicenseRequest{
3 Auth: auth.FromKey("licenseKey"),
4 },
5 Hostname: "hostname",
6 AppVersion: "1.1.1",
7 ...
8})
Go
1resp := client.ActivateLicense(license_client.ActivationRequest{
2 LicenseRequest: core_request.LicenseRequest{
3 Auth: auth.FromUsername("username", "password"),
4 },
5 Hostname: "hostname",
6 AppVersion: "1.1.1",
7 ...
8})
Go
1err := client.DeactivateLicense(license_client.LicenseRequest{
2 Auth: auth.FromKey("licenseKey"),
3})
Go
1err := client.DeactivateLicense(license_client.LicenseRequest{
2 Auth: auth.FromUsername("username", "password"),
3})
Go
1resp := client.CheckLicense(license_client.ActivationRequest{
2 LicenseRequest: core_request.LicenseRequest{
3 Auth: auth.FromKey("licenseKey"),
4 },
5 ...
6})
Go
1resp := client.CheckLicense(license_client.ActivationRequest{
2 LicenseRequest: core_request.LicenseRequest{
3 Auth: auth.FromUsername("username", "password"),
4 },
5 ...
6})
Go
1// Generate offline license request data
2resp := client.GenerateOfflineLicenseRequest(license_client.ActivationRequest{
3 LicenseRequest: core_request.LicenseRequest{
4 Auth: auth.FromKey("licenseKey"),
5 },
6}, license_client.OfflineActivationRequest)
7
8// Write to request file if you want to activate license manually
9encoded, err := resp.Value.Encode()
10ioutil.WriteFile("activate_offline.req", []byte(encoded), os.ModePerm)
11
12// Activate offline license using API
13client.ActivateOffline(offlineLicenseRequest)
Go
1// Generate offline license request data
2resp := client.GenerateOfflineLicenseRequest(license_client.ActivationRequest{
3 LicenseRequest: core_request.LicenseRequest{
4 Auth: auth.FromKey("licenseKey"),
5 },
6}, license_client.OfflineDeactivationRequest)
7
8// Write to request file if you want to deactivate license manually
9encoded, err := resp.Value.Encode()
10ioutil.WriteFile("deactivate_offline.req", []byte(encoded), os.ModePerm)
11
12// Deactivate offline license using API
13client.DeactivateOffline(offlineLicenseRequest)
Go
1
2# Add 1 consumption
3resp := client.AddConsumption(license_client.ConsumptionRequest{
4 LicenseRequest: core_request.LicenseRequest{
5 Auth: auth.FromKey("licenseKey"),
6 },
7 Consumptions: 1,
8})
9
10# Add 1 consumption, allow overages and define max overages
11resp := client.AddConsumption(license_client.ConsumptionRequest{
12 LicenseRequest: core_request.LicenseRequest{
13 Auth: auth.FromKey("licenseKey"),
14 },
15 Consumptions: 1,
16 MaxOverages: 5,
17 AllowOverages: true,
18})
Go
1
2resp := client.AddFeatureConsumption(license_client.FeatureConsumptionRequest{
3 LicenseRequest: license_client.LicenseRequest{
4 Auth: core_request.Auth{}.FromKey("licenseKey"),
5 },
6 Feature: "featureCode",
7 Consumptions: 1,
8})
Go
1resp := client.TrialKey(license_client.TrialLicenseRequest{
2 LicenseRequest: core_request.LicenseRequest{
3 Auth: auth.FromKey("licenseKey"),
4 },
5 Email: "",
6 LicensePolicy: "",
7 FirstName: "",
8 LastName: "",
9 Phone: "",
10 Address: "",
11 PostCode: "",
12 State: "",
13 Country: "",
14 City: "",
15 Reference: "",
16})
Go
1
2// takes product code from configuration
3resp := client.ProductDetails()
Go
1
2err := client.TrackDeviceVariables(license_client.DeviceVariablesRequest{
3 LicenseRequest: core_request.LicenseRequest{
4 Auth: auth.FromKey("licenseKey"),
5 },
6 Variables: map[string]string{
7 "key": "var",
8 },
9})
Go
1resp := client.GetDeviceVariables(license_client.LicenseRequest{
2 Auth: auth.FromKey("licenseKey"),
3})
Go
1resp := client.FloatingBorrow(license_client.FloatingBorrowRequest{
2 LicenseRequest: license_client.LicenseRequest{
3 Auth: auth.FromKey("licenseKey"),
4 },
5 BorrowedUntil: time.Now().UTC().Add(time.Hour * 24 * 5),
6})
Go
1client.FloatingRelease(license_client.LicenseRequest{
2 Auth: auth.FromKey("licenseKey"),
3})
Go
1client.ChangePassword(license_client.ChangePasswordRequest{
2 PasswordAuth: core_request.PasswordAuth{
3 Username: "username",
4 Password: "password",
5 },
6 NewPassword: "abcd",
7})
Go
1resp := client.Versions(license_client.LicenseRequest{
2 Auth: auth.FromKey("licenseKey"),
3})
Go
1
2resp := client.InstallationFile(license_client.LicenseRequest{
3 Auth: auth.FromKey("licenseKey"),
4})
Go
1resp := client.CustomerLicenseUsers(license_client.CustomerLicenseUsersRequest{
2 Customer: "customer",
3})
Go
1resp := client.SSOUrl(license_client.SSOUrlRequest{
2 CustomerAccountCode: "code",
3})
Go
1airgapClient := license_client.NewAirgapClient(config, "publicKey")
2activationCode, err := airgapClient.AirgapInitialization("licenseKey", "signingKey")
3return activationCode, cfg.HardwareId
Go
1airgapClient := license_client.NewAirgapClient(config, "publicKey")
2license, err := airgapClient.AirgapActivation("licensePolicy", "confirmationCode", 1234)
Updated 21 May 2024
Did this page help you?