Skip to main content

org_budgets

Creates, updates, deletes, gets or lists an org_budgets resource.

Overview

Nameorg_budgets
TypeResource
Idgithub.billing.org_budgets

Fields

The following fields are returned by SELECT queries:

Response when updating a budget

NameDatatypeDescription
idstringID of the budget.
budget_entity_namestringThe name of the entity to apply the budget to (example: octocat/hello-world)
budget_alertingobject
budget_amountintegerThe budget amount in whole dollars. For license-based products, this represents the number of licenses.
budget_product_skustringA single product or sku to apply the budget to. (example: actions_linux)
budget_scopestringThe type of scope for the budget (enterprise, organization, repository, cost_center, multi_user_customer, multi_user_cost_center, user) (example: enterprise)
budget_typestringThe type of pricing for the budget (ProductPricing) (example: ProductPricing)
prevent_further_usagebooleanWhether to prevent additional spending once the budget is exceeded
userstringThe user login when the budget is scoped to a single user (user scope). (example: octocat)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_budget_orgselectorg, budget_idGets a budget by ID. The authenticated user must be an organization admin or billing manager.
get_all_budgets_orgselectorgpage, per_page, scope, userGets all budgets for an organization. The authenticated user must be an organization admin or billing manager.
Each page returns up to 100 budgets.
create_organization_budgetinsertorgCreates a new budget for an organization. The authenticated user must be an
organization admin or billing manager.
update_budget_orgupdateorg, budget_idUpdates an existing budget for an organization. The authenticated user must be an organization admin or billing manager.
delete_budget_orgdeleteorg, budget_idDeletes a budget by ID for an organization. The authenticated user must be an organization admin or billing manager.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
budget_idstringThe ID corresponding to the budget.
orgstringThe organization name. The name is not case sensitive.
pageintegerThe page number of the results to fetch.
per_pageintegerThe number of results per page (max 100).
scopestringFilter budgets by scope type. - organization: Budgets scoped to the organization. - repository: Budgets scoped to a repository. - multi_user_customer: Universal budgets that apply to all users in the organization. - user: Budgets scoped to an individual user.
userstringFilter consumed amount details for budgets by the specified user login.

SELECT examples

Gets a budget by ID. The authenticated user must be an organization admin or billing manager.

SELECT
id,
budget_entity_name,
budget_alerting,
budget_amount,
budget_product_sku,
budget_scope,
budget_type,
prevent_further_usage,
user
FROM github.billing.org_budgets
WHERE org = '{{ org }}' -- required
AND budget_id = '{{ budget_id }}' -- required
;

INSERT examples

Creates a new budget for an organization. The authenticated user must be an
organization admin or billing manager.

INSERT INTO github.billing.org_budgets (
budget_amount,
prevent_further_usage,
budget_alerting,
budget_scope,
budget_entity_name,
budget_type,
budget_product_sku,
user,
org
)
SELECT
{{ budget_amount }},
{{ prevent_further_usage }},
'{{ budget_alerting }}',
'{{ budget_scope }}',
'{{ budget_entity_name }}',
'{{ budget_type }}',
'{{ budget_product_sku }}',
'{{ user }}',
'{{ org }}'
RETURNING
budget,
message
;

UPDATE examples

Updates an existing budget for an organization. The authenticated user must be an organization admin or billing manager.

UPDATE github.billing.org_budgets
SET
budget_amount = {{ budget_amount }},
prevent_further_usage = {{ prevent_further_usage }},
budget_alerting = '{{ budget_alerting }}',
budget_scope = '{{ budget_scope }}',
budget_entity_name = '{{ budget_entity_name }}',
budget_type = '{{ budget_type }}',
budget_product_sku = '{{ budget_product_sku }}',
user = '{{ user }}'
WHERE
org = '{{ org }}' --required
AND budget_id = '{{ budget_id }}' --required
RETURNING
budget,
message;

DELETE examples

Deletes a budget by ID for an organization. The authenticated user must be an organization admin or billing manager.

DELETE FROM github.billing.org_budgets
WHERE org = '{{ org }}' --required
AND budget_id = '{{ budget_id }}' --required
;