Consumption-Based
Consumption licenses are ideal for applications where usage is metered based on a chosen metric, for example the number of API calls, data transfer volume, or any other measurable unit.
These licenses allow developers to set usage limits and track consumption, ensuring fair and flexible licensing for their users.
- Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
- Created a LicenseID using either LicenseID::fromKey or LicenseID::fromUser function, depending on the activation method you prefer.
- Activated a license of any type.
When granting a license, choose the "consumption" type as the preferred option. The key parameters associated with this type are as follows:
- Max Consumption: This parameter specifies the upper limit for the license usage, defining the maximum number of permitted uses.
- Allow Overages: By using this parameter, the software vendor can determine whether to block any additional usage beyond the maximum consumption limit. This can be further configured to allow a limited number of over usages or to have no restrictions (unlimited) on overages.
- Reset Consumption: This parameter facilitates periodic resetting of the available usage count back to the value provided in the "Max Consumption" field. The reset period can be set to daily, weekly, monthly, or annually, as per the vendor's requirements.
maxConsumption() defines the upper limit or cap on the license usage, indicating the maximum number of allowed usages for the licensed product or service. This parameter ensures that users do not exceed a predetermined threshold, enabling software vendors to control and manage the license's usage scope. This method is shown below:
On the other hand, totalConsumption() refers to the actual number of times the license has been utilized by the end-users. Monitoring the total consumption is crucial for both software vendors and users, as it provides insights into the software's popularity and usage patterns.
The function named updateConsumption(), shown below, serves to modify the license consumptions based on the value specified in the first parameter.
By default, the value is set to 1, but it can be increased or decreased as needed.
Additionally, the function allows users to control whether the updated license information should be saved to a file or not, depending on the saveLicense boolean parameter.
If saveLicense is set to true, the changes will be saved to a file, ensuring persistent license data.
NotEnoughConsumptionException: The consumption license or feature has depleted its available resources.
Seen below, the syncConsumption() function is responsible for synchronizing the consumption license values with the server.
This synchronization guarantees that the server is up-to-date with the latest accurate consumption-based data.
The function accepts an optional parameter, requestOverage, which allows users to request consumption overages if necessary.
If no specific overage value is provided, the function will not request any particular overage amount from the server during synchronization.
In an unlimited consumption model, users are granted access to the software with unrestricted usage rights.
There are no predefined limits or quotas on the number of times the software can be used or the features that can be accessed.
Users can utilize the software freely and continuously, without any concerns about overages or exceeding usage limits.
Whether this is enabled can be checked within the SDK by using the following Boolean method:
In a consumption license, an overage refers to the additional usage beyond the predefined limits or allocated resources set in the license agreement.
Max overages refers to the maximum allowable number of additional usages beyond the defined consumption limit in a given period. Max overages can be accessed by using:
Note: In the case of unlimited overages, maxOverages() returns the maximum possible value.
In addition, developers have the option to verify whether overages are permitted by utilizing:
Consumption licenses can be reset on regular intervals, whether it be daily, weekly, monthly, or annually, as per the vendor's requirements. This consumption reset sets the totalConsumption() to equal 0, as to reset the total consumptions.
The period of time after which the consumption is reset can be accessed, in the form of a ConsumptionPeriod object using the following method:
Developers can also check for whether this periodic reset is enabled, by using the isResetConsumptionEnabled() method on a License object: