SDKs
Go SDK
Go License Client
26min
Go
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"
)
Go
config := license_client.NewLicenseClientConfiguration("apiKey", "sharedKey", "productCode")
client := license_client.NewLicenseClient(config)
Go
resp := client.ActivateLicense(license_client.ActivationRequest{
LicenseRequest: core_request.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
},
Hostname: "hostname",
AppVersion: "1.1.1",
...
})
Go
resp := client.ActivateLicense(license_client.ActivationRequest{
LicenseRequest: core_request.LicenseRequest{
Auth: auth.FromUsername("username", "password"),
},
Hostname: "hostname",
AppVersion: "1.1.1",
...
})
Go
err := client.DeactivateLicense(license_client.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
})
Go
err := client.DeactivateLicense(license_client.LicenseRequest{
Auth: auth.FromUsername("username", "password"),
})
Go
resp := client.CheckLicense(license_client.ActivationRequest{
LicenseRequest: core_request.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
},
...
})
Go
resp := client.CheckLicense(license_client.ActivationRequest{
LicenseRequest: core_request.LicenseRequest{
Auth: auth.FromUsername("username", "password"),
},
...
})
Go
// 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)
Go
// 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)
Go
# 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,
})
Go
resp := client.AddFeatureConsumption(license_client.FeatureConsumptionRequest{
LicenseRequest: license_client.LicenseRequest{
Auth: core_request.Auth{}.FromKey("licenseKey"),
},
Feature: "featureCode",
Consumptions: 1,
})
Go
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: "",
})
Go
// takes product code from configuration
resp := client.ProductDetails()
Go
err := client.TrackDeviceVariables(license_client.DeviceVariablesRequest{
LicenseRequest: core_request.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
},
Variables: map[string]string{
"key": "var",
},
})
Go
resp := client.GetDeviceVariables(license_client.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
})
Go
resp := client.FloatingBorrow(license_client.FloatingBorrowRequest{
LicenseRequest: license_client.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
},
BorrowedUntil: time.Now().UTC().Add(time.Hour * 24 * 5),
})
Go
client.FloatingRelease(license_client.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
})
Go
client.ChangePassword(license_client.ChangePasswordRequest{
PasswordAuth: core_request.PasswordAuth{
Username: "username",
Password: "password",
},
NewPassword: "abcd",
})
Go
resp := client.Versions(license_client.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
})
Go
resp := client.InstallationFile(license_client.LicenseRequest{
Auth: auth.FromKey("licenseKey"),
})
Go
resp := client.CustomerLicenseUsers(license_client.CustomerLicenseUsersRequest{
Customer: "customer",
})
Go
resp := client.SSOUrl(license_client.SSOUrlRequest{
CustomerAccountCode: "code",
})
Go
airgapClient := license_client.NewAirgapClient(config, "publicKey")
activationCode, err := airgapClient.AirgapInitialization("licenseKey", "signingKey")
return activationCode, cfg.HardwareId
Go
airgapClient := license_client.NewAirgapClient(config, "publicKey")
license, err := airgapClient.AirgapActivation("licensePolicy", "confirmationCode", 1234)
Updated 15 Sep 2023
Did this page help you?