Skip to content

Budget

A Datatailr spend budget (cap, usage, prevent_overflow, ACL).

Fields match dt cost list-budgets / dt cost get-budget JSON (see internal-docs/budgets.md). Optional fields may be omitted when the caller only has operate visibility on a budget row.

Construct by name to load from the platform ::

b = Budget("my_budget")

The numeric :attr:id is the database budget id used in job definitions as budget_id. Rows built via :meth:from_dict (e.g. from list-budgets) reflect the JSON as returned by the API and do not trigger an extra fetch.

acl property

The budget ACL. Will be None if user does not have read permissions.

budget_usd property

Cap in USD when visible to the caller.

id property

Numeric budget id (budget_id in job JSON).

name property

Budget name.

prevent_overflow property

Whether the platform blocks spend past the limit when visible.

usage_percentage property

Usage as a percent of cap when available.

usage_usd property

Current-month usage in USD when visible.

__init__(name)

Load a budget by name from the platform (dt cost get-budget).

Parameters:

Name Type Description Default
name str

Non-empty budget name.

required

Raises:

Type Description
ValueError

If name is empty or the API response is invalid.

add(name, amount, *, prevent_overflow=False, acl=None) staticmethod

Create a budget. Admin only.

add_acl(name, acl) staticmethod

Merge ACL entries. Admin only.

from_dict(data) classmethod

Build a :class:Budget from CLI/JSON dict without an extra API call.

get(name) staticmethod

Load one budget by name.

get_acl(name) staticmethod

Returns the budget ACL. Admin only.

ls() staticmethod

Get a list of budgets visible to the current user.

remove(name) staticmethod

Remove a budget. Admin only.

remove_acl(name, acl) staticmethod

Remove ACL entries. Admin only.

set_acl(name, acl) staticmethod

Replace the budget ACL. Admin only.

update(name, *, amount=None, prevent_overflow=None) staticmethod

Update budget cap and/or prevent_overflow. Admin only.