A budget helps you organize and track credit usage in your UP42 account by grouping orders and processing jobs by cost center. This provides better visibility into spending and can be linked to a project ID for internal tracking.
Assign a budget when creating orders or processing jobs to attribute credit consumption.
A data class that represents a budget in the system.
Attributes
| Attribute | Description |
|---|---|
id | str The budget ID. |
name | str The name of the budget. |
status | BudgetStatus The budget status. |
created_by | str The ID of the user who created the budget. |
created_at | str The timestamp when the budget was created. |
updated_at | str The timestamp when the budget was last updated. |
description | Optional[str] The description of the budget. |
external_id | Optional[str] The ID of the external project associated with the budget. |
# Select a budgetbudget_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch budget infobudget = up42.Budget.get(budget_id=budget_id)
# Define outputprint(f"Budget details for ID: {budget.id}")print(f"Name: {budget.name}")print(f"Status: {budget.status}")print(f"Description: {budget.description}")print(f"External ID: {budget.external_id}")Methods
Retrieves all budgets, with optional filtering. Returns Iterator[Budget]. Use itertools.islice to offset and limit the results.
| Parameter | Description |
|---|---|
status | Optional[List[BudgetStatus]] Budget statuses. Use to search for budgets with any of the provided statuses. |
sort_by | Optional[utils.SortingField] The results sorting method that arranges elements in ascending or descending order based on a chosen field. To view the list of possible values, see |
from itertools import islice
# Search for budgetsbudgets = up42.Budget.all( status=["ACTIVE"], sort_by=up42.BudgetSorting.updated_at.desc,)
# Define outputfor budget in islice(budgets, 0, 5): # Print first 5 results print(f"- Budget ID: {budget.id}") print(f" Name: {budget.name}") print(f" Status: {budget.status}") print(f" Updated at: {budget.updated_at}\n")Retrieves a specific budget by its ID. Returns Budget.
| Parameter | Description |
|---|---|
budget_id | str The budget ID. |
# Select a budgetbudget_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch budget infobudget = up42.Budget.get(budget_id=budget_id)
# Define outputprint(f"Budget details for ID: {budget.id}")print(f"Name: {budget.name}")print(f"Status: {budget.status}")Retrieves the credit usage for a budget. Credit consumption is recorded when orders or processing jobs reach a specific status or substatus. Returns BudgetUsage.
# Select a budgetbudget_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch credit usagebudget = up42.Budget.get(budget_id=budget_id)usage = budget.get_usage()
# Define outputprint(f"Budget ID: {usage.budget_id}")print(f"Consumed credits: {usage.consumed_credits}")A data class that represents the credit usage of a budget.
Attributes
| Attribute | Description |
|---|---|
budget_id | str The budget ID. |
consumed_credits | int The number of credits consumed by all transactions associated with this budget. |
# Select a budgetbudget_id = "a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Fetch credit usagebudget = up42.Budget.get(budget_id=budget_id)usage = budget.get_usage()
# Define outputprint(f"Budget ID: {usage.budget_id}")print(f"Consumed credits: {usage.consumed_credits}")A data class that represents the budget enforcement settings for an account.
Attributes
| Attribute | Description |
|---|---|
enforcement_enabled | bool Indicates whether budget enforcement is enabled for the account. When enabled, a valid budget ID is required for orders and processing jobs. |
budget_setting_id | Optional[str] The budget setting ID. |
# Fetch budget settingssettings = up42.BudgetSettings.get()
# Define outputprint(f"Enforcement enabled: {settings.enforcement_enabled}")print(f"Budget setting ID: {settings.budget_setting_id}")Methods
Retrieves the budget enforcement settings for the account. Returns BudgetSettings.
# Fetch budget settingssettings = up42.BudgetSettings.get()
# Define outputprint(f"Enforcement enabled: {settings.enforcement_enabled}")A class that provides sorting options for budgets.
Attributes
| Attribute | Description |
|---|---|
updated_at | utils.SortingField Sorts by update date. The default order is ascending. |
from itertools import islice
# Sort by update date, from the most recent to the earliestbudgets_sorted = up42.Budget.all(sort_by=up42.BudgetSorting.updated_at.desc)
# Define outputfor budget in islice(budgets_sorted, 0, 5): # Print first 5 results print(f"- Budget ID: {budget.id}") print(f" Name: {budget.name}") print(f" Updated at: {budget.updated_at}\n")