Reference documentation and code samples for the Google Cloud Billing Budgets V1 Client class ThresholdRule.
ThresholdRule contains the definition of a threshold. Threshold rules define
the triggering events used to generate a budget notification email. When a
threshold is crossed (spend exceeds the specified percentages of the
budget), budget alert emails are sent to the email recipients you specify
in theNotificationsRule.
Threshold rules also affect the fields included in theJSON data
objectsent to a Pub/Sub topic.
Threshold rules arerequiredif using email notifications.
Threshold rules areoptionalif only setting apubsubTopicNotificationsRule,
unless you want your JSON data object to include data about the thresholds
you set.
For more information, seeset budget threshold rules and
actions.
Generated from protobuf messagegoogle.cloud.billing.budgets.v1.ThresholdRule
Namespace
Google \ Cloud \ Billing \ Budgets \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ threshold_percent
float
Required. Send an alert when this threshold is exceeded. This is a 1.0-based percentage, so 0.5 = 50%. Validation: non-negative number.
↳ spend_basis
int
Optional. The type of basis used to determine if spend has passed the threshold. Behavior defaults to CURRENT_SPEND if not set.
getThresholdPercent
Required. Send an alert when this threshold is exceeded.
This is a 1.0-based percentage, so 0.5 = 50%.
Validation: non-negative number.
Returns
Type
Description
float
setThresholdPercent
Required. Send an alert when this threshold is exceeded.
This is a 1.0-based percentage, so 0.5 = 50%.
Validation: non-negative number.
Parameter
Name
Description
var
float
Returns
Type
Description
$this
getSpendBasis
Optional. The type of basis used to determine if spend has passed the
threshold. Behavior defaults to CURRENT_SPEND if not set.
Returns
Type
Description
int
setSpendBasis
Optional. The type of basis used to determine if spend has passed the
threshold. Behavior defaults to CURRENT_SPEND if not set.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud Billing Budgets V1 Client - Class ThresholdRule (2.0.5)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.5 (latest)](/php/docs/reference/cloud-billing-budgets/latest/V1.ThresholdRule)\n- [2.0.4](/php/docs/reference/cloud-billing-budgets/2.0.4/V1.ThresholdRule)\n- [1.4.5](/php/docs/reference/cloud-billing-budgets/1.4.5/V1.ThresholdRule)\n- [1.3.1](/php/docs/reference/cloud-billing-budgets/1.3.1/V1.ThresholdRule)\n- [1.2.2](/php/docs/reference/cloud-billing-budgets/1.2.2/V1.ThresholdRule)\n- [1.1.0](/php/docs/reference/cloud-billing-budgets/1.1.0/V1.ThresholdRule)\n- [1.0.5](/php/docs/reference/cloud-billing-budgets/1.0.5/V1.ThresholdRule) \nReference documentation and code samples for the Google Cloud Billing Budgets V1 Client class ThresholdRule.\n\nThresholdRule contains the definition of a threshold. Threshold rules define\nthe triggering events used to generate a budget notification email. When a\nthreshold is crossed (spend exceeds the specified percentages of the\nbudget), budget alert emails are sent to the email recipients you specify\nin the\n[NotificationsRule](#notificationsrule).\n\nThreshold rules also affect the fields included in the\n[JSON data\nobject](https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format)\nsent to a Pub/Sub topic.\nThreshold rules are *required* if using email notifications.\nThreshold rules are *optional* if only setting a\n[`pubsubTopic` NotificationsRule](#NotificationsRule),\nunless you want your JSON data object to include data about the thresholds\nyou set.\nFor more information, see\n[set budget threshold rules and\nactions](https://cloud.google.com/billing/docs/how-to/budgets#budget-actions).\n\nGenerated from protobuf message `google.cloud.billing.budgets.v1.ThresholdRule`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Billing \\\\ Budgets \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getThresholdPercent\n\nRequired. Send an alert when this threshold is exceeded.\n\nThis is a 1.0-based percentage, so 0.5 = 50%.\nValidation: non-negative number.\n\n### setThresholdPercent\n\nRequired. Send an alert when this threshold is exceeded.\n\nThis is a 1.0-based percentage, so 0.5 = 50%.\nValidation: non-negative number.\n\n### getSpendBasis\n\nOptional. The type of basis used to determine if spend has passed the\nthreshold. Behavior defaults to CURRENT_SPEND if not set.\n\n### setSpendBasis\n\nOptional. The type of basis used to determine if spend has passed the\nthreshold. Behavior defaults to CURRENT_SPEND if not set."]]