budget_model.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. // Copyright 2021 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.v1;
  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/v1;budgets";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "BudgetModelProto";
  24. option java_package = "com.google.cloud.billing.budgets.v1";
  25. // A budget is a plan that describes what you expect to spend on Cloud
  26. // projects, plus the rules to execute as spend is tracked against that plan,
  27. // (for example, send an alert when 90% of the target spend is met).
  28. // The budget time period is configurable, with options such as month (default),
  29. // quarter, year, or custom time period.
  30. message Budget {
  31. option (google.api.resource) = {
  32. type: "billingbudgets.googleapis.com/Budget"
  33. pattern: "billingAccounts/{billing_account}/budgets/{budget}"
  34. };
  35. // Output only. Resource name of the budget.
  36. // The resource name implies the scope of a budget. Values are of the form
  37. // `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
  38. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  39. // User data for display name in UI. The name must be less than or equal to 60
  40. // characters.
  41. string display_name = 2;
  42. // Optional. Filters that define which resources are used to compute the
  43. // actual spend against the budget amount, such as projects, services, and the
  44. // budget's time period, as well as other filters.
  45. Filter budget_filter = 3 [(google.api.field_behavior) = OPTIONAL];
  46. // Required. Budgeted amount.
  47. BudgetAmount amount = 4 [(google.api.field_behavior) = REQUIRED];
  48. // Optional. Rules that trigger alerts (notifications of thresholds
  49. // being crossed) when spend exceeds the specified percentages of the budget.
  50. repeated ThresholdRule threshold_rules = 5
  51. [(google.api.field_behavior) = OPTIONAL];
  52. // Optional. Rules to apply to notifications sent based on budget spend and
  53. // thresholds.
  54. NotificationsRule notifications_rule = 6
  55. [(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.v1.Filter.calendar_period].
  74. // It cannot be set in combination with
  75. // [Filter.custom_period][google.cloud.billing.budgets.v1.Filter.custom_period].
  76. LastPeriodAmount last_period_amount = 2;
  77. }
  78. }
  79. // Describes a budget amount targeted to the last
  80. // [Filter.calendar_period][google.cloud.billing.budgets.v1.Filter.calendar_period]
  81. // spend. At this time, the amount is automatically 100% of the last calendar
  82. // period's spend; that is, there are no other options yet.
  83. // Future configuration options will be described here (for example, configuring
  84. // a percentage of last period's spend).
  85. // LastPeriodAmount cannot be set for a budget configured with
  86. // a
  87. // [Filter.custom_period][google.cloud.billing.budgets.v1.Filter.custom_period].
  88. message LastPeriodAmount {}
  89. // ThresholdRule contains a definition of a threshold which triggers
  90. // an alert (a notification of a threshold being crossed) to be sent when
  91. // spend goes above the specified amount.
  92. // Alerts are automatically e-mailed to users with the Billing Account
  93. // Administrator role or the Billing Account User role.
  94. // The thresholds here have no effect on notifications sent to anything
  95. // configured under `Budget.all_updates_rule`.
  96. message ThresholdRule {
  97. // The type of basis used to determine if spend has passed the threshold.
  98. enum Basis {
  99. // Unspecified threshold basis.
  100. BASIS_UNSPECIFIED = 0;
  101. // Use current spend as the basis for comparison against the threshold.
  102. CURRENT_SPEND = 1;
  103. // Use forecasted spend for the period as the basis for comparison against
  104. // the threshold.
  105. // FORECASTED_SPEND can only be set when the budget's time period is a
  106. // [Filter.calendar_period][google.cloud.billing.budgets.v1.Filter.calendar_period].
  107. // It cannot be set in combination with
  108. // [Filter.custom_period][google.cloud.billing.budgets.v1.Filter.custom_period].
  109. FORECASTED_SPEND = 2;
  110. }
  111. // Required. Send an alert when this threshold is exceeded.
  112. // This is a 1.0-based percentage, so 0.5 = 50%.
  113. // Validation: non-negative number.
  114. double threshold_percent = 1 [(google.api.field_behavior) = REQUIRED];
  115. // Optional. The type of basis used to determine if spend has passed the
  116. // threshold. Behavior defaults to CURRENT_SPEND if not set.
  117. Basis spend_basis = 2 [(google.api.field_behavior) = OPTIONAL];
  118. }
  119. // NotificationsRule defines notifications that are sent based on budget spend
  120. // and thresholds.
  121. message NotificationsRule {
  122. // Optional. The name of the Pub/Sub topic where budget related messages will
  123. // be published, in the form `projects/{project_id}/topics/{topic_id}`.
  124. // Updates are sent at regular intervals to the topic. The topic needs to be
  125. // created before the budget is created; see
  126. // https://cloud.google.com/billing/docs/how-to/budgets#manage-notifications
  127. // for more details.
  128. // Caller is expected to have
  129. // `pubsub.topics.setIamPolicy` permission on the topic when it's set for a
  130. // budget, otherwise, the API call will fail with PERMISSION_DENIED. See
  131. // https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications
  132. // for more details on Pub/Sub roles and permissions.
  133. string pubsub_topic = 1 [(google.api.field_behavior) = OPTIONAL];
  134. // Optional. Required when
  135. // [NotificationsRule.pubsub_topic][google.cloud.billing.budgets.v1.NotificationsRule.pubsub_topic]
  136. // is set. The schema version of the notification sent to
  137. // [NotificationsRule.pubsub_topic][google.cloud.billing.budgets.v1.NotificationsRule.pubsub_topic].
  138. // Only "1.0" is accepted. It represents the JSON schema as defined in
  139. // https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format.
  140. string schema_version = 2 [(google.api.field_behavior) = OPTIONAL];
  141. // Optional. Targets to send notifications to when a threshold is exceeded.
  142. // This is in addition to default recipients who have billing account IAM
  143. // roles. The value is the full REST resource name of a monitoring
  144. // notification channel with the form
  145. // `projects/{project_id}/notificationChannels/{channel_id}`. A maximum of 5
  146. // channels are allowed. See
  147. // https://cloud.google.com/billing/docs/how-to/budgets-notification-recipients
  148. // for more details.
  149. repeated string monitoring_notification_channels = 3
  150. [(google.api.field_behavior) = OPTIONAL];
  151. // Optional. When set to true, disables default notifications sent when a
  152. // threshold is exceeded. Default notifications are sent to those with Billing
  153. // Account Administrator and Billing Account User IAM roles for the target
  154. // account.
  155. bool disable_default_iam_recipients = 4
  156. [(google.api.field_behavior) = OPTIONAL];
  157. }
  158. // A filter for a budget, limiting the scope of the cost to calculate.
  159. message Filter {
  160. // Specifies how credits are applied when determining the spend for
  161. // threshold calculations. Budgets track the total cost minus any applicable
  162. // selected credits.
  163. // [See the documentation for a list of credit
  164. // types](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type).
  165. enum CreditTypesTreatment {
  166. CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0;
  167. // All types of credit are subtracted from the gross cost to determine the
  168. // spend for threshold calculations.
  169. INCLUDE_ALL_CREDITS = 1;
  170. // All types of credit are added to the net cost to determine the spend for
  171. // threshold calculations.
  172. EXCLUDE_ALL_CREDITS = 2;
  173. // [Credit
  174. // types](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type)
  175. // specified in the credit_types field are subtracted from the
  176. // gross cost to determine the spend for threshold calculations.
  177. INCLUDE_SPECIFIED_CREDITS = 3;
  178. }
  179. // Optional. A set of projects of the form `projects/{project}`,
  180. // specifying that usage from only this set of projects should be
  181. // included in the budget. If omitted, the report will include all usage for
  182. // the billing account, regardless of which project the usage occurred on.
  183. // Only zero or one project can be specified currently.
  184. repeated string projects = 1 [(google.api.field_behavior) = OPTIONAL];
  185. // Optional. If
  186. // [Filter.credit_types_treatment][google.cloud.billing.budgets.v1.Filter.credit_types_treatment]
  187. // is INCLUDE_SPECIFIED_CREDITS, this is a list of credit types to be
  188. // subtracted from gross cost to determine the spend for threshold
  189. // calculations. See [a list of acceptable credit type
  190. // values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type).
  191. //
  192. // If
  193. // [Filter.credit_types_treatment][google.cloud.billing.budgets.v1.Filter.credit_types_treatment]
  194. // is **not** INCLUDE_SPECIFIED_CREDITS, this field must be empty.
  195. repeated string credit_types = 7 [(google.api.field_behavior) = OPTIONAL];
  196. // Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`.
  197. CreditTypesTreatment credit_types_treatment = 4
  198. [(google.api.field_behavior) = OPTIONAL];
  199. // Optional. A set of services of the form `services/{service_id}`,
  200. // specifying that usage from only this set of services should be
  201. // included in the budget. If omitted, the report will include usage for
  202. // all the services.
  203. // The service names are available through the Catalog API:
  204. // https://cloud.google.com/billing/v1/how-tos/catalog-api.
  205. repeated string services = 3 [(google.api.field_behavior) = OPTIONAL];
  206. // Optional. A set of subaccounts of the form `billingAccounts/{account_id}`,
  207. // specifying that usage from only this set of subaccounts should be included
  208. // in the budget. If a subaccount is set to the name of the parent account,
  209. // usage from the parent account will be included. If the field is omitted,
  210. // the report will include usage from the parent account and all subaccounts,
  211. // if they exist.
  212. repeated string subaccounts = 5 [(google.api.field_behavior) = OPTIONAL];
  213. // Optional. A single label and value pair specifying that usage from only
  214. // this set of labeled resources should be included in the budget. Currently,
  215. // multiple entries or multiple values per entry are not allowed. If omitted,
  216. // the report will include all labeled and unlabeled usage.
  217. map<string, google.protobuf.ListValue> labels = 6
  218. [(google.api.field_behavior) = OPTIONAL];
  219. // Multiple options to choose the budget's time period, specifying that only
  220. // usage that occurs during this time period should be included in the budget.
  221. // If not set, the `usage_period` defaults to CalendarPeriod.MONTH.
  222. oneof usage_period {
  223. // Optional. Specifies to track usage for recurring calendar period.
  224. // For example, assume that CalendarPeriod.QUARTER is set. The budget will
  225. // track usage from April 1 to June 30, when the current calendar month is
  226. // April, May, June. After that, it will track usage from July 1 to
  227. // September 30 when the current calendar month is July, August, September,
  228. // so on.
  229. CalendarPeriod calendar_period = 8 [(google.api.field_behavior) = OPTIONAL];
  230. // Optional. Specifies to track usage from any start date (required) to any
  231. // end date (optional). This time period is static, it does not recur.
  232. CustomPeriod custom_period = 9 [(google.api.field_behavior) = OPTIONAL];
  233. }
  234. }
  235. // All date times begin at 12 AM US and Canadian Pacific Time (UTC-8).
  236. message CustomPeriod {
  237. // Required. The start date must be after January 1, 2017.
  238. google.type.Date start_date = 1 [(google.api.field_behavior) = REQUIRED];
  239. // Optional. The end date of the time period. Budgets with elapsed end date
  240. // won't be processed. If unset, specifies to track all usage incurred since
  241. // the start_date.
  242. google.type.Date end_date = 2 [(google.api.field_behavior) = OPTIONAL];
  243. }
  244. // A `CalendarPeriod` represents the abstract concept of a time period that
  245. // has a canonical start. Grammatically, "the start of the current
  246. // `CalendarPeriod`". All calendar times begin at 12 AM US and Canadian
  247. // Pacific Time (UTC-8).
  248. enum CalendarPeriod {
  249. CALENDAR_PERIOD_UNSPECIFIED = 0;
  250. // A month. Month starts on the first day of each month, such as January 1,
  251. // February 1, March 1, and so on.
  252. MONTH = 1;
  253. // A quarter. Quarters start on dates January 1, April 1, July 1, and October
  254. // 1 of each year.
  255. QUARTER = 2;
  256. // A year. Year starts on January 1.
  257. YEAR = 3;
  258. }