Skip to content

Commit dd6ba75

Browse files
Google APIscopybara-github
authored andcommitted
feat: Added support for configurable budget time period.
fix: Updated some documentation links. PiperOrigin-RevId: 368871890
1 parent 24f0828 commit dd6ba75

2 files changed

Lines changed: 96 additions & 28 deletions

File tree

google/cloud/billing/budgets/v1/BUILD.bazel

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file was automatically generated by BuildFileGenerator
2-
# https://github.com/googleapis/gapic-generator/tree/master/rules_gapic/bazel
2+
# https://github.com/googleapis/rules_gapic/tree/master/bazel
33

44
# Most of the manual changes to this file will be overwritten.
55
# It's **only** allowed to change the following rule attribute values:
@@ -30,17 +30,17 @@ load(
3030
"java_proto_library",
3131
"nodejs_gapic_assembly_pkg",
3232
"nodejs_gapic_library",
33-
php_gapic_assembly_pkg = "php_gapic_assembly_pkg2",
34-
php_gapic_library = "php_gapic_library2",
35-
php_grpc_library = "php_grpc_library2",
36-
php_proto_library = "php_proto_library2",
3733
"proto_library_with_info",
3834
"py_gapic_assembly_pkg",
3935
"py_gapic_library",
36+
"ruby_cloud_gapic_library",
4037
"ruby_gapic_assembly_pkg",
41-
"ruby_gapic_library",
4238
"ruby_grpc_library",
4339
"ruby_proto_library",
40+
php_gapic_assembly_pkg = "php_gapic_assembly_pkg2",
41+
php_gapic_library = "php_gapic_library2",
42+
php_grpc_library = "php_grpc_library2",
43+
php_proto_library = "php_proto_library2",
4444
)
4545

4646
# This is an API workspace, having public visibility by default makes perfect sense.
@@ -57,6 +57,7 @@ proto_library(
5757
"//google/api:client_proto",
5858
"//google/api:field_behavior_proto",
5959
"//google/api:resource_proto",
60+
"//google/type:date_proto",
6061
"//google/type:money_proto",
6162
"@com_google_protobuf//:empty_proto",
6263
"@com_google_protobuf//:field_mask_proto",
@@ -98,6 +99,7 @@ java_gapic_library(
9899
java_gapic_test(
99100
name = "budgets_java_gapic_test_suite",
100101
test_classes = [
102+
"com.google.cloud.billing.budgets.v1.BudgetServiceClientTest",
101103
],
102104
runtime_deps = [":budgets_java_gapic_test"],
103105
)
@@ -120,6 +122,7 @@ go_proto_library(
120122
protos = [":budgets_proto"],
121123
deps = [
122124
"//google/api:annotations_go_proto",
125+
"//google/type:date_go_proto",
123126
"//google/type:money_go_proto",
124127
],
125128
)
@@ -129,6 +132,7 @@ go_gapic_library(
129132
srcs = [":budgets_proto_with_info"],
130133
grpc_service_config = "billingbudgets_grpc_service_config.json",
131134
importpath = "cloud.google.com/go/billing/budgets/apiv1;budgets",
135+
metadata = True,
132136
service_yaml = "billingbudgets.yaml",
133137
deps = [
134138
":budgets_go_proto",
@@ -147,6 +151,7 @@ go_gapic_assembly_pkg(
147151
name = "gapi-cloud-billing-budgets-v1-go",
148152
deps = [
149153
":budgets_go_gapic",
154+
":budgets_go_gapic_srcjar-metadata.srcjar",
150155
":budgets_go_gapic_srcjar-test.srcjar",
151156
":budgets_go_proto",
152157
],
@@ -181,6 +186,7 @@ php_gapic_library(
181186
name = "budgets_php_gapic",
182187
srcs = [":budgets_proto_with_info"],
183188
grpc_service_config = "billingbudgets_grpc_service_config.json",
189+
service_yaml = "billingbudgets.yaml",
184190
deps = [
185191
":budgets_php_grpc",
186192
":budgets_php_proto",
@@ -227,13 +233,11 @@ ruby_grpc_library(
227233
deps = [":budgets_ruby_proto"],
228234
)
229235

230-
ruby_gapic_library(
236+
ruby_cloud_gapic_library(
231237
name = "budgets_ruby_gapic",
232-
src = ":budgets_proto_with_info",
233-
gapic_yaml = "billingbudget_gapic.yaml",
238+
srcs = [":budgets_proto_with_info"],
239+
extra_protoc_parameters = ["ruby-cloud-gem-name=google-cloud-billing-budgets-v1"],
234240
grpc_service_config = "billingbudgets_grpc_service_config.json",
235-
package = "google.cloud.billing.budgets.v1",
236-
service_yaml = "billingbudgets.yaml",
237241
deps = [
238242
":budgets_ruby_grpc",
239243
":budgets_ruby_proto",

google/cloud/billing/budgets/v1/budget_model.proto

Lines changed: 81 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package google.cloud.billing.budgets.v1;
1919
import "google/api/field_behavior.proto";
2020
import "google/api/resource.proto";
2121
import "google/protobuf/struct.proto";
22+
import "google/type/date.proto";
2223
import "google/type/money.proto";
2324

2425
option go_package = "google.golang.org/genproto/googleapis/cloud/billing/budgets/v1;budgets";
@@ -29,8 +30,8 @@ option java_package = "com.google.cloud.billing.budgets.v1";
2930
// A budget is a plan that describes what you expect to spend on Cloud
3031
// projects, plus the rules to execute as spend is tracked against that plan,
3132
// (for example, send an alert when 90% of the target spend is met).
32-
// Currently all plans are monthly budgets so the usage period(s) tracked are
33-
// implied (calendar months of usage back-to-back).
33+
// The budget time period is configurable, with options such as month (default),
34+
// quarter, year, or custom time period.
3435
message Budget {
3536
option (google.api.resource) = {
3637
type: "billingbudgets.googleapis.com/Budget"
@@ -46,8 +47,9 @@ message Budget {
4647
// characters.
4748
string display_name = 2;
4849

49-
// Optional. Filters that define which resources are used to compute
50-
// the actual spend against the budget.
50+
// Optional. Filters that define which resources are used to compute the
51+
// actual spend against the budget amount, such as projects, services, and the
52+
// budget's time period, as well as other filters.
5153
Filter budget_filter = 3 [(google.api.field_behavior) = OPTIONAL];
5254

5355
// Required. Budgeted amount.
@@ -81,15 +83,23 @@ message BudgetAmount {
8183
google.type.Money specified_amount = 1;
8284

8385
// Use the last period's actual spend as the budget for the present period.
86+
// LastPeriodAmount can only be set when the budget's time period is a
87+
// [Filter.calendar_period][google.cloud.billing.budgets.v1.Filter.calendar_period].
88+
// It cannot be set in combination with
89+
// [Filter.custom_period][google.cloud.billing.budgets.v1.Filter.custom_period].
8490
LastPeriodAmount last_period_amount = 2;
8591
}
8692
}
8793

88-
// Describes a budget amount targeted to last period's spend.
89-
// At this time, the amount is automatically 100% of last period's spend;
90-
// that is, there are no other options yet.
91-
// Future configuration will be described here (for example, configuring a
92-
// percentage of last period's spend).
94+
// Describes a budget amount targeted to the last
95+
// [Filter.calendar_period][google.cloud.billing.budgets.v1.Filter.calendar_period]
96+
// spend. At this time, the amount is automatically 100% of the last calendar
97+
// period's spend; that is, there are no other options yet.
98+
// Future configuration options will be described here (for example, configuring
99+
// a percentage of last period's spend).
100+
// LastPeriodAmount cannot be set for a budget configured with
101+
// a
102+
// [Filter.custom_period][google.cloud.billing.budgets.v1.Filter.custom_period].
93103
message LastPeriodAmount {}
94104

95105
// ThresholdRule contains a definition of a threshold which triggers
@@ -110,6 +120,10 @@ message ThresholdRule {
110120

111121
// Use forecasted spend for the period as the basis for comparison against
112122
// the threshold.
123+
// FORECASTED_SPEND can only be set when the budget's time period is a
124+
// [Filter.calendar_period][google.cloud.billing.budgets.v1.Filter.calendar_period].
125+
// It cannot be set in combination with
126+
// [Filter.custom_period][google.cloud.billing.budgets.v1.Filter.custom_period].
113127
FORECASTED_SPEND = 2;
114128
}
115129

@@ -168,10 +182,12 @@ message NotificationsRule {
168182

169183
// A filter for a budget, limiting the scope of the cost to calculate.
170184
message Filter {
171-
// Specifies how credits should be treated when determining spend for
172-
// threshold calculations.
185+
// Specifies how credits are applied when determining the spend for
186+
// threshold calculations. Budgets track the total cost minus any applicable
187+
// selected credits.
188+
// [See the documentation for a list of credit
189+
// types](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type).
173190
enum CreditTypesTreatment {
174-
// This is an invalid value.
175191
CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0;
176192

177193
// All types of credit are subtracted from the gross cost to determine the
@@ -182,7 +198,9 @@ message Filter {
182198
// threshold calculations.
183199
EXCLUDE_ALL_CREDITS = 2;
184200

185-
// Credit types specified in the credit_types field are subtracted from the
201+
// [Credit
202+
// types](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type)
203+
// specified in the credit_types field are subtracted from the
186204
// gross cost to determine the spend for threshold calculations.
187205
INCLUDE_SPECIFIED_CREDITS = 3;
188206
}
@@ -198,13 +216,12 @@ message Filter {
198216
// [Filter.credit_types_treatment][google.cloud.billing.budgets.v1.Filter.credit_types_treatment]
199217
// is INCLUDE_SPECIFIED_CREDITS, this is a list of credit types to be
200218
// subtracted from gross cost to determine the spend for threshold
201-
// calculations.
219+
// calculations. See [a list of acceptable credit type
220+
// values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type).
202221
//
203222
// If
204223
// [Filter.credit_types_treatment][google.cloud.billing.budgets.v1.Filter.credit_types_treatment]
205-
// is **not** INCLUDE_SPECIFIED_CREDITS, this field must be empty. See [a list
206-
// of acceptable credit type
207-
// values](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type).
224+
// is **not** INCLUDE_SPECIFIED_CREDITS, this field must be empty.
208225
repeated string credit_types = 7 [(google.api.field_behavior) = OPTIONAL];
209226

210227
// Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`.
@@ -233,4 +250,51 @@ message Filter {
233250
// the report will include all labeled and unlabeled usage.
234251
map<string, google.protobuf.ListValue> labels = 6
235252
[(google.api.field_behavior) = OPTIONAL];
253+
254+
// Multiple options to choose the budget's time period, specifying that only
255+
// usage that occurs during this time period should be included in the budget.
256+
// If not set, the `usage_period` defaults to CalendarPeriod.MONTH.
257+
oneof usage_period {
258+
// Optional. Specifies to track usage for recurring calendar period.
259+
// For example, assume that CalendarPeriod.QUARTER is set. The budget will
260+
// track usage from April 1 to June 30, when the current calendar month is
261+
// April, May, June. After that, it will track usage from July 1 to
262+
// September 30 when the current calendar month is July, August, September,
263+
// so on.
264+
CalendarPeriod calendar_period = 8 [(google.api.field_behavior) = OPTIONAL];
265+
266+
// Optional. Specifies to track usage from any start date (required) to any
267+
// end date (optional). This time period is static, it does not recur.
268+
CustomPeriod custom_period = 9 [(google.api.field_behavior) = OPTIONAL];
269+
}
270+
}
271+
272+
// All date times begin at 12 AM US and Canadian Pacific Time (UTC-8).
273+
message CustomPeriod {
274+
// Required. The start date must be after January 1, 2017.
275+
google.type.Date start_date = 1 [(google.api.field_behavior) = REQUIRED];
276+
277+
// Optional. The end date of the time period. Budgets with elapsed end date
278+
// won't be processed. If unset, specifies to track all usage incurred since
279+
// the start_date.
280+
google.type.Date end_date = 2 [(google.api.field_behavior) = OPTIONAL];
281+
}
282+
283+
// A `CalendarPeriod` represents the abstract concept of a time period that
284+
// has a canonical start. Grammatically, "the start of the current
285+
// `CalendarPeriod`". All calendar times begin at 12 AM US and Canadian
286+
// Pacific Time (UTC-8).
287+
enum CalendarPeriod {
288+
CALENDAR_PERIOD_UNSPECIFIED = 0;
289+
290+
// A month. Month starts on the first day of each month, such as January 1,
291+
// February 1, March 1, and so on.
292+
MONTH = 1;
293+
294+
// A quarter. Quarters start on dates January 1, April 1, July 1, and October
295+
// 1 of each year.
296+
QUARTER = 2;
297+
298+
// A year. Year starts on January 1.
299+
YEAR = 3;
236300
}

0 commit comments

Comments
 (0)