bayesline.api.AppFeature#
- class bayesline.api.AppFeature(value: str) None#
Base for the constants naming an application’s features.
A subclass states the group its features are presented under once, and writes each feature down as a member whose value is its name within that group:
class RiskFeature(AppFeature): __group__ = "risk" AI_ENABLED = "ai_enabled"
The class and member names make up the identity everything granted on the feature hangs off; the group and value make up the alias it is presented under, which is free to change.
Members are not strings. Anywhere a feature has to be named as one, say which half is meant.
Parameters#
- valuestr
The name the feature is presented under, within its group.
Raises#
- ValueError
If the subclass states no
__group__, or the group or value is not lowercase[a-z0-9_-]+, in which case the alias they build would match nothing wherever it is used.
Methods
declare(*, description, default_enabled[, ...])Declare this feature, taking its identity and alias from the constant.
__init__(value)Attributes
identityThe durable identity of this member.
The group this application's features are presented under.
The name this feature is presented under.
The alias this feature is presented under.
- property group: str#
The group this application’s features are presented under.
Returns#
- str
The subclass’s
__group__.
- property feature_name: str#
The name this feature is presented under.
Returns#
- str
The member’s value.
- property label: str#
The alias this feature is presented under.
Returns#
- str
The group and name joined by a period.
- declare(*, description: str, default_enabled: bool, is_editable: bool = True, default_data: dict[str, Any] | None = None, default_grants: tuple[Grant, ...] = ()) FeatureDeclaration#
Declare this feature, taking its identity and alias from the constant.
Parameters#
- descriptionstr
What the feature is.
- default_enabledbool
The value when nothing more specific applies.
- is_editablebool, default=True
Whether anything may move it.
- default_datadict[str, Any] | None, default=None
The payload when nothing more specific applies.
- default_grantstuple[Grant, …], default=()
Grants the application ships with it.
Returns#
- FeatureDeclaration
The declaration, identified by this constant’s name.