budget_model.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.billing.budgets.v1beta1;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/protobuf/struct.proto";
  19. import "google/type/date.proto";
  20. import "google/type/money.proto";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/billing/budgets/v1beta1;budgets";
  22. option java_multiple_files = true;
  23. option java_package = "com.google.cloud.billing.budgets.v1beta1";
  24. // A budget is a plan that describes what you expect to spend on Cloud
  25. // projects, plus the rules to execute as spend is tracked against that plan,
  26. // (for example, send an alert when 90% of the target spend is met).
  27. // The budget time period is configurable, with options such as month (default),
  28. // quarter, year, or custom time period.
  29. message Budget {
  30. option (google.api.resource) = {
  31. type: "billingbudgets.googleapis.com/Budget"
  32. pattern: "billingAccounts/{billing_account}/budgets/{budget}"
  33. };
  34. // Output only. Resource name of the budget.
  35. // The resource name implies the scope of a budget. Values are of the form
  36. // `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
  37. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  38. // User data for display name in UI.
  39. // Validation: <= 60 chars.
  40. string display_name = 2;
  41. // Optional. Filters that define which resources are used to compute the actual spend
  42. // against the budget amount, such as projects, services, and the budget's
  43. // time period, as well as other filters.
  44. Filter budget_filter = 3 [(google.api.field_behavior) = OPTIONAL];
  45. // Required. Budgeted amount.
  46. BudgetAmount amount = 4 [(google.api.field_behavior) = REQUIRED];
  47. // Optional. Rules that trigger alerts (notifications of thresholds
  48. // being crossed) when spend exceeds the specified percentages of the budget.
  49. //
  50. // Optional for `pubsubTopic` notifications.
  51. //
  52. // Required if using email notifications.
  53. repeated ThresholdRule threshold_rules = 5 [(google.api.field_behavior) = OPTIONAL];
  54. // Optional. Rules to apply to notifications sent based on budget spend and thresholds.
  55. AllUpdatesRule all_updates_rule = 6 [(google.api.field_behavior) = OPTIONAL];
  56. // Optional. Etag to validate that the object is unchanged for a
  57. // read-modify-write operation.
  58. // An empty etag will cause an update to overwrite other changes.
  59. string etag = 7 [(google.api.field_behavior) = OPTIONAL];
  60. }
  61. // The budgeted amount for each usage period.
  62. message BudgetAmount {
  63. // Specification for what amount to use as the budget.
  64. oneof budget_amount {
  65. // A specified amount to use as the budget.
  66. // `currency_code` is optional. If specified when creating a budget, it must
  67. // match the currency of the billing account. If specified when updating a
  68. // budget, it must match the currency_code of the existing budget.
  69. // The `currency_code` is provided on output.
  70. google.type.Money specified_amount = 1;
  71. // Use the last period's actual spend as the budget for the present period.
  72. // LastPeriodAmount can only be set when the budget's time period is a
  73. // [Filter.calendar_period][google.cloud.billing.budgets.v1beta1.Filter.calendar_period]. It cannot be set in combination with
  74. // [Filter.custom_period][google.cloud.billing.budgets.v1beta1.Filter.custom_period].
  75. LastPeriodAmount last_period_amount = 2;
  76. }
  77. }
  78. // Describes a budget amount targeted to the last [Filter.calendar_period][google.cloud.billing.budgets.v1beta1.Filter.calendar_period]
  79. // spend. At this time, the amount is automatically 100% of the last calendar
  80. // period's spend; that is, there are no other options yet.
  81. // Future configuration options will be described here (for example, configuring
  82. // a percentage of last period's spend).
  83. // LastPeriodAmount cannot be set for a budget configured with
  84. // a [Filter.custom_period][google.cloud.billing.budgets.v1beta1.Filter.custom_period].
  85. message LastPeriodAmount {
  86. }
  87. // ThresholdRule contains the definition of a threshold. Threshold rules define
  88. // the triggering events used to generate a budget notification email. When a
  89. // threshold is crossed (spend exceeds the specified percentages of the
  90. // budget), budget alert emails are sent to the email recipients you specify
  91. // in the
  92. // [NotificationsRule](#notificationsrule).
  93. //
  94. // Threshold rules also affect the fields included in the
  95. // [JSON data
  96. // object](https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format)
  97. // sent to a Pub/Sub topic.
  98. //
  99. // Threshold rules are _required_ if using email notifications.
  100. //
  101. // Threshold rules are _optional_ if only setting a
  102. // [`pubsubTopic` NotificationsRule](#NotificationsRule),
  103. // unless you want your JSON data object to include data about the thresholds
  104. // you set.
  105. //
  106. // For more information, see
  107. // [set budget threshold rules and
  108. // actions](https://cloud.google.com/billing/docs/how-to/budgets#budget-actions).
  109. message ThresholdRule {
  110. // The type of basis used to determine if spend has passed the threshold.
  111. enum Basis {
  112. // Unspecified threshold basis.
  113. BASIS_UNSPECIFIED = 0;
  114. // Use current spend as the basis for comparison against the threshold.
  115. CURRENT_SPEND = 1;
  116. // Use forecasted spend for the period as the basis for comparison against
  117. // the threshold.
  118. // FORECASTED_SPEND can only be set when the budget's time period is a
  119. // [Filter.calendar_period][google.cloud.billing.budgets.v1beta1.Filter.calendar_period]. It cannot be set in combination with
  120. // [Filter.custom_period][google.cloud.billing.budgets.v1beta1.Filter.custom_period].
  121. FORECASTED_SPEND = 2;
  122. }
  123. // Required. Send an alert when this threshold is exceeded.
  124. // This is a 1.0-based percentage, so 0.5 = 50%.
  125. // Validation: non-negative number.
  126. double threshold_percent = 1 [(google.api.field_behavior) = REQUIRED];
  127. // Optional. The type of basis used to determine if spend has passed the
  128. // threshold. Behavior defaults to CURRENT_SPEND if not set.
  129. Basis spend_basis = 2 [(google.api.field_behavior) = OPTIONAL];
  130. }
  131. // AllUpdatesRule defines notifications that are sent based on budget spend
  132. // and thresholds.
  133. message AllUpdatesRule {
  134. // Optional. The name of the Pub/Sub topic where budget related messages will be
  135. // published, in the form `projects/{project_id}/topics/{topic_id}`. Updates
  136. // are sent at regular intervals to the topic.
  137. // The topic needs to be created before the budget is created; see
  138. // https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications
  139. // for more details.
  140. // Caller is expected to have
  141. // `pubsub.topics.setIamPolicy` permission on the topic when it's set for a
  142. // budget, otherwise, the API call will fail with PERMISSION_DENIED. See
  143. // https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#permissions_required_for_this_task
  144. // for more details on Pub/Sub roles and permissions.
  145. string pubsub_topic = 1 [(google.api.field_behavior) = OPTIONAL];
  146. // Optional. Required when [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic] is set. The schema version of
  147. // the notification sent to [AllUpdatesRule.pubsub_topic][google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic]. Only "1.0" is
  148. // accepted. It represents the JSON schema as defined in
  149. // https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format.
  150. string schema_version = 2 [(google.api.field_behavior) = OPTIONAL];
  151. // Optional. Targets to send notifications to when a threshold is exceeded. This is in
  152. // addition to default recipients who have billing account IAM roles.
  153. // The value is the full REST resource name of a monitoring notification
  154. // channel with the form
  155. // `projects/{project_id}/notificationChannels/{channel_id}`. A maximum of 5
  156. // channels are allowed. See
  157. // https://cloud.google.com/billing/docs/how-to/budgets-notification-recipients
  158. // for more details.
  159. repeated string monitoring_notification_channels = 3 [(google.api.field_behavior) = OPTIONAL];
  160. // Optional. When set to true, disables default notifications sent when a threshold is
  161. // exceeded. Default notifications are sent to those with Billing Account
  162. // Administrator and Billing Account User IAM roles for the target account.
  163. bool disable_default_iam_recipients = 4 [(google.api.field_behavior) = OPTIONAL];
  164. }
  165. // A filter for a budget, limiting the scope of the cost to calculate.
  166. message Filter {
  167. // Specifies how credits are applied when determining the spend for
  168. // threshold calculations. Budgets track the total cost minus any applicable
  169. // selected credits.
  170. // [See the documentation for a list of credit
  171. // types](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type).
  172. enum CreditTypesTreatment {
  173. CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0;
  174. // All types of credit are subtracted from the gross cost to determine the
  175. // spend for threshold calculations.
  176. INCLUDE_ALL_CREDITS = 1;
  177. // All types of credit are added to the net cost to determine the spend for
  178. // threshold calculations.
  179. EXCLUDE_ALL_CREDITS = 2;
  180. // [Credit
  181. // types](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type)
  182. // specified in the credit_types field are subtracted from the
  183. // gross cost to determine the spend for threshold calculations.
  184. INCLUDE_SPECIFIED_CREDITS = 3;
  185. }
  186. // Optional. A set of projects of the form `projects/{project}`,
  187. // specifying that usage from only this set of projects should be
  188. // included in the budget. If omitted, the report will include all usage for
  189. // the billing account, regardless of which project the usage occurred on.
  190. // Only zero or one project can be specified currently.
  191. repeated string projects = 1 [(google.api.field_behavior) = OPTIONAL];
  192. // Optional. If [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] is INCLUDE_SPECIFIED_CREDITS, this is
  193. // a list of credit types to be subtracted from gross cost to determine the
  194. // spend for threshold calculations. See
  195. // [a list of acceptable credit type
  196. // values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type).
  197. //
  198. // If [Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment] is **not** INCLUDE_SPECIFIED_CREDITS,
  199. // this field must be empty.
  200. repeated string credit_types = 7 [(google.api.field_behavior) = OPTIONAL];
  201. // Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`.
  202. CreditTypesTreatment credit_types_treatment = 4 [(google.api.field_behavior) = OPTIONAL];
  203. // Optional. A set of services of the form `services/{service_id}`,
  204. // specifying that usage from only this set of services should be
  205. // included in the budget. If omitted, the report will include usage for
  206. // all the services.
  207. // The service names are available through the Catalog API:
  208. // https://cloud.google.com/billing/v1/how-tos/catalog-api.
  209. repeated string services = 3 [(google.api.field_behavior) = OPTIONAL];
  210. // Optional. A set of subaccounts of the form `billingAccounts/{account_id}`, specifying
  211. // that usage from only this set of subaccounts should be included in the
  212. // budget. If a subaccount is set to the name of the parent account,
  213. // usage from the parent account will be included. If omitted, the
  214. // report will include usage from the parent account and all
  215. // subaccounts, if they exist.
  216. repeated string subaccounts = 5 [(google.api.field_behavior) = OPTIONAL];
  217. // Optional. A single label and value pair specifying that usage from only this set of
  218. // labeled resources should be included in the budget. If omitted, the
  219. // report will include all labeled and unlabeled usage.
  220. //
  221. // An object containing a single `"key": value` pair. Example: `{ "name":
  222. // "wrench" }`.
  223. //
  224. // _Currently, multiple entries or multiple values per entry are not
  225. // allowed._
  226. map<string, google.protobuf.ListValue> labels = 6 [(google.api.field_behavior) = OPTIONAL];
  227. // Multiple options to choose the budget's time period, specifying that only
  228. // usage that occurs during this time period should be included in the budget.
  229. // If not set, the <code>usage_period</code> defaults to CalendarPeriod.MONTH.
  230. oneof usage_period {
  231. // Optional. Specifies to track usage for recurring calendar period.
  232. // For example, assume that CalendarPeriod.QUARTER is set. The budget will
  233. // track usage from April 1 to June 30, when the current calendar month is
  234. // April, May, June. After that, it will track usage from July 1 to
  235. // September 30 when the current calendar month is July, August, September,
  236. // so on.
  237. CalendarPeriod calendar_period = 8 [(google.api.field_behavior) = OPTIONAL];
  238. // Optional. Specifies to track usage from any start date (required) to any end date
  239. // (optional). This time period is static, it does not recur.
  240. CustomPeriod custom_period = 9 [(google.api.field_behavior) = OPTIONAL];
  241. }
  242. }
  243. // All date times begin at 12 AM US and Canadian Pacific Time (UTC-8).
  244. message CustomPeriod {
  245. // Required. The start date must be after January 1, 2017.
  246. google.type.Date start_date = 1 [(google.api.field_behavior) = REQUIRED];
  247. // Optional. The end date of the time period. Budgets with elapsed end date won't be
  248. // processed. If unset, specifies to track all usage
  249. // incurred since the start_date.
  250. google.type.Date end_date = 2 [(google.api.field_behavior) = OPTIONAL];
  251. }
  252. // A `CalendarPeriod` represents the abstract concept of a time period that
  253. // has a canonical start. Grammatically, "the start of the current
  254. // `CalendarPeriod`". All calendar times begin at 12 AM US and Canadian
  255. // Pacific Time (UTC-8).
  256. enum CalendarPeriod {
  257. // Calendar period is unset. This is the default if the budget is for a
  258. // custom time period (CustomPeriod).
  259. CALENDAR_PERIOD_UNSPECIFIED = 0;
  260. // A month. Month starts on the first day of each month, such as January 1,
  261. // February 1, March 1, and so on.
  262. MONTH = 1;
  263. // A quarter. Quarters start on dates January 1, April 1, July 1, and October
  264. // 1 of each year.
  265. QUARTER = 2;
  266. // A year. Year starts on January 1.
  267. YEAR = 3;
  268. }