reviewboard.licensing.license¶
Information on product licenses.
New in version 8.0.
- class LicenseStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
EnumThe status of a license.
New in version 8.0.
- class LicenseLineItem[source]¶
Bases:
TypedDictA line item to show for a license.
New in version 8.0.
- content: str¶
The content for the line item.
This may be a plain text string (which will be escaped) or a safe HTML-formatted string, depending on the
content_is_htmlflag.
- __closed__ = None¶
- __extra_items__ = typing_extensions.NoExtraItems¶
- __mutable_keys__ = frozenset({'content', 'content_is_html', 'icon'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'content', 'content_is_html', 'icon'})¶
- __total__ = True¶
- class LicenseInfo(*, license_id: str, licensed_to: str, product_name: str, auto_renew: bool = False, can_upload_license: bool = False, expires: datetime | None = None, grace_period_days_remaining: int = 0, is_trial: bool = False, license_instance: Any = None, line_items: Sequence[LicenseLineItem] | None = None, plan_id: str | None = None, plan_name: str | None = None, status: LicenseStatus = LicenseStatus.UNLICENSED, summary: str = '')[source]¶
Bases:
objectInformation on a license.
This may be an active, expired, or trial license.
License providers should use this to communicate information about a license to the rest of Review Board, but generally will have their own more tailored license structure behind it. This is not intended as a fully-featured license model.
New in version 8.0.
- __init__(*, license_id: str, licensed_to: str, product_name: str, auto_renew: bool = False, can_upload_license: bool = False, expires: datetime | None = None, grace_period_days_remaining: int = 0, is_trial: bool = False, license_instance: Any = None, line_items: Sequence[LicenseLineItem] | None = None, plan_id: str | None = None, plan_name: str | None = None, status: LicenseStatus = LicenseStatus.UNLICENSED, summary: str = '') None[source]¶
Initialize the license information.
- Parameters:
licensed_id (
str) –A backend-specific ID for this license.
This may be used for communication with a license server, client-side.
licensed_to (
str) –Who the license is licensed to.
This may be the company or a division of a company (cost center).
product_name (
str) – The name of the product being licensed.auto_renew (
bool, optional) – Whether the license is set to auto-renew on the license server. WhenTrue, the license summary and details show “renews on” instead of “expires on”.can_upload_license (
bool, optional) – Whether a new license file can be manually uploaded for this license.expires (
datetime.datetime, optional) – The expiration date/time of the license.grace_period_days_remaining (
int, optional) –The number of grace period days remaining on the license.
This is only considered when the license is expired.
is_trial (
bool, optional) – Whether this is a trial license.license_instance (
object, optional) –The backend-specific license instance.
This is used purely for the convenience of a license provider. It may be
None.line_items (
Sequence[LicenseLineItem], optional) – Any displayable line items to show on license information.plan_id (
str, optional) – A backend-specific plan ID for this license.plan_name (
str, optional) – A display name for the plan.status (
LicenseStatus, optional) – The active/expiration status of this license.summary (
str, optional) –A descriptive summary of the license.
If not provided, one will be automatically generated based off the product name and status.
- license_id: str¶
A backend-specific ID for this license.
This may be used for communication with a license server, client-side.
- licensed_to: str¶
Who the license is licensed to.
This may be the company or a division of a company (cost center).
- auto_renew: bool¶
Whether the license is set to auto-renew on the license server.
When
True, the license is presented as renewing rather than expiring. The license summary and detail line will say “renews on” instead of “expires on”, and we don’t show warnings that the license will expire soon.This is dynamic billing-side state and is not part of the signed license payload. License providers should populate this from the most recent license check.
- grace_period_days_remaining: int¶
The number of grace period days remaining on the license.
This is only considered when the license is expired.
- license_instance: Any¶
The backend-specific license instance.
This is used purely for the convenience of a license provider. It may be
None.
- line_items: Sequence[LicenseLineItem]¶
Any displayable line items to show on license information.
- status: LicenseStatus¶
The active/expiration status of this license.
- summary: str¶
A descriptive summary of the license.
If not provided, one will be automatically generated based off the product name and status.
- get_summary() str[source]¶
Return a summary for the license.
This will return
summaryif provided. Otherwise, it will generate a suitable summary based on the state of the license.Subclasses can override this to provide custom summaries.
- Returns:
The summary of the license.
- Return type:
- format_plan_name() str[source]¶
Return a formatted version of the plan name.
This allows a license implementation to provide a custom way of formatting the plan name for use in the summary.
By default, this returns the plan name as-is.
This may not be used if a plan name is not set.
- Returns:
The formatted plan name.
- Return type:
- get_expires_soon() bool[source]¶
Return whether or not the license expires soon.
“Soon” is defined as the result of
get_expires_soon_days_threshold(), which can be overridden by subclasses. By default, this is defined as within 10 days for a trial license or within 30 days for a non-trial license.This does not include the grace period.
- Returns:
Trueif the license expires soon.Falseif it does not, or if the license has already expired.- Return type:
- get_expires_soon_days_threshold() int[source]¶
Return the number of days considered “soon” for expiration.
This can be overridden by subclasses to change the number of days based on the term or renewal times of a license.
By default, this is defined as within 10 days for a trial license or within 30 days for a non-trial license.
This does not include the grace period.
- Returns:
The number of days considered “soon” for expiration, based on the license state or type.
- Return type: