google-cloud-billing-budgets-v1beta1 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +203 -0
- data/README.md +75 -0
- data/lib/google-cloud-billing-budgets-v1beta1.rb +21 -0
- data/lib/google/cloud/billing/budgets/v1beta1.rb +37 -0
- data/lib/google/cloud/billing/budgets/v1beta1/budget_model_pb.rb +75 -0
- data/lib/google/cloud/billing/budgets/v1beta1/budget_service.rb +52 -0
- data/lib/google/cloud/billing/budgets/v1beta1/budget_service/client.rb +736 -0
- data/lib/google/cloud/billing/budgets/v1beta1/budget_service/credentials.rb +53 -0
- data/lib/google/cloud/billing/budgets/v1beta1/budget_service/paths.rb +66 -0
- data/lib/google/cloud/billing/budgets/v1beta1/budget_service_pb.rb +56 -0
- data/lib/google/cloud/billing/budgets/v1beta1/budget_service_services_pb.rb +72 -0
- data/lib/google/cloud/billing/budgets/v1beta1/version.rb +30 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/field_behavior.rb +59 -0
- data/proto_docs/google/api/resource.rb +247 -0
- data/proto_docs/google/cloud/billing/budgets/v1beta1/budget_model.rb +220 -0
- data/proto_docs/google/cloud/billing/budgets/v1beta1/budget_service.rb +111 -0
- data/proto_docs/google/protobuf/empty.rb +36 -0
- data/proto_docs/google/protobuf/field_mask.rb +229 -0
- data/proto_docs/google/protobuf/struct.rb +96 -0
- data/proto_docs/google/type/money.rb +43 -0
- metadata +206 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Cloud
|
22
|
+
module Billing
|
23
|
+
module Budgets
|
24
|
+
module V1beta1
|
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
|
+
# Currently all plans are monthly budgets so the usage period(s) tracked are
|
29
|
+
# implied (calendar months of usage back-to-back).
|
30
|
+
# @!attribute [r] name
|
31
|
+
# @return [::String]
|
32
|
+
# Output only. Resource name of the budget.
|
33
|
+
# The resource name implies the scope of a budget. Values are of the form
|
34
|
+
# `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
|
35
|
+
# @!attribute [rw] display_name
|
36
|
+
# @return [::String]
|
37
|
+
# User data for display name in UI.
|
38
|
+
# Validation: <= 60 chars.
|
39
|
+
# @!attribute [rw] budget_filter
|
40
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::Filter]
|
41
|
+
# Optional. Filters that define which resources are used to compute
|
42
|
+
# the actual spend against the budget.
|
43
|
+
# @!attribute [rw] amount
|
44
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::BudgetAmount]
|
45
|
+
# Required. Budgeted amount.
|
46
|
+
# @!attribute [rw] threshold_rules
|
47
|
+
# @return [::Array<::Google::Cloud::Billing::Budgets::V1beta1::ThresholdRule>]
|
48
|
+
# Optional. Rules that trigger alerts (notifications of thresholds
|
49
|
+
# being crossed) when spend exceeds the specified percentages of the budget.
|
50
|
+
# @!attribute [rw] all_updates_rule
|
51
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::AllUpdatesRule]
|
52
|
+
# Optional. Rules to apply to notifications sent based on budget spend and
|
53
|
+
# thresholds.
|
54
|
+
# @!attribute [rw] etag
|
55
|
+
# @return [::String]
|
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
|
+
class Budget
|
60
|
+
include ::Google::Protobuf::MessageExts
|
61
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
62
|
+
end
|
63
|
+
|
64
|
+
# The budgeted amount for each usage period.
|
65
|
+
# @!attribute [rw] specified_amount
|
66
|
+
# @return [::Google::Type::Money]
|
67
|
+
# A specified amount to use as the budget.
|
68
|
+
# `currency_code` is optional. If specified, it must match the
|
69
|
+
# currency of the billing account. The `currency_code` is provided on
|
70
|
+
# output.
|
71
|
+
# @!attribute [rw] last_period_amount
|
72
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::LastPeriodAmount]
|
73
|
+
# Use the last period's actual spend as the budget for the present period.
|
74
|
+
class BudgetAmount
|
75
|
+
include ::Google::Protobuf::MessageExts
|
76
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
77
|
+
end
|
78
|
+
|
79
|
+
# Describes a budget amount targeted to last period's spend.
|
80
|
+
# At this time, the amount is automatically 100% of last period's spend;
|
81
|
+
# that is, there are no other options yet.
|
82
|
+
# Future configuration will be described here (for example, configuring a
|
83
|
+
# percentage of last period's spend).
|
84
|
+
class LastPeriodAmount
|
85
|
+
include ::Google::Protobuf::MessageExts
|
86
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
87
|
+
end
|
88
|
+
|
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
|
+
# @!attribute [rw] threshold_percent
|
97
|
+
# @return [::Float]
|
98
|
+
# Required. Send an alert when this threshold is exceeded.
|
99
|
+
# This is a 1.0-based percentage, so 0.5 = 50%.
|
100
|
+
# Validation: non-negative number.
|
101
|
+
# @!attribute [rw] spend_basis
|
102
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::ThresholdRule::Basis]
|
103
|
+
# Optional. The type of basis used to determine if spend has passed the
|
104
|
+
# threshold. Behavior defaults to CURRENT_SPEND if not set.
|
105
|
+
class ThresholdRule
|
106
|
+
include ::Google::Protobuf::MessageExts
|
107
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
108
|
+
|
109
|
+
# The type of basis used to determine if spend has passed the threshold.
|
110
|
+
module Basis
|
111
|
+
# Unspecified threshold basis.
|
112
|
+
BASIS_UNSPECIFIED = 0
|
113
|
+
|
114
|
+
# Use current spend as the basis for comparison against the threshold.
|
115
|
+
CURRENT_SPEND = 1
|
116
|
+
|
117
|
+
# Use forecasted spend for the period as the basis for comparison against
|
118
|
+
# the threshold.
|
119
|
+
FORECASTED_SPEND = 2
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# AllUpdatesRule defines notifications that are sent based on budget spend
|
124
|
+
# and thresholds.
|
125
|
+
# @!attribute [rw] pubsub_topic
|
126
|
+
# @return [::String]
|
127
|
+
# Required. The name of the Cloud Pub/Sub topic where budget related messages
|
128
|
+
# will be published, in the form `projects/{project_id}/topics/{topic_id}`.
|
129
|
+
# Updates are sent at regular intervals to the topic. The topic needs to be
|
130
|
+
# created before the budget is created; see
|
131
|
+
# https://cloud.google.com/billing/docs/how-to/budgets#manage-notifications
|
132
|
+
# for more details.
|
133
|
+
# Caller is expected to have
|
134
|
+
# `pubsub.topics.setIamPolicy` permission on the topic when it's set for a
|
135
|
+
# budget, otherwise, the API call will fail with PERMISSION_DENIED. See
|
136
|
+
# https://cloud.google.com/pubsub/docs/access-control for more details on
|
137
|
+
# Pub/Sub roles and permissions.
|
138
|
+
# @!attribute [rw] schema_version
|
139
|
+
# @return [::String]
|
140
|
+
# Required. The schema version of the notification sent to `pubsub_topic`.
|
141
|
+
# Only "1.0" is accepted. It represents the JSON schema as defined in
|
142
|
+
# https://cloud.google.com/billing/docs/how-to/budgets#notification_format
|
143
|
+
# @!attribute [rw] monitoring_notification_channels
|
144
|
+
# @return [::Array<::String>]
|
145
|
+
# Optional. Targets to send notifications to when a threshold is exceeded.
|
146
|
+
# This is in addition to default recipients who have billing account roles.
|
147
|
+
# The value is the full REST resource name of a monitoring notification
|
148
|
+
# channel with the form
|
149
|
+
# `projects/{project_id}/notificationChannels/{channel_id}`. A maximum of 5
|
150
|
+
# channels are allowed.
|
151
|
+
class AllUpdatesRule
|
152
|
+
include ::Google::Protobuf::MessageExts
|
153
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
154
|
+
end
|
155
|
+
|
156
|
+
# A filter for a budget, limiting the scope of the cost to calculate.
|
157
|
+
# @!attribute [rw] projects
|
158
|
+
# @return [::Array<::String>]
|
159
|
+
# Optional. A set of projects of the form `projects/{project}`,
|
160
|
+
# specifying that usage from only this set of projects should be
|
161
|
+
# included in the budget. If omitted, the report will include all usage for
|
162
|
+
# the billing account, regardless of which project the usage occurred on.
|
163
|
+
# Only zero or one project can be specified currently.
|
164
|
+
# @!attribute [rw] credit_types_treatment
|
165
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::Filter::CreditTypesTreatment]
|
166
|
+
# Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`.
|
167
|
+
# @!attribute [rw] services
|
168
|
+
# @return [::Array<::String>]
|
169
|
+
# Optional. A set of services of the form `services/{service_id}`,
|
170
|
+
# specifying that usage from only this set of services should be
|
171
|
+
# included in the budget. If omitted, the report will include usage for
|
172
|
+
# all the services.
|
173
|
+
# The service names are available through the Catalog API:
|
174
|
+
# https://cloud.google.com/billing/v1/how-tos/catalog-api.
|
175
|
+
# @!attribute [rw] subaccounts
|
176
|
+
# @return [::Array<::String>]
|
177
|
+
# Optional. A set of subaccounts of the form `billingAccounts/{account_id}`,
|
178
|
+
# specifying that usage from only this set of subaccounts should be included
|
179
|
+
# in the budget. If a subaccount is set to the name of the reseller account,
|
180
|
+
# usage from the reseller account will be included. If omitted, the report
|
181
|
+
# will include usage from the reseller account and all subaccounts, if they
|
182
|
+
# exist.
|
183
|
+
# @!attribute [rw] labels
|
184
|
+
# @return [::Google::Protobuf::Map{::String => ::Google::Protobuf::ListValue}]
|
185
|
+
# Optional. A single label and value pair specifying that usage from only
|
186
|
+
# this set of labeled resources should be included in the budget. Currently,
|
187
|
+
# multiple entries or multiple values per entry are not allowed. If omitted,
|
188
|
+
# the report will include all labeled and unlabeled usage.
|
189
|
+
class Filter
|
190
|
+
include ::Google::Protobuf::MessageExts
|
191
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
192
|
+
|
193
|
+
# @!attribute [rw] key
|
194
|
+
# @return [::String]
|
195
|
+
# @!attribute [rw] value
|
196
|
+
# @return [::Google::Protobuf::ListValue]
|
197
|
+
class LabelsEntry
|
198
|
+
include ::Google::Protobuf::MessageExts
|
199
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
200
|
+
end
|
201
|
+
|
202
|
+
# Specifies how credits should be treated when determining spend for
|
203
|
+
# threshold calculations.
|
204
|
+
module CreditTypesTreatment
|
205
|
+
CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0
|
206
|
+
|
207
|
+
# All types of credit are subtracted from the gross cost to determine the
|
208
|
+
# spend for threshold calculations.
|
209
|
+
INCLUDE_ALL_CREDITS = 1
|
210
|
+
|
211
|
+
# All types of credit are added to the net cost to determine the spend for
|
212
|
+
# threshold calculations.
|
213
|
+
EXCLUDE_ALL_CREDITS = 2
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Cloud
|
22
|
+
module Billing
|
23
|
+
module Budgets
|
24
|
+
module V1beta1
|
25
|
+
# Request for CreateBudget
|
26
|
+
# @!attribute [rw] parent
|
27
|
+
# @return [::String]
|
28
|
+
# Required. The name of the billing account to create the budget in. Values
|
29
|
+
# are of the form `billingAccounts/{billingAccountId}`.
|
30
|
+
# @!attribute [rw] budget
|
31
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
|
32
|
+
# Required. Budget to create.
|
33
|
+
class CreateBudgetRequest
|
34
|
+
include ::Google::Protobuf::MessageExts
|
35
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
36
|
+
end
|
37
|
+
|
38
|
+
# Request for UpdateBudget
|
39
|
+
# @!attribute [rw] budget
|
40
|
+
# @return [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
|
41
|
+
# Required. The updated budget object.
|
42
|
+
# The budget to update is specified by the budget name in the budget.
|
43
|
+
# @!attribute [rw] update_mask
|
44
|
+
# @return [::Google::Protobuf::FieldMask]
|
45
|
+
# Optional. Indicates which fields in the provided budget to update.
|
46
|
+
# Read-only fields (such as `name`) cannot be changed. If this is not
|
47
|
+
# provided, then only fields with non-default values from the request are
|
48
|
+
# updated. See
|
49
|
+
# https://developers.google.com/protocol-buffers/docs/proto3#default for more
|
50
|
+
# details about default values.
|
51
|
+
class UpdateBudgetRequest
|
52
|
+
include ::Google::Protobuf::MessageExts
|
53
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
54
|
+
end
|
55
|
+
|
56
|
+
# Request for GetBudget
|
57
|
+
# @!attribute [rw] name
|
58
|
+
# @return [::String]
|
59
|
+
# Required. Name of budget to get. Values are of the form
|
60
|
+
# `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
|
61
|
+
class GetBudgetRequest
|
62
|
+
include ::Google::Protobuf::MessageExts
|
63
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
64
|
+
end
|
65
|
+
|
66
|
+
# Request for ListBudgets
|
67
|
+
# @!attribute [rw] parent
|
68
|
+
# @return [::String]
|
69
|
+
# Required. Name of billing account to list budgets under. Values
|
70
|
+
# are of the form `billingAccounts/{billingAccountId}`.
|
71
|
+
# @!attribute [rw] page_size
|
72
|
+
# @return [::Integer]
|
73
|
+
# Optional. The maximum number of budgets to return per page.
|
74
|
+
# The default and maximum value are 100.
|
75
|
+
# @!attribute [rw] page_token
|
76
|
+
# @return [::String]
|
77
|
+
# Optional. The value returned by the last `ListBudgetsResponse` which
|
78
|
+
# indicates that this is a continuation of a prior `ListBudgets` call,
|
79
|
+
# and that the system should return the next page of data.
|
80
|
+
class ListBudgetsRequest
|
81
|
+
include ::Google::Protobuf::MessageExts
|
82
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
83
|
+
end
|
84
|
+
|
85
|
+
# Response for ListBudgets
|
86
|
+
# @!attribute [rw] budgets
|
87
|
+
# @return [::Array<::Google::Cloud::Billing::Budgets::V1beta1::Budget>]
|
88
|
+
# List of the budgets owned by the requested billing account.
|
89
|
+
# @!attribute [rw] next_page_token
|
90
|
+
# @return [::String]
|
91
|
+
# If not empty, indicates that there may be more budgets that match the
|
92
|
+
# request; this value should be passed in a new `ListBudgetsRequest`.
|
93
|
+
class ListBudgetsResponse
|
94
|
+
include ::Google::Protobuf::MessageExts
|
95
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
96
|
+
end
|
97
|
+
|
98
|
+
# Request for DeleteBudget
|
99
|
+
# @!attribute [rw] name
|
100
|
+
# @return [::String]
|
101
|
+
# Required. Name of the budget to delete. Values are of the form
|
102
|
+
# `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
|
103
|
+
class DeleteBudgetRequest
|
104
|
+
include ::Google::Protobuf::MessageExts
|
105
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Protobuf
|
22
|
+
# A generic empty message that you can re-use to avoid defining duplicated
|
23
|
+
# empty messages in your APIs. A typical example is to use it as the request
|
24
|
+
# or the response type of an API method. For instance:
|
25
|
+
#
|
26
|
+
# service Foo {
|
27
|
+
# rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
28
|
+
# }
|
29
|
+
#
|
30
|
+
# The JSON representation for `Empty` is empty JSON object `{}`.
|
31
|
+
class Empty
|
32
|
+
include ::Google::Protobuf::MessageExts
|
33
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Protobuf
|
22
|
+
# `FieldMask` represents a set of symbolic field paths, for example:
|
23
|
+
#
|
24
|
+
# paths: "f.a"
|
25
|
+
# paths: "f.b.d"
|
26
|
+
#
|
27
|
+
# Here `f` represents a field in some root message, `a` and `b`
|
28
|
+
# fields in the message found in `f`, and `d` a field found in the
|
29
|
+
# message in `f.b`.
|
30
|
+
#
|
31
|
+
# Field masks are used to specify a subset of fields that should be
|
32
|
+
# returned by a get operation or modified by an update operation.
|
33
|
+
# Field masks also have a custom JSON encoding (see below).
|
34
|
+
#
|
35
|
+
# # Field Masks in Projections
|
36
|
+
#
|
37
|
+
# When used in the context of a projection, a response message or
|
38
|
+
# sub-message is filtered by the API to only contain those fields as
|
39
|
+
# specified in the mask. For example, if the mask in the previous
|
40
|
+
# example is applied to a response message as follows:
|
41
|
+
#
|
42
|
+
# f {
|
43
|
+
# a : 22
|
44
|
+
# b {
|
45
|
+
# d : 1
|
46
|
+
# x : 2
|
47
|
+
# }
|
48
|
+
# y : 13
|
49
|
+
# }
|
50
|
+
# z: 8
|
51
|
+
#
|
52
|
+
# The result will not contain specific values for fields x,y and z
|
53
|
+
# (their value will be set to the default, and omitted in proto text
|
54
|
+
# output):
|
55
|
+
#
|
56
|
+
#
|
57
|
+
# f {
|
58
|
+
# a : 22
|
59
|
+
# b {
|
60
|
+
# d : 1
|
61
|
+
# }
|
62
|
+
# }
|
63
|
+
#
|
64
|
+
# A repeated field is not allowed except at the last position of a
|
65
|
+
# paths string.
|
66
|
+
#
|
67
|
+
# If a FieldMask object is not present in a get operation, the
|
68
|
+
# operation applies to all fields (as if a FieldMask of all fields
|
69
|
+
# had been specified).
|
70
|
+
#
|
71
|
+
# Note that a field mask does not necessarily apply to the
|
72
|
+
# top-level response message. In case of a REST get operation, the
|
73
|
+
# field mask applies directly to the response, but in case of a REST
|
74
|
+
# list operation, the mask instead applies to each individual message
|
75
|
+
# in the returned resource list. In case of a REST custom method,
|
76
|
+
# other definitions may be used. Where the mask applies will be
|
77
|
+
# clearly documented together with its declaration in the API. In
|
78
|
+
# any case, the effect on the returned resource/resources is required
|
79
|
+
# behavior for APIs.
|
80
|
+
#
|
81
|
+
# # Field Masks in Update Operations
|
82
|
+
#
|
83
|
+
# A field mask in update operations specifies which fields of the
|
84
|
+
# targeted resource are going to be updated. The API is required
|
85
|
+
# to only change the values of the fields as specified in the mask
|
86
|
+
# and leave the others untouched. If a resource is passed in to
|
87
|
+
# describe the updated values, the API ignores the values of all
|
88
|
+
# fields not covered by the mask.
|
89
|
+
#
|
90
|
+
# If a repeated field is specified for an update operation, new values will
|
91
|
+
# be appended to the existing repeated field in the target resource. Note that
|
92
|
+
# a repeated field is only allowed in the last position of a `paths` string.
|
93
|
+
#
|
94
|
+
# If a sub-message is specified in the last position of the field mask for an
|
95
|
+
# update operation, then new value will be merged into the existing sub-message
|
96
|
+
# in the target resource.
|
97
|
+
#
|
98
|
+
# For example, given the target message:
|
99
|
+
#
|
100
|
+
# f {
|
101
|
+
# b {
|
102
|
+
# d: 1
|
103
|
+
# x: 2
|
104
|
+
# }
|
105
|
+
# c: [1]
|
106
|
+
# }
|
107
|
+
#
|
108
|
+
# And an update message:
|
109
|
+
#
|
110
|
+
# f {
|
111
|
+
# b {
|
112
|
+
# d: 10
|
113
|
+
# }
|
114
|
+
# c: [2]
|
115
|
+
# }
|
116
|
+
#
|
117
|
+
# then if the field mask is:
|
118
|
+
#
|
119
|
+
# paths: ["f.b", "f.c"]
|
120
|
+
#
|
121
|
+
# then the result will be:
|
122
|
+
#
|
123
|
+
# f {
|
124
|
+
# b {
|
125
|
+
# d: 10
|
126
|
+
# x: 2
|
127
|
+
# }
|
128
|
+
# c: [1, 2]
|
129
|
+
# }
|
130
|
+
#
|
131
|
+
# An implementation may provide options to override this default behavior for
|
132
|
+
# repeated and message fields.
|
133
|
+
#
|
134
|
+
# In order to reset a field's value to the default, the field must
|
135
|
+
# be in the mask and set to the default value in the provided resource.
|
136
|
+
# Hence, in order to reset all fields of a resource, provide a default
|
137
|
+
# instance of the resource and set all fields in the mask, or do
|
138
|
+
# not provide a mask as described below.
|
139
|
+
#
|
140
|
+
# If a field mask is not present on update, the operation applies to
|
141
|
+
# all fields (as if a field mask of all fields has been specified).
|
142
|
+
# Note that in the presence of schema evolution, this may mean that
|
143
|
+
# fields the client does not know and has therefore not filled into
|
144
|
+
# the request will be reset to their default. If this is unwanted
|
145
|
+
# behavior, a specific service may require a client to always specify
|
146
|
+
# a field mask, producing an error if not.
|
147
|
+
#
|
148
|
+
# As with get operations, the location of the resource which
|
149
|
+
# describes the updated values in the request message depends on the
|
150
|
+
# operation kind. In any case, the effect of the field mask is
|
151
|
+
# required to be honored by the API.
|
152
|
+
#
|
153
|
+
# ## Considerations for HTTP REST
|
154
|
+
#
|
155
|
+
# The HTTP kind of an update operation which uses a field mask must
|
156
|
+
# be set to PATCH instead of PUT in order to satisfy HTTP semantics
|
157
|
+
# (PUT must only be used for full updates).
|
158
|
+
#
|
159
|
+
# # JSON Encoding of Field Masks
|
160
|
+
#
|
161
|
+
# In JSON, a field mask is encoded as a single string where paths are
|
162
|
+
# separated by a comma. Fields name in each path are converted
|
163
|
+
# to/from lower-camel naming conventions.
|
164
|
+
#
|
165
|
+
# As an example, consider the following message declarations:
|
166
|
+
#
|
167
|
+
# message Profile {
|
168
|
+
# User user = 1;
|
169
|
+
# Photo photo = 2;
|
170
|
+
# }
|
171
|
+
# message User {
|
172
|
+
# string display_name = 1;
|
173
|
+
# string address = 2;
|
174
|
+
# }
|
175
|
+
#
|
176
|
+
# In proto a field mask for `Profile` may look as such:
|
177
|
+
#
|
178
|
+
# mask {
|
179
|
+
# paths: "user.display_name"
|
180
|
+
# paths: "photo"
|
181
|
+
# }
|
182
|
+
#
|
183
|
+
# In JSON, the same mask is represented as below:
|
184
|
+
#
|
185
|
+
# {
|
186
|
+
# mask: "user.displayName,photo"
|
187
|
+
# }
|
188
|
+
#
|
189
|
+
# # Field Masks and Oneof Fields
|
190
|
+
#
|
191
|
+
# Field masks treat fields in oneofs just as regular fields. Consider the
|
192
|
+
# following message:
|
193
|
+
#
|
194
|
+
# message SampleMessage {
|
195
|
+
# oneof test_oneof {
|
196
|
+
# string name = 4;
|
197
|
+
# SubMessage sub_message = 9;
|
198
|
+
# }
|
199
|
+
# }
|
200
|
+
#
|
201
|
+
# The field mask can be:
|
202
|
+
#
|
203
|
+
# mask {
|
204
|
+
# paths: "name"
|
205
|
+
# }
|
206
|
+
#
|
207
|
+
# Or:
|
208
|
+
#
|
209
|
+
# mask {
|
210
|
+
# paths: "sub_message"
|
211
|
+
# }
|
212
|
+
#
|
213
|
+
# Note that oneof type names ("test_oneof" in this case) cannot be used in
|
214
|
+
# paths.
|
215
|
+
#
|
216
|
+
# ## Field Mask Verification
|
217
|
+
#
|
218
|
+
# The implementation of any API method which has a FieldMask type field in the
|
219
|
+
# request should verify the included field paths, and return an
|
220
|
+
# `INVALID_ARGUMENT` error if any path is unmappable.
|
221
|
+
# @!attribute [rw] paths
|
222
|
+
# @return [::Array<::String>]
|
223
|
+
# The set of field mask paths.
|
224
|
+
class FieldMask
|
225
|
+
include ::Google::Protobuf::MessageExts
|
226
|
+
extend ::Google::Protobuf::MessageExts::ClassMethods
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|