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.
@@ -0,0 +1,21 @@
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
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/billing/budgets/v1beta1"
@@ -0,0 +1,37 @@
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
+ require "google/cloud/billing/budgets/v1beta1/budget_service"
20
+ require "google/cloud/billing/budgets/v1beta1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Billing
25
+ module Budgets
26
+ ##
27
+ # To load this package, including all its services, and instantiate a client:
28
+ #
29
+ # require "google/cloud/billing/budgets/v1beta1"
30
+ # client = ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client.new
31
+ #
32
+ module V1beta1
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,75 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/billing/budgets/v1beta1/budget_model.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/field_behavior_pb'
7
+ require 'google/api/resource_pb'
8
+ require 'google/protobuf/struct_pb'
9
+ require 'google/type/money_pb'
10
+ Google::Protobuf::DescriptorPool.generated_pool.build do
11
+ add_file("google/cloud/billing/budgets/v1beta1/budget_model.proto", :syntax => :proto3) do
12
+ add_message "google.cloud.billing.budgets.v1beta1.Budget" do
13
+ optional :name, :string, 1
14
+ optional :display_name, :string, 2
15
+ optional :budget_filter, :message, 3, "google.cloud.billing.budgets.v1beta1.Filter"
16
+ optional :amount, :message, 4, "google.cloud.billing.budgets.v1beta1.BudgetAmount"
17
+ repeated :threshold_rules, :message, 5, "google.cloud.billing.budgets.v1beta1.ThresholdRule"
18
+ optional :all_updates_rule, :message, 6, "google.cloud.billing.budgets.v1beta1.AllUpdatesRule"
19
+ optional :etag, :string, 7
20
+ end
21
+ add_message "google.cloud.billing.budgets.v1beta1.BudgetAmount" do
22
+ oneof :budget_amount do
23
+ optional :specified_amount, :message, 1, "google.type.Money"
24
+ optional :last_period_amount, :message, 2, "google.cloud.billing.budgets.v1beta1.LastPeriodAmount"
25
+ end
26
+ end
27
+ add_message "google.cloud.billing.budgets.v1beta1.LastPeriodAmount" do
28
+ end
29
+ add_message "google.cloud.billing.budgets.v1beta1.ThresholdRule" do
30
+ optional :threshold_percent, :double, 1
31
+ optional :spend_basis, :enum, 2, "google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis"
32
+ end
33
+ add_enum "google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis" do
34
+ value :BASIS_UNSPECIFIED, 0
35
+ value :CURRENT_SPEND, 1
36
+ value :FORECASTED_SPEND, 2
37
+ end
38
+ add_message "google.cloud.billing.budgets.v1beta1.AllUpdatesRule" do
39
+ optional :pubsub_topic, :string, 1
40
+ optional :schema_version, :string, 2
41
+ repeated :monitoring_notification_channels, :string, 3
42
+ end
43
+ add_message "google.cloud.billing.budgets.v1beta1.Filter" do
44
+ repeated :projects, :string, 1
45
+ optional :credit_types_treatment, :enum, 4, "google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment"
46
+ repeated :services, :string, 3
47
+ repeated :subaccounts, :string, 5
48
+ map :labels, :string, :message, 6, "google.protobuf.ListValue"
49
+ end
50
+ add_enum "google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment" do
51
+ value :CREDIT_TYPES_TREATMENT_UNSPECIFIED, 0
52
+ value :INCLUDE_ALL_CREDITS, 1
53
+ value :EXCLUDE_ALL_CREDITS, 2
54
+ end
55
+ end
56
+ end
57
+
58
+ module Google
59
+ module Cloud
60
+ module Billing
61
+ module Budgets
62
+ module V1beta1
63
+ Budget = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.Budget").msgclass
64
+ BudgetAmount = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.BudgetAmount").msgclass
65
+ LastPeriodAmount = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.LastPeriodAmount").msgclass
66
+ ThresholdRule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.ThresholdRule").msgclass
67
+ ThresholdRule::Basis = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis").enummodule
68
+ AllUpdatesRule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.AllUpdatesRule").msgclass
69
+ Filter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.Filter").msgclass
70
+ Filter::CreditTypesTreatment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment").enummodule
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,52 @@
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
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/billing/budgets/v1beta1/version"
24
+
25
+ require "google/cloud/billing/budgets/v1beta1/budget_service/credentials"
26
+ require "google/cloud/billing/budgets/v1beta1/budget_service/paths"
27
+ require "google/cloud/billing/budgets/v1beta1/budget_service/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Billing
32
+ module Budgets
33
+ module V1beta1
34
+ ##
35
+ # BudgetService stores Cloud Billing budgets, which define a
36
+ # budget plan and rules to execute as we track spend against that plan.
37
+ #
38
+ # To load this service and instantiate a client:
39
+ #
40
+ # require "google/cloud/billing/budgets/v1beta1/budget_service"
41
+ # client = ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client.new
42
+ #
43
+ module BudgetService
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "budget_service", "helpers.rb"
52
+ require "google/cloud/billing/budgets/v1beta1/budget_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,736 @@
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
+ require "google/cloud/errors"
20
+ require "google/cloud/billing/budgets/v1beta1/budget_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Billing
25
+ module Budgets
26
+ module V1beta1
27
+ module BudgetService
28
+ ##
29
+ # Client for the BudgetService service.
30
+ #
31
+ # BudgetService stores Cloud Billing budgets, which define a
32
+ # budget plan and rules to execute as we track spend against that plan.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :budget_service_stub
39
+
40
+ ##
41
+ # Configure the BudgetService Client class.
42
+ #
43
+ # See {::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # ## Example
47
+ #
48
+ # To modify the configuration for all BudgetService clients:
49
+ #
50
+ # ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "Billing", "Budgets", "V1beta1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const&.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.rpcs.create_budget.timeout = 60.0
71
+
72
+ default_config.rpcs.update_budget.timeout = 60.0
73
+ default_config.rpcs.update_budget.retry_policy = {
74
+ initial_delay: 0.1,
75
+ max_delay: 60.0,
76
+ multiplier: 1.3,
77
+ retry_codes: [4, 14]
78
+ }
79
+
80
+ default_config.rpcs.get_budget.timeout = 60.0
81
+ default_config.rpcs.get_budget.retry_policy = {
82
+ initial_delay: 0.1,
83
+ max_delay: 60.0,
84
+ multiplier: 1.3,
85
+ retry_codes: [4, 14]
86
+ }
87
+
88
+ default_config.rpcs.list_budgets.timeout = 60.0
89
+ default_config.rpcs.list_budgets.retry_policy = {
90
+ initial_delay: 0.1,
91
+ max_delay: 60.0,
92
+ multiplier: 1.3,
93
+ retry_codes: [4, 14]
94
+ }
95
+
96
+ default_config.rpcs.delete_budget.timeout = 60.0
97
+ default_config.rpcs.delete_budget.retry_policy = {
98
+ initial_delay: 0.1,
99
+ max_delay: 60.0,
100
+ multiplier: 1.3,
101
+ retry_codes: [4, 14]
102
+ }
103
+
104
+ default_config
105
+ end
106
+ yield @configure if block_given?
107
+ @configure
108
+ end
109
+
110
+ ##
111
+ # Configure the BudgetService Client instance.
112
+ #
113
+ # The configuration is set to the derived mode, meaning that values can be changed,
114
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
115
+ # should be made on {Client.configure}.
116
+ #
117
+ # See {::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client::Configuration}
118
+ # for a description of the configuration fields.
119
+ #
120
+ # @yield [config] Configure the Client client.
121
+ # @yieldparam config [Client::Configuration]
122
+ #
123
+ # @return [Client::Configuration]
124
+ #
125
+ def configure
126
+ yield @config if block_given?
127
+ @config
128
+ end
129
+
130
+ ##
131
+ # Create a new BudgetService client object.
132
+ #
133
+ # ## Examples
134
+ #
135
+ # To create a new BudgetService client with the default
136
+ # configuration:
137
+ #
138
+ # client = ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client.new
139
+ #
140
+ # To create a new BudgetService client with a custom
141
+ # configuration:
142
+ #
143
+ # client = ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client.new do |config|
144
+ # config.timeout = 10.0
145
+ # end
146
+ #
147
+ # @yield [config] Configure the BudgetService client.
148
+ # @yieldparam config [Client::Configuration]
149
+ #
150
+ def initialize
151
+ # These require statements are intentionally placed here to initialize
152
+ # the gRPC module only when it's required.
153
+ # See https://github.com/googleapis/toolkit/issues/446
154
+ require "gapic/grpc"
155
+ require "google/cloud/billing/budgets/v1beta1/budget_service_services_pb"
156
+
157
+ # Create the configuration object
158
+ @config = Configuration.new Client.configure
159
+
160
+ # Yield the configuration if needed
161
+ yield @config if block_given?
162
+
163
+ # Create credentials
164
+ credentials = @config.credentials
165
+ credentials ||= Credentials.default scope: @config.scope
166
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
167
+ credentials = Credentials.new credentials, scope: @config.scope
168
+ end
169
+ @quota_project_id = @config.quota_project
170
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
171
+
172
+ @budget_service_stub = ::Gapic::ServiceStub.new(
173
+ ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Stub,
174
+ credentials: credentials,
175
+ endpoint: @config.endpoint,
176
+ channel_args: @config.channel_args,
177
+ interceptors: @config.interceptors
178
+ )
179
+ end
180
+
181
+ # Service calls
182
+
183
+ ##
184
+ # Creates a new budget. See
185
+ # <a href="https://cloud.google.com/billing/quotas">Quotas and limits</a>
186
+ # for more information on the limits of the number of budgets you can create.
187
+ #
188
+ # @overload create_budget(request, options = nil)
189
+ # Pass arguments to `create_budget` via a request object, either of type
190
+ # {::Google::Cloud::Billing::Budgets::V1beta1::CreateBudgetRequest} or an equivalent Hash.
191
+ #
192
+ # @param request [::Google::Cloud::Billing::Budgets::V1beta1::CreateBudgetRequest, ::Hash]
193
+ # A request object representing the call parameters. Required. To specify no
194
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
195
+ # @param options [::Gapic::CallOptions, ::Hash]
196
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
197
+ #
198
+ # @overload create_budget(parent: nil, budget: nil)
199
+ # Pass arguments to `create_budget` via keyword arguments. Note that at
200
+ # least one keyword argument is required. To specify no parameters, or to keep all
201
+ # the default parameter values, pass an empty Hash as a request object (see above).
202
+ #
203
+ # @param parent [::String]
204
+ # Required. The name of the billing account to create the budget in. Values
205
+ # are of the form `billingAccounts/{billingAccountId}`.
206
+ # @param budget [::Google::Cloud::Billing::Budgets::V1beta1::Budget, ::Hash]
207
+ # Required. Budget to create.
208
+ #
209
+ # @yield [response, operation] Access the result along with the RPC operation
210
+ # @yieldparam response [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
211
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
212
+ #
213
+ # @return [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
214
+ #
215
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
216
+ #
217
+ def create_budget request, options = nil
218
+ raise ::ArgumentError, "request must be provided" if request.nil?
219
+
220
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::Budgets::V1beta1::CreateBudgetRequest
221
+
222
+ # Converts hash and nil to an options object
223
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
224
+
225
+ # Customize the options with defaults
226
+ metadata = @config.rpcs.create_budget.metadata.to_h
227
+
228
+ # Set x-goog-api-client and x-goog-user-project headers
229
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
230
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
231
+ gapic_version: ::Google::Cloud::Billing::Budgets::V1beta1::VERSION
232
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
233
+
234
+ header_params = {
235
+ "parent" => request.parent
236
+ }
237
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
238
+ metadata[:"x-goog-request-params"] ||= request_params_header
239
+
240
+ options.apply_defaults timeout: @config.rpcs.create_budget.timeout,
241
+ metadata: metadata,
242
+ retry_policy: @config.rpcs.create_budget.retry_policy
243
+ options.apply_defaults metadata: @config.metadata,
244
+ retry_policy: @config.retry_policy
245
+
246
+ @budget_service_stub.call_rpc :create_budget, request, options: options do |response, operation|
247
+ yield response, operation if block_given?
248
+ return response
249
+ end
250
+ rescue ::GRPC::BadStatus => e
251
+ raise ::Google::Cloud::Error.from_error(e)
252
+ end
253
+
254
+ ##
255
+ # Updates a budget and returns the updated budget.
256
+ #
257
+ # WARNING: There are some fields exposed on the Google Cloud Console that
258
+ # aren't available on this API. Budget fields that are not exposed in
259
+ # this API will not be changed by this method.
260
+ #
261
+ # @overload update_budget(request, options = nil)
262
+ # Pass arguments to `update_budget` via a request object, either of type
263
+ # {::Google::Cloud::Billing::Budgets::V1beta1::UpdateBudgetRequest} or an equivalent Hash.
264
+ #
265
+ # @param request [::Google::Cloud::Billing::Budgets::V1beta1::UpdateBudgetRequest, ::Hash]
266
+ # A request object representing the call parameters. Required. To specify no
267
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
268
+ # @param options [::Gapic::CallOptions, ::Hash]
269
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
270
+ #
271
+ # @overload update_budget(budget: nil, update_mask: nil)
272
+ # Pass arguments to `update_budget` via keyword arguments. Note that at
273
+ # least one keyword argument is required. To specify no parameters, or to keep all
274
+ # the default parameter values, pass an empty Hash as a request object (see above).
275
+ #
276
+ # @param budget [::Google::Cloud::Billing::Budgets::V1beta1::Budget, ::Hash]
277
+ # Required. The updated budget object.
278
+ # The budget to update is specified by the budget name in the budget.
279
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
280
+ # Optional. Indicates which fields in the provided budget to update.
281
+ # Read-only fields (such as `name`) cannot be changed. If this is not
282
+ # provided, then only fields with non-default values from the request are
283
+ # updated. See
284
+ # https://developers.google.com/protocol-buffers/docs/proto3#default for more
285
+ # details about default values.
286
+ #
287
+ # @yield [response, operation] Access the result along with the RPC operation
288
+ # @yieldparam response [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
289
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
290
+ #
291
+ # @return [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
292
+ #
293
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
294
+ #
295
+ def update_budget request, options = nil
296
+ raise ::ArgumentError, "request must be provided" if request.nil?
297
+
298
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::Budgets::V1beta1::UpdateBudgetRequest
299
+
300
+ # Converts hash and nil to an options object
301
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
302
+
303
+ # Customize the options with defaults
304
+ metadata = @config.rpcs.update_budget.metadata.to_h
305
+
306
+ # Set x-goog-api-client and x-goog-user-project headers
307
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
308
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
309
+ gapic_version: ::Google::Cloud::Billing::Budgets::V1beta1::VERSION
310
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
311
+
312
+ header_params = {
313
+ "budget.name" => request.budget.name
314
+ }
315
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
316
+ metadata[:"x-goog-request-params"] ||= request_params_header
317
+
318
+ options.apply_defaults timeout: @config.rpcs.update_budget.timeout,
319
+ metadata: metadata,
320
+ retry_policy: @config.rpcs.update_budget.retry_policy
321
+ options.apply_defaults metadata: @config.metadata,
322
+ retry_policy: @config.retry_policy
323
+
324
+ @budget_service_stub.call_rpc :update_budget, request, options: options do |response, operation|
325
+ yield response, operation if block_given?
326
+ return response
327
+ end
328
+ rescue ::GRPC::BadStatus => e
329
+ raise ::Google::Cloud::Error.from_error(e)
330
+ end
331
+
332
+ ##
333
+ # Returns a budget.
334
+ #
335
+ # WARNING: There are some fields exposed on the Google Cloud Console that
336
+ # aren't available on this API. When reading from the API, you will not
337
+ # see these fields in the return value, though they may have been set
338
+ # in the Cloud Console.
339
+ #
340
+ # @overload get_budget(request, options = nil)
341
+ # Pass arguments to `get_budget` via a request object, either of type
342
+ # {::Google::Cloud::Billing::Budgets::V1beta1::GetBudgetRequest} or an equivalent Hash.
343
+ #
344
+ # @param request [::Google::Cloud::Billing::Budgets::V1beta1::GetBudgetRequest, ::Hash]
345
+ # A request object representing the call parameters. Required. To specify no
346
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
347
+ # @param options [::Gapic::CallOptions, ::Hash]
348
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
349
+ #
350
+ # @overload get_budget(name: nil)
351
+ # Pass arguments to `get_budget` via keyword arguments. Note that at
352
+ # least one keyword argument is required. To specify no parameters, or to keep all
353
+ # the default parameter values, pass an empty Hash as a request object (see above).
354
+ #
355
+ # @param name [::String]
356
+ # Required. Name of budget to get. Values are of the form
357
+ # `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
358
+ #
359
+ # @yield [response, operation] Access the result along with the RPC operation
360
+ # @yieldparam response [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
361
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
362
+ #
363
+ # @return [::Google::Cloud::Billing::Budgets::V1beta1::Budget]
364
+ #
365
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
366
+ #
367
+ def get_budget request, options = nil
368
+ raise ::ArgumentError, "request must be provided" if request.nil?
369
+
370
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::Budgets::V1beta1::GetBudgetRequest
371
+
372
+ # Converts hash and nil to an options object
373
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
374
+
375
+ # Customize the options with defaults
376
+ metadata = @config.rpcs.get_budget.metadata.to_h
377
+
378
+ # Set x-goog-api-client and x-goog-user-project headers
379
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
380
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
381
+ gapic_version: ::Google::Cloud::Billing::Budgets::V1beta1::VERSION
382
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
383
+
384
+ header_params = {
385
+ "name" => request.name
386
+ }
387
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
388
+ metadata[:"x-goog-request-params"] ||= request_params_header
389
+
390
+ options.apply_defaults timeout: @config.rpcs.get_budget.timeout,
391
+ metadata: metadata,
392
+ retry_policy: @config.rpcs.get_budget.retry_policy
393
+ options.apply_defaults metadata: @config.metadata,
394
+ retry_policy: @config.retry_policy
395
+
396
+ @budget_service_stub.call_rpc :get_budget, request, options: options do |response, operation|
397
+ yield response, operation if block_given?
398
+ return response
399
+ end
400
+ rescue ::GRPC::BadStatus => e
401
+ raise ::Google::Cloud::Error.from_error(e)
402
+ end
403
+
404
+ ##
405
+ # Returns a list of budgets for a billing account.
406
+ #
407
+ # WARNING: There are some fields exposed on the Google Cloud Console that
408
+ # aren't available on this API. When reading from the API, you will not
409
+ # see these fields in the return value, though they may have been set
410
+ # in the Cloud Console.
411
+ #
412
+ # @overload list_budgets(request, options = nil)
413
+ # Pass arguments to `list_budgets` via a request object, either of type
414
+ # {::Google::Cloud::Billing::Budgets::V1beta1::ListBudgetsRequest} or an equivalent Hash.
415
+ #
416
+ # @param request [::Google::Cloud::Billing::Budgets::V1beta1::ListBudgetsRequest, ::Hash]
417
+ # A request object representing the call parameters. Required. To specify no
418
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
419
+ # @param options [::Gapic::CallOptions, ::Hash]
420
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
421
+ #
422
+ # @overload list_budgets(parent: nil, page_size: nil, page_token: nil)
423
+ # Pass arguments to `list_budgets` via keyword arguments. Note that at
424
+ # least one keyword argument is required. To specify no parameters, or to keep all
425
+ # the default parameter values, pass an empty Hash as a request object (see above).
426
+ #
427
+ # @param parent [::String]
428
+ # Required. Name of billing account to list budgets under. Values
429
+ # are of the form `billingAccounts/{billingAccountId}`.
430
+ # @param page_size [::Integer]
431
+ # Optional. The maximum number of budgets to return per page.
432
+ # The default and maximum value are 100.
433
+ # @param page_token [::String]
434
+ # Optional. The value returned by the last `ListBudgetsResponse` which
435
+ # indicates that this is a continuation of a prior `ListBudgets` call,
436
+ # and that the system should return the next page of data.
437
+ #
438
+ # @yield [response, operation] Access the result along with the RPC operation
439
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Billing::Budgets::V1beta1::Budget>]
440
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
441
+ #
442
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Billing::Budgets::V1beta1::Budget>]
443
+ #
444
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
445
+ #
446
+ def list_budgets request, options = nil
447
+ raise ::ArgumentError, "request must be provided" if request.nil?
448
+
449
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::Budgets::V1beta1::ListBudgetsRequest
450
+
451
+ # Converts hash and nil to an options object
452
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
453
+
454
+ # Customize the options with defaults
455
+ metadata = @config.rpcs.list_budgets.metadata.to_h
456
+
457
+ # Set x-goog-api-client and x-goog-user-project headers
458
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
459
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
460
+ gapic_version: ::Google::Cloud::Billing::Budgets::V1beta1::VERSION
461
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
462
+
463
+ header_params = {
464
+ "parent" => request.parent
465
+ }
466
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
467
+ metadata[:"x-goog-request-params"] ||= request_params_header
468
+
469
+ options.apply_defaults timeout: @config.rpcs.list_budgets.timeout,
470
+ metadata: metadata,
471
+ retry_policy: @config.rpcs.list_budgets.retry_policy
472
+ options.apply_defaults metadata: @config.metadata,
473
+ retry_policy: @config.retry_policy
474
+
475
+ @budget_service_stub.call_rpc :list_budgets, request, options: options do |response, operation|
476
+ response = ::Gapic::PagedEnumerable.new @budget_service_stub, :list_budgets, request, response, operation, options
477
+ yield response, operation if block_given?
478
+ return response
479
+ end
480
+ rescue ::GRPC::BadStatus => e
481
+ raise ::Google::Cloud::Error.from_error(e)
482
+ end
483
+
484
+ ##
485
+ # Deletes a budget. Returns successfully if already deleted.
486
+ #
487
+ # @overload delete_budget(request, options = nil)
488
+ # Pass arguments to `delete_budget` via a request object, either of type
489
+ # {::Google::Cloud::Billing::Budgets::V1beta1::DeleteBudgetRequest} or an equivalent Hash.
490
+ #
491
+ # @param request [::Google::Cloud::Billing::Budgets::V1beta1::DeleteBudgetRequest, ::Hash]
492
+ # A request object representing the call parameters. Required. To specify no
493
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
494
+ # @param options [::Gapic::CallOptions, ::Hash]
495
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
496
+ #
497
+ # @overload delete_budget(name: nil)
498
+ # Pass arguments to `delete_budget` via keyword arguments. Note that at
499
+ # least one keyword argument is required. To specify no parameters, or to keep all
500
+ # the default parameter values, pass an empty Hash as a request object (see above).
501
+ #
502
+ # @param name [::String]
503
+ # Required. Name of the budget to delete. Values are of the form
504
+ # `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
505
+ #
506
+ # @yield [response, operation] Access the result along with the RPC operation
507
+ # @yieldparam response [::Google::Protobuf::Empty]
508
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
509
+ #
510
+ # @return [::Google::Protobuf::Empty]
511
+ #
512
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
513
+ #
514
+ def delete_budget request, options = nil
515
+ raise ::ArgumentError, "request must be provided" if request.nil?
516
+
517
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::Budgets::V1beta1::DeleteBudgetRequest
518
+
519
+ # Converts hash and nil to an options object
520
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
521
+
522
+ # Customize the options with defaults
523
+ metadata = @config.rpcs.delete_budget.metadata.to_h
524
+
525
+ # Set x-goog-api-client and x-goog-user-project headers
526
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
527
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
528
+ gapic_version: ::Google::Cloud::Billing::Budgets::V1beta1::VERSION
529
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
530
+
531
+ header_params = {
532
+ "name" => request.name
533
+ }
534
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
535
+ metadata[:"x-goog-request-params"] ||= request_params_header
536
+
537
+ options.apply_defaults timeout: @config.rpcs.delete_budget.timeout,
538
+ metadata: metadata,
539
+ retry_policy: @config.rpcs.delete_budget.retry_policy
540
+ options.apply_defaults metadata: @config.metadata,
541
+ retry_policy: @config.retry_policy
542
+
543
+ @budget_service_stub.call_rpc :delete_budget, request, options: options do |response, operation|
544
+ yield response, operation if block_given?
545
+ return response
546
+ end
547
+ rescue ::GRPC::BadStatus => e
548
+ raise ::Google::Cloud::Error.from_error(e)
549
+ end
550
+
551
+ ##
552
+ # Configuration class for the BudgetService API.
553
+ #
554
+ # This class represents the configuration for BudgetService,
555
+ # providing control over timeouts, retry behavior, logging, transport
556
+ # parameters, and other low-level controls. Certain parameters can also be
557
+ # applied individually to specific RPCs. See
558
+ # {::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client::Configuration::Rpcs}
559
+ # for a list of RPCs that can be configured independently.
560
+ #
561
+ # Configuration can be applied globally to all clients, or to a single client
562
+ # on construction.
563
+ #
564
+ # # Examples
565
+ #
566
+ # To modify the global config, setting the timeout for create_budget
567
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
568
+ #
569
+ # ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client.configure do |config|
570
+ # config.timeout = 10.0
571
+ # config.rpcs.create_budget.timeout = 20.0
572
+ # end
573
+ #
574
+ # To apply the above configuration only to a new client:
575
+ #
576
+ # client = ::Google::Cloud::Billing::Budgets::V1beta1::BudgetService::Client.new do |config|
577
+ # config.timeout = 10.0
578
+ # config.rpcs.create_budget.timeout = 20.0
579
+ # end
580
+ #
581
+ # @!attribute [rw] endpoint
582
+ # The hostname or hostname:port of the service endpoint.
583
+ # Defaults to `"billingbudgets.googleapis.com"`.
584
+ # @return [::String]
585
+ # @!attribute [rw] credentials
586
+ # Credentials to send with calls. You may provide any of the following types:
587
+ # * (`String`) The path to a service account key file in JSON format
588
+ # * (`Hash`) A service account key as a Hash
589
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
590
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
591
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
592
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
593
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
594
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
595
+ # * (`nil`) indicating no credentials
596
+ # @return [::Object]
597
+ # @!attribute [rw] scope
598
+ # The OAuth scopes
599
+ # @return [::Array<::String>]
600
+ # @!attribute [rw] lib_name
601
+ # The library name as recorded in instrumentation and logging
602
+ # @return [::String]
603
+ # @!attribute [rw] lib_version
604
+ # The library version as recorded in instrumentation and logging
605
+ # @return [::String]
606
+ # @!attribute [rw] channel_args
607
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
608
+ # `GRPC::Core::Channel` object is provided as the credential.
609
+ # @return [::Hash]
610
+ # @!attribute [rw] interceptors
611
+ # An array of interceptors that are run before calls are executed.
612
+ # @return [::Array<::GRPC::ClientInterceptor>]
613
+ # @!attribute [rw] timeout
614
+ # The call timeout in seconds.
615
+ # @return [::Numeric]
616
+ # @!attribute [rw] metadata
617
+ # Additional gRPC headers to be sent with the call.
618
+ # @return [::Hash{::Symbol=>::String}]
619
+ # @!attribute [rw] retry_policy
620
+ # The retry policy. The value is a hash with the following keys:
621
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
622
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
623
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
624
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
625
+ # trigger a retry.
626
+ # @return [::Hash]
627
+ # @!attribute [rw] quota_project
628
+ # A separate project against which to charge quota.
629
+ # @return [::String]
630
+ #
631
+ class Configuration
632
+ extend ::Gapic::Config
633
+
634
+ config_attr :endpoint, "billingbudgets.googleapis.com", ::String
635
+ config_attr :credentials, nil do |value|
636
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
637
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
638
+ allowed.any? { |klass| klass === value }
639
+ end
640
+ config_attr :scope, nil, ::String, ::Array, nil
641
+ config_attr :lib_name, nil, ::String, nil
642
+ config_attr :lib_version, nil, ::String, nil
643
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
644
+ config_attr :interceptors, nil, ::Array, nil
645
+ config_attr :timeout, nil, ::Numeric, nil
646
+ config_attr :metadata, nil, ::Hash, nil
647
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
648
+ config_attr :quota_project, nil, ::String, nil
649
+
650
+ # @private
651
+ def initialize parent_config = nil
652
+ @parent_config = parent_config unless parent_config.nil?
653
+
654
+ yield self if block_given?
655
+ end
656
+
657
+ ##
658
+ # Configurations for individual RPCs
659
+ # @return [Rpcs]
660
+ #
661
+ def rpcs
662
+ @rpcs ||= begin
663
+ parent_rpcs = nil
664
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
665
+ Rpcs.new parent_rpcs
666
+ end
667
+ end
668
+
669
+ ##
670
+ # Configuration RPC class for the BudgetService API.
671
+ #
672
+ # Includes fields providing the configuration for each RPC in this service.
673
+ # Each configuration object is of type `Gapic::Config::Method` and includes
674
+ # the following configuration fields:
675
+ #
676
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
677
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
678
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
679
+ # include the following keys:
680
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
681
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
682
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
683
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
684
+ # trigger a retry.
685
+ #
686
+ class Rpcs
687
+ ##
688
+ # RPC-specific configuration for `create_budget`
689
+ # @return [::Gapic::Config::Method]
690
+ #
691
+ attr_reader :create_budget
692
+ ##
693
+ # RPC-specific configuration for `update_budget`
694
+ # @return [::Gapic::Config::Method]
695
+ #
696
+ attr_reader :update_budget
697
+ ##
698
+ # RPC-specific configuration for `get_budget`
699
+ # @return [::Gapic::Config::Method]
700
+ #
701
+ attr_reader :get_budget
702
+ ##
703
+ # RPC-specific configuration for `list_budgets`
704
+ # @return [::Gapic::Config::Method]
705
+ #
706
+ attr_reader :list_budgets
707
+ ##
708
+ # RPC-specific configuration for `delete_budget`
709
+ # @return [::Gapic::Config::Method]
710
+ #
711
+ attr_reader :delete_budget
712
+
713
+ # @private
714
+ def initialize parent_rpcs = nil
715
+ create_budget_config = parent_rpcs&.create_budget if parent_rpcs&.respond_to? :create_budget
716
+ @create_budget = ::Gapic::Config::Method.new create_budget_config
717
+ update_budget_config = parent_rpcs&.update_budget if parent_rpcs&.respond_to? :update_budget
718
+ @update_budget = ::Gapic::Config::Method.new update_budget_config
719
+ get_budget_config = parent_rpcs&.get_budget if parent_rpcs&.respond_to? :get_budget
720
+ @get_budget = ::Gapic::Config::Method.new get_budget_config
721
+ list_budgets_config = parent_rpcs&.list_budgets if parent_rpcs&.respond_to? :list_budgets
722
+ @list_budgets = ::Gapic::Config::Method.new list_budgets_config
723
+ delete_budget_config = parent_rpcs&.delete_budget if parent_rpcs&.respond_to? :delete_budget
724
+ @delete_budget = ::Gapic::Config::Method.new delete_budget_config
725
+
726
+ yield self if block_given?
727
+ end
728
+ end
729
+ end
730
+ end
731
+ end
732
+ end
733
+ end
734
+ end
735
+ end
736
+ end