google-cloud-billing-budgets-v1 0.2.0 → 0.3.0

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