flexmeasures.data.services.plan_quotas

Enforce organisation plan quotas for all ORM creation paths.

Functions

flexmeasures.data.services.plan_quotas.enforce_plan_quotas(session: Session, flush_context, instances) → None

Apply plan constraints across ORM paths, including recursive asset copies.

flexmeasures.data.services.plan_quotas.get_organisations_over_plan_quotas(session: Session, plan: Plan, limits: Mapping[str, int]) → list[str]

Name each organisation on the plan whose usage is above one of the given limits, one line per organisation and quota.

The limits are keyed by resource (users, assets or clients), so that a tightened plan can say whom it puts over a quota.

flexmeasures.data.services.plan_quotas.get_plan_quota_warning(plan: Plan, usage: Mapping[str, int]) → str

Explain what the selected plan would restrict at the organisation’s current usage.

flexmeasures.data.services.plan_quotas.get_plan_usage(session: Session, account_id: int, *resources: str) → dict[str, int]

Count an organisation’s quota usage for the requested resources, or all three.

Exceptions

exception flexmeasures.data.services.plan_quotas.PlanQuotaExceeded

An organisation’s plan prevents an operation.