google-cloud-billing-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +166 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +24 -0
  6. data/lib/google/cloud/billing/v1/cloud_billing/client.rb +955 -0
  7. data/lib/google/cloud/billing/v1/cloud_billing/credentials.rb +52 -0
  8. data/lib/google/cloud/billing/v1/cloud_billing/paths.rb +45 -0
  9. data/lib/google/cloud/billing/v1/cloud_billing.rb +20 -0
  10. data/lib/google/cloud/billing/v1/cloud_billing_pb.rb +84 -0
  11. data/lib/google/cloud/billing/v1/cloud_billing_services_pb.rb +127 -0
  12. data/lib/google/cloud/billing/v1/cloud_catalog/client.rb +326 -0
  13. data/lib/google/cloud/billing/v1/cloud_catalog/credentials.rb +52 -0
  14. data/lib/google/cloud/billing/v1/cloud_catalog/paths.rb +45 -0
  15. data/lib/google/cloud/billing/v1/cloud_catalog.rb +20 -0
  16. data/lib/google/cloud/billing/v1/cloud_catalog_pb.rb +113 -0
  17. data/lib/google/cloud/billing/v1/cloud_catalog_services_pb.rb +50 -0
  18. data/lib/google/cloud/billing/v1/version.rb +28 -0
  19. data/lib/google/cloud/billing/v1.rb +20 -0
  20. data/lib/google/cloud/common_resources_pb.rb +15 -0
  21. data/lib/google-cloud-billing-v1.rb +1 -0
  22. data/proto_docs/README.md +4 -0
  23. data/proto_docs/google/api/field_behavior.rb +59 -0
  24. data/proto_docs/google/api/resource.rb +247 -0
  25. data/proto_docs/google/cloud/billing/v1/cloud_billing.rb +217 -0
  26. data/proto_docs/google/cloud/billing/v1/cloud_catalog.rb +319 -0
  27. data/proto_docs/google/iam/v1/iam_policy.rb +79 -0
  28. data/proto_docs/google/iam/v1/policy.rb +156 -0
  29. data/proto_docs/google/protobuf/field_mask.rb +237 -0
  30. data/proto_docs/google/protobuf/timestamp.rb +116 -0
  31. data/proto_docs/google/type/money.rb +43 -0
  32. metadata +199 -0
@@ -0,0 +1,955 @@
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/errors"
24
+ require "google/cloud/billing/v1/version"
25
+ require "google/cloud/billing/v1/cloud_billing_pb"
26
+ require "google/cloud/billing/v1/cloud_billing/credentials"
27
+ require "google/cloud/billing/v1/cloud_billing/paths"
28
+
29
+
30
+ module Google
31
+ module Cloud
32
+ module Billing
33
+ module V1
34
+ module CloudBilling
35
+ # Service that implements CloudBilling API.
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :cloud_billing_stub
41
+
42
+ ##
43
+ # Configuration for the CloudBilling Client API.
44
+ #
45
+ # @yield [config] Configure the Client client.
46
+ # @yieldparam config [Client::Configuration]
47
+ #
48
+ # @return [Client::Configuration]
49
+ #
50
+ def self.configure
51
+ @configure ||= begin
52
+ namespace = ["Google", "Cloud", "Billing", "V1"]
53
+ parent_config = while namespace.any?
54
+ parent_name = namespace.join "::"
55
+ parent_const = const_get parent_name
56
+ break parent_const.configure if parent_const&.respond_to? :configure
57
+ namespace.pop
58
+ end
59
+ Client::Configuration.new parent_config
60
+ end
61
+ yield @configure if block_given?
62
+ @configure
63
+ end
64
+
65
+ ##
66
+ # Configure the CloudBilling Client instance.
67
+ #
68
+ # The configuration is set to the derived mode, meaning that values can be changed,
69
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
70
+ # should be made on {Client.configure}.
71
+ #
72
+ # @yield [config] Configure the Client client.
73
+ # @yieldparam config [Client::Configuration]
74
+ #
75
+ # @return [Client::Configuration]
76
+ #
77
+ def configure
78
+ yield @config if block_given?
79
+ @config
80
+ end
81
+
82
+ ##
83
+ # Create a new Client client object.
84
+ #
85
+ # @yield [config] Configure the Client client.
86
+ # @yieldparam config [Client::Configuration]
87
+ #
88
+ def initialize
89
+ # These require statements are intentionally placed here to initialize
90
+ # the gRPC module only when it's required.
91
+ # See https://github.com/googleapis/toolkit/issues/446
92
+ require "gapic/grpc"
93
+ require "google/cloud/billing/v1/cloud_billing_services_pb"
94
+
95
+ # Create the configuration object
96
+ @config = Configuration.new Client.configure
97
+
98
+ # Yield the configuration if needed
99
+ yield @config if block_given?
100
+
101
+ # Create credentials
102
+ credentials = @config.credentials
103
+ credentials ||= Credentials.default scope: @config.scope
104
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
105
+ credentials = Credentials.new credentials, scope: @config.scope
106
+ end
107
+
108
+
109
+ @cloud_billing_stub = Gapic::ServiceStub.new(
110
+ Google::Cloud::Billing::V1::CloudBilling::Stub,
111
+ credentials: credentials,
112
+ endpoint: @config.endpoint,
113
+ channel_args: @config.channel_args,
114
+ interceptors: @config.interceptors
115
+ )
116
+ end
117
+
118
+ # Service calls
119
+
120
+ ##
121
+ # Gets information about a billing account. The current authenticated user
122
+ # must be a [viewer of the billing
123
+ # account](https://cloud.google.com/billing/docs/how-to/billing-access).
124
+ #
125
+ # @overload get_billing_account(request, options = nil)
126
+ # @param request [Google::Cloud::Billing::V1::GetBillingAccountRequest | Hash]
127
+ # Gets information about a billing account. The current authenticated user
128
+ # must be a [viewer of the billing
129
+ # account](https://cloud.google.com/billing/docs/how-to/billing-access).
130
+ # @param options [Gapic::CallOptions, Hash]
131
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
132
+ #
133
+ # @overload get_billing_account(name: nil)
134
+ # @param name [String]
135
+ # Required. The resource name of the billing account to retrieve. For example,
136
+ # `billingAccounts/012345-567890-ABCDEF`.
137
+ #
138
+ #
139
+ # @yield [response, operation] Access the result along with the RPC operation
140
+ # @yieldparam response [Google::Cloud::Billing::V1::BillingAccount]
141
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
142
+ #
143
+ # @return [Google::Cloud::Billing::V1::BillingAccount]
144
+ #
145
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
146
+ #
147
+ def get_billing_account request, options = nil
148
+ raise ArgumentError, "request must be provided" if request.nil?
149
+
150
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::GetBillingAccountRequest
151
+
152
+ # Converts hash and nil to an options object
153
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
154
+
155
+ # Customize the options with defaults
156
+ metadata = @config.rpcs.get_billing_account.metadata.to_h
157
+
158
+ # Set x-goog-api-client header
159
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
160
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
161
+ gapic_version: Google::Cloud::Billing::V1::VERSION
162
+
163
+ header_params = {
164
+ "name" => request.name
165
+ }
166
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
167
+ metadata[:"x-goog-request-params"] ||= request_params_header
168
+
169
+ options.apply_defaults timeout: @config.rpcs.get_billing_account.timeout,
170
+ metadata: metadata,
171
+ retry_policy: @config.rpcs.get_billing_account.retry_policy
172
+ options.apply_defaults metadata: @config.metadata,
173
+ retry_policy: @config.retry_policy
174
+
175
+ @cloud_billing_stub.call_rpc :get_billing_account, request, options: options do |response, operation|
176
+ yield response, operation if block_given?
177
+ return response
178
+ end
179
+ rescue GRPC::BadStatus => e
180
+ raise Google::Cloud::Error.from_error(e)
181
+ end
182
+
183
+ ##
184
+ # Lists the billing accounts that the current authenticated user has
185
+ # permission to
186
+ # [view](https://cloud.google.com/billing/docs/how-to/billing-access).
187
+ #
188
+ # @overload list_billing_accounts(request, options = nil)
189
+ # @param request [Google::Cloud::Billing::V1::ListBillingAccountsRequest | Hash]
190
+ # Lists the billing accounts that the current authenticated user has
191
+ # permission to
192
+ # [view](https://cloud.google.com/billing/docs/how-to/billing-access).
193
+ # @param options [Gapic::CallOptions, Hash]
194
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
195
+ #
196
+ # @overload list_billing_accounts(page_size: nil, page_token: nil, filter: nil)
197
+ # @param page_size [Integer]
198
+ # Requested page size. The maximum page size is 100; this is also the
199
+ # default.
200
+ # @param page_token [String]
201
+ # A token identifying a page of results to return. This should be a
202
+ # `next_page_token` value returned from a previous `ListBillingAccounts`
203
+ # call. If unspecified, the first page of results is returned.
204
+ # @param filter [String]
205
+ # Options for how to filter the returned billing accounts.
206
+ # Currently this only supports filtering for
207
+ # [subaccounts](https://cloud.google.com/billing/docs/concepts) under a
208
+ # single provided reseller billing account.
209
+ # (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF").
210
+ # Boolean algebra and other fields are not currently supported.
211
+ #
212
+ #
213
+ # @yield [response, operation] Access the result along with the RPC operation
214
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Billing::V1::BillingAccount>]
215
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
216
+ #
217
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Billing::V1::BillingAccount>]
218
+ #
219
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
220
+ #
221
+ def list_billing_accounts request, options = nil
222
+ raise ArgumentError, "request must be provided" if request.nil?
223
+
224
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::ListBillingAccountsRequest
225
+
226
+ # Converts hash and nil to an options object
227
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
228
+
229
+ # Customize the options with defaults
230
+ metadata = @config.rpcs.list_billing_accounts.metadata.to_h
231
+
232
+ # Set x-goog-api-client header
233
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
234
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
235
+ gapic_version: Google::Cloud::Billing::V1::VERSION
236
+
237
+ options.apply_defaults timeout: @config.rpcs.list_billing_accounts.timeout,
238
+ metadata: metadata,
239
+ retry_policy: @config.rpcs.list_billing_accounts.retry_policy
240
+ options.apply_defaults metadata: @config.metadata,
241
+ retry_policy: @config.retry_policy
242
+
243
+ @cloud_billing_stub.call_rpc :list_billing_accounts, request, options: options do |response, operation|
244
+ response = Gapic::PagedEnumerable.new @cloud_billing_stub, :list_billing_accounts, request, response, operation, options
245
+ yield response, operation if block_given?
246
+ return response
247
+ end
248
+ rescue GRPC::BadStatus => e
249
+ raise Google::Cloud::Error.from_error(e)
250
+ end
251
+
252
+ ##
253
+ # Updates a billing account's fields.
254
+ # Currently the only field that can be edited is `display_name`.
255
+ # The current authenticated user must have the `billing.accounts.update`
256
+ # IAM permission, which is typically given to the
257
+ # [administrator](https://cloud.google.com/billing/docs/how-to/billing-access)
258
+ # of the billing account.
259
+ #
260
+ # @overload update_billing_account(request, options = nil)
261
+ # @param request [Google::Cloud::Billing::V1::UpdateBillingAccountRequest | Hash]
262
+ # Updates a billing account's fields.
263
+ # Currently the only field that can be edited is `display_name`.
264
+ # The current authenticated user must have the `billing.accounts.update`
265
+ # IAM permission, which is typically given to the
266
+ # [administrator](https://cloud.google.com/billing/docs/how-to/billing-access)
267
+ # of the billing account.
268
+ # @param options [Gapic::CallOptions, Hash]
269
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
270
+ #
271
+ # @overload update_billing_account(name: nil, account: nil, update_mask: nil)
272
+ # @param name [String]
273
+ # Required. The name of the billing account resource to be updated.
274
+ # @param account [Google::Cloud::Billing::V1::BillingAccount | Hash]
275
+ # Required. The billing account resource to replace the resource on the server.
276
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
277
+ # The update mask applied to the resource.
278
+ # Only "display_name" is currently supported.
279
+ #
280
+ #
281
+ # @yield [response, operation] Access the result along with the RPC operation
282
+ # @yieldparam response [Google::Cloud::Billing::V1::BillingAccount]
283
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
284
+ #
285
+ # @return [Google::Cloud::Billing::V1::BillingAccount]
286
+ #
287
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
288
+ #
289
+ def update_billing_account request, options = nil
290
+ raise ArgumentError, "request must be provided" if request.nil?
291
+
292
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::UpdateBillingAccountRequest
293
+
294
+ # Converts hash and nil to an options object
295
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
296
+
297
+ # Customize the options with defaults
298
+ metadata = @config.rpcs.update_billing_account.metadata.to_h
299
+
300
+ # Set x-goog-api-client header
301
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
302
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
303
+ gapic_version: Google::Cloud::Billing::V1::VERSION
304
+
305
+ header_params = {
306
+ "name" => request.name
307
+ }
308
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
309
+ metadata[:"x-goog-request-params"] ||= request_params_header
310
+
311
+ options.apply_defaults timeout: @config.rpcs.update_billing_account.timeout,
312
+ metadata: metadata,
313
+ retry_policy: @config.rpcs.update_billing_account.retry_policy
314
+ options.apply_defaults metadata: @config.metadata,
315
+ retry_policy: @config.retry_policy
316
+
317
+ @cloud_billing_stub.call_rpc :update_billing_account, request, options: options do |response, operation|
318
+ yield response, operation if block_given?
319
+ return response
320
+ end
321
+ rescue GRPC::BadStatus => e
322
+ raise Google::Cloud::Error.from_error(e)
323
+ end
324
+
325
+ ##
326
+ # Creates a billing account.
327
+ # This method can only be used to create
328
+ # [billing subaccounts](https://cloud.google.com/billing/docs/concepts)
329
+ # by GCP resellers.
330
+ # When creating a subaccount, the current authenticated user must have the
331
+ # `billing.accounts.update` IAM permission on the master account, which is
332
+ # typically given to billing account
333
+ # [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
334
+ # This method will return an error if the master account has not been
335
+ # provisioned as a reseller account.
336
+ #
337
+ # @overload create_billing_account(request, options = nil)
338
+ # @param request [Google::Cloud::Billing::V1::CreateBillingAccountRequest | Hash]
339
+ # Creates a billing account.
340
+ # This method can only be used to create
341
+ # [billing subaccounts](https://cloud.google.com/billing/docs/concepts)
342
+ # by GCP resellers.
343
+ # When creating a subaccount, the current authenticated user must have the
344
+ # `billing.accounts.update` IAM permission on the master account, which is
345
+ # typically given to billing account
346
+ # [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
347
+ # This method will return an error if the master account has not been
348
+ # provisioned as a reseller account.
349
+ # @param options [Gapic::CallOptions, Hash]
350
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
351
+ #
352
+ # @overload create_billing_account(billing_account: nil)
353
+ # @param billing_account [Google::Cloud::Billing::V1::BillingAccount | Hash]
354
+ # Required. The billing account resource to create.
355
+ # Currently CreateBillingAccount only supports subaccount creation, so
356
+ # any created billing accounts must be under a provided master billing
357
+ # account.
358
+ #
359
+ #
360
+ # @yield [response, operation] Access the result along with the RPC operation
361
+ # @yieldparam response [Google::Cloud::Billing::V1::BillingAccount]
362
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
363
+ #
364
+ # @return [Google::Cloud::Billing::V1::BillingAccount]
365
+ #
366
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
367
+ #
368
+ def create_billing_account request, options = nil
369
+ raise ArgumentError, "request must be provided" if request.nil?
370
+
371
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::CreateBillingAccountRequest
372
+
373
+ # Converts hash and nil to an options object
374
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
375
+
376
+ # Customize the options with defaults
377
+ metadata = @config.rpcs.create_billing_account.metadata.to_h
378
+
379
+ # Set x-goog-api-client header
380
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
381
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
382
+ gapic_version: Google::Cloud::Billing::V1::VERSION
383
+
384
+ options.apply_defaults timeout: @config.rpcs.create_billing_account.timeout,
385
+ metadata: metadata,
386
+ retry_policy: @config.rpcs.create_billing_account.retry_policy
387
+ options.apply_defaults metadata: @config.metadata,
388
+ retry_policy: @config.retry_policy
389
+
390
+ @cloud_billing_stub.call_rpc :create_billing_account, request, options: options do |response, operation|
391
+ yield response, operation if block_given?
392
+ return response
393
+ end
394
+ rescue GRPC::BadStatus => e
395
+ raise Google::Cloud::Error.from_error(e)
396
+ end
397
+
398
+ ##
399
+ # Lists the projects associated with a billing account. The current
400
+ # authenticated user must have the `billing.resourceAssociations.list` IAM
401
+ # permission, which is often given to billing account
402
+ # [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
403
+ #
404
+ # @overload list_project_billing_info(request, options = nil)
405
+ # @param request [Google::Cloud::Billing::V1::ListProjectBillingInfoRequest | Hash]
406
+ # Lists the projects associated with a billing account. The current
407
+ # authenticated user must have the `billing.resourceAssociations.list` IAM
408
+ # permission, which is often given to billing account
409
+ # [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
410
+ # @param options [Gapic::CallOptions, Hash]
411
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
412
+ #
413
+ # @overload list_project_billing_info(name: nil, page_size: nil, page_token: nil)
414
+ # @param name [String]
415
+ # Required. The resource name of the billing account associated with the projects that
416
+ # you want to list. For example, `billingAccounts/012345-567890-ABCDEF`.
417
+ # @param page_size [Integer]
418
+ # Requested page size. The maximum page size is 100; this is also the
419
+ # default.
420
+ # @param page_token [String]
421
+ # A token identifying a page of results to be returned. This should be a
422
+ # `next_page_token` value returned from a previous `ListProjectBillingInfo`
423
+ # call. If unspecified, the first page of results is returned.
424
+ #
425
+ #
426
+ # @yield [response, operation] Access the result along with the RPC operation
427
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Billing::V1::ProjectBillingInfo>]
428
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
429
+ #
430
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Billing::V1::ProjectBillingInfo>]
431
+ #
432
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
433
+ #
434
+ def list_project_billing_info request, options = nil
435
+ raise ArgumentError, "request must be provided" if request.nil?
436
+
437
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::ListProjectBillingInfoRequest
438
+
439
+ # Converts hash and nil to an options object
440
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
441
+
442
+ # Customize the options with defaults
443
+ metadata = @config.rpcs.list_project_billing_info.metadata.to_h
444
+
445
+ # Set x-goog-api-client header
446
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
447
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
448
+ gapic_version: Google::Cloud::Billing::V1::VERSION
449
+
450
+ header_params = {
451
+ "name" => request.name
452
+ }
453
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
454
+ metadata[:"x-goog-request-params"] ||= request_params_header
455
+
456
+ options.apply_defaults timeout: @config.rpcs.list_project_billing_info.timeout,
457
+ metadata: metadata,
458
+ retry_policy: @config.rpcs.list_project_billing_info.retry_policy
459
+ options.apply_defaults metadata: @config.metadata,
460
+ retry_policy: @config.retry_policy
461
+
462
+ @cloud_billing_stub.call_rpc :list_project_billing_info, request, options: options do |response, operation|
463
+ response = Gapic::PagedEnumerable.new @cloud_billing_stub, :list_project_billing_info, request, response, operation, options
464
+ yield response, operation if block_given?
465
+ return response
466
+ end
467
+ rescue GRPC::BadStatus => e
468
+ raise Google::Cloud::Error.from_error(e)
469
+ end
470
+
471
+ ##
472
+ # Gets the billing information for a project. The current authenticated user
473
+ # must have [permission to view the
474
+ # project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo
475
+ # ).
476
+ #
477
+ # @overload get_project_billing_info(request, options = nil)
478
+ # @param request [Google::Cloud::Billing::V1::GetProjectBillingInfoRequest | Hash]
479
+ # Gets the billing information for a project. The current authenticated user
480
+ # must have [permission to view the
481
+ # project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo
482
+ # ).
483
+ # @param options [Gapic::CallOptions, Hash]
484
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
485
+ #
486
+ # @overload get_project_billing_info(name: nil)
487
+ # @param name [String]
488
+ # Required. The resource name of the project for which billing information is
489
+ # retrieved. For example, `projects/tokyo-rain-123`.
490
+ #
491
+ #
492
+ # @yield [response, operation] Access the result along with the RPC operation
493
+ # @yieldparam response [Google::Cloud::Billing::V1::ProjectBillingInfo]
494
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
495
+ #
496
+ # @return [Google::Cloud::Billing::V1::ProjectBillingInfo]
497
+ #
498
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
499
+ #
500
+ def get_project_billing_info request, options = nil
501
+ raise ArgumentError, "request must be provided" if request.nil?
502
+
503
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::GetProjectBillingInfoRequest
504
+
505
+ # Converts hash and nil to an options object
506
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
507
+
508
+ # Customize the options with defaults
509
+ metadata = @config.rpcs.get_project_billing_info.metadata.to_h
510
+
511
+ # Set x-goog-api-client header
512
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
513
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
514
+ gapic_version: Google::Cloud::Billing::V1::VERSION
515
+
516
+ header_params = {
517
+ "name" => request.name
518
+ }
519
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
520
+ metadata[:"x-goog-request-params"] ||= request_params_header
521
+
522
+ options.apply_defaults timeout: @config.rpcs.get_project_billing_info.timeout,
523
+ metadata: metadata,
524
+ retry_policy: @config.rpcs.get_project_billing_info.retry_policy
525
+ options.apply_defaults metadata: @config.metadata,
526
+ retry_policy: @config.retry_policy
527
+
528
+ @cloud_billing_stub.call_rpc :get_project_billing_info, request, options: options do |response, operation|
529
+ yield response, operation if block_given?
530
+ return response
531
+ end
532
+ rescue GRPC::BadStatus => e
533
+ raise Google::Cloud::Error.from_error(e)
534
+ end
535
+
536
+ ##
537
+ # Sets or updates the billing account associated with a project. You specify
538
+ # the new billing account by setting the `billing_account_name` in the
539
+ # `ProjectBillingInfo` resource to the resource name of a billing account.
540
+ # Associating a project with an open billing account enables billing on the
541
+ # project and allows charges for resource usage. If the project already had a
542
+ # billing account, this method changes the billing account used for resource
543
+ # usage charges.
544
+ #
545
+ # *Note:* Incurred charges that have not yet been reported in the transaction
546
+ # history of the GCP Console might be billed to the new billing
547
+ # account, even if the charge occurred before the new billing account was
548
+ # assigned to the project.
549
+ #
550
+ # The current authenticated user must have ownership privileges for both the
551
+ # [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo
552
+ # ) and the [billing
553
+ # account](https://cloud.google.com/billing/docs/how-to/billing-access).
554
+ #
555
+ # You can disable billing on the project by setting the
556
+ # `billing_account_name` field to empty. This action disassociates the
557
+ # current billing account from the project. Any billable activity of your
558
+ # in-use services will stop, and your application could stop functioning as
559
+ # expected. Any unbilled charges to date will be billed to the previously
560
+ # associated account. The current authenticated user must be either an owner
561
+ # of the project or an owner of the billing account for the project.
562
+ #
563
+ # Note that associating a project with a *closed* billing account will have
564
+ # much the same effect as disabling billing on the project: any paid
565
+ # resources used by the project will be shut down. Thus, unless you wish to
566
+ # disable billing, you should always call this method with the name of an
567
+ # *open* billing account.
568
+ #
569
+ # @overload update_project_billing_info(request, options = nil)
570
+ # @param request [Google::Cloud::Billing::V1::UpdateProjectBillingInfoRequest | Hash]
571
+ # Sets or updates the billing account associated with a project. You specify
572
+ # the new billing account by setting the `billing_account_name` in the
573
+ # `ProjectBillingInfo` resource to the resource name of a billing account.
574
+ # Associating a project with an open billing account enables billing on the
575
+ # project and allows charges for resource usage. If the project already had a
576
+ # billing account, this method changes the billing account used for resource
577
+ # usage charges.
578
+ #
579
+ # *Note:* Incurred charges that have not yet been reported in the transaction
580
+ # history of the GCP Console might be billed to the new billing
581
+ # account, even if the charge occurred before the new billing account was
582
+ # assigned to the project.
583
+ #
584
+ # The current authenticated user must have ownership privileges for both the
585
+ # [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo
586
+ # ) and the [billing
587
+ # account](https://cloud.google.com/billing/docs/how-to/billing-access).
588
+ #
589
+ # You can disable billing on the project by setting the
590
+ # `billing_account_name` field to empty. This action disassociates the
591
+ # current billing account from the project. Any billable activity of your
592
+ # in-use services will stop, and your application could stop functioning as
593
+ # expected. Any unbilled charges to date will be billed to the previously
594
+ # associated account. The current authenticated user must be either an owner
595
+ # of the project or an owner of the billing account for the project.
596
+ #
597
+ # Note that associating a project with a *closed* billing account will have
598
+ # much the same effect as disabling billing on the project: any paid
599
+ # resources used by the project will be shut down. Thus, unless you wish to
600
+ # disable billing, you should always call this method with the name of an
601
+ # *open* billing account.
602
+ # @param options [Gapic::CallOptions, Hash]
603
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
604
+ #
605
+ # @overload update_project_billing_info(name: nil, project_billing_info: nil)
606
+ # @param name [String]
607
+ # Required. The resource name of the project associated with the billing information
608
+ # that you want to update. For example, `projects/tokyo-rain-123`.
609
+ # @param project_billing_info [Google::Cloud::Billing::V1::ProjectBillingInfo | Hash]
610
+ # The new billing information for the project. Read-only fields are ignored;
611
+ # thus, you can leave empty all fields except `billing_account_name`.
612
+ #
613
+ #
614
+ # @yield [response, operation] Access the result along with the RPC operation
615
+ # @yieldparam response [Google::Cloud::Billing::V1::ProjectBillingInfo]
616
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
617
+ #
618
+ # @return [Google::Cloud::Billing::V1::ProjectBillingInfo]
619
+ #
620
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
621
+ #
622
+ def update_project_billing_info request, options = nil
623
+ raise ArgumentError, "request must be provided" if request.nil?
624
+
625
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::UpdateProjectBillingInfoRequest
626
+
627
+ # Converts hash and nil to an options object
628
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
629
+
630
+ # Customize the options with defaults
631
+ metadata = @config.rpcs.update_project_billing_info.metadata.to_h
632
+
633
+ # Set x-goog-api-client header
634
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
635
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
636
+ gapic_version: Google::Cloud::Billing::V1::VERSION
637
+
638
+ header_params = {
639
+ "name" => request.name
640
+ }
641
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
642
+ metadata[:"x-goog-request-params"] ||= request_params_header
643
+
644
+ options.apply_defaults timeout: @config.rpcs.update_project_billing_info.timeout,
645
+ metadata: metadata,
646
+ retry_policy: @config.rpcs.update_project_billing_info.retry_policy
647
+ options.apply_defaults metadata: @config.metadata,
648
+ retry_policy: @config.retry_policy
649
+
650
+ @cloud_billing_stub.call_rpc :update_project_billing_info, request, options: options do |response, operation|
651
+ yield response, operation if block_given?
652
+ return response
653
+ end
654
+ rescue GRPC::BadStatus => e
655
+ raise Google::Cloud::Error.from_error(e)
656
+ end
657
+
658
+ ##
659
+ # Gets the access control policy for a billing account.
660
+ # The caller must have the `billing.accounts.getIamPolicy` permission on the
661
+ # account, which is often given to billing account
662
+ # [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
663
+ #
664
+ # @overload get_iam_policy(request, options = nil)
665
+ # @param request [Google::Iam::V1::GetIamPolicyRequest | Hash]
666
+ # Gets the access control policy for a billing account.
667
+ # The caller must have the `billing.accounts.getIamPolicy` permission on the
668
+ # account, which is often given to billing account
669
+ # [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
670
+ # @param options [Gapic::CallOptions, Hash]
671
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
672
+ #
673
+ # @overload get_iam_policy(resource: nil)
674
+ # @param resource [String]
675
+ # REQUIRED: The resource for which the policy is being requested.
676
+ # `resource` is usually specified as a path. For example, a Project
677
+ # resource is specified as `projects/\\\{project\}`.
678
+ #
679
+ #
680
+ # @yield [response, operation] Access the result along with the RPC operation
681
+ # @yieldparam response [Google::Iam::V1::Policy]
682
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
683
+ #
684
+ # @return [Google::Iam::V1::Policy]
685
+ #
686
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
687
+ #
688
+ def get_iam_policy request, options = nil
689
+ raise ArgumentError, "request must be provided" if request.nil?
690
+
691
+ request = Gapic::Protobuf.coerce request, to: Google::Iam::V1::GetIamPolicyRequest
692
+
693
+ # Converts hash and nil to an options object
694
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
695
+
696
+ # Customize the options with defaults
697
+ metadata = @config.rpcs.get_iam_policy.metadata.to_h
698
+
699
+ # Set x-goog-api-client header
700
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
701
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
702
+ gapic_version: Google::Cloud::Billing::V1::VERSION
703
+
704
+ header_params = {
705
+ "resource" => request.resource
706
+ }
707
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
708
+ metadata[:"x-goog-request-params"] ||= request_params_header
709
+
710
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
711
+ metadata: metadata,
712
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
713
+ options.apply_defaults metadata: @config.metadata,
714
+ retry_policy: @config.retry_policy
715
+
716
+ @cloud_billing_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
717
+ yield response, operation if block_given?
718
+ return response
719
+ end
720
+ rescue GRPC::BadStatus => e
721
+ raise Google::Cloud::Error.from_error(e)
722
+ end
723
+
724
+ ##
725
+ # Sets the access control policy for a billing account. Replaces any existing
726
+ # policy.
727
+ # The caller must have the `billing.accounts.setIamPolicy` permission on the
728
+ # account, which is often given to billing account
729
+ # [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
730
+ #
731
+ # @overload set_iam_policy(request, options = nil)
732
+ # @param request [Google::Iam::V1::SetIamPolicyRequest | Hash]
733
+ # Sets the access control policy for a billing account. Replaces any existing
734
+ # policy.
735
+ # The caller must have the `billing.accounts.setIamPolicy` permission on the
736
+ # account, which is often given to billing account
737
+ # [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
738
+ # @param options [Gapic::CallOptions, Hash]
739
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
740
+ #
741
+ # @overload set_iam_policy(resource: nil, policy: nil)
742
+ # @param resource [String]
743
+ # REQUIRED: The resource for which the policy is being specified.
744
+ # `resource` is usually specified as a path. For example, a Project
745
+ # resource is specified as `projects/\\\{project\}`.
746
+ # @param policy [Google::Iam::V1::Policy | Hash]
747
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
748
+ # the policy is limited to a few 10s of KB. An empty policy is a
749
+ # valid policy but certain Cloud Platform services (such as Projects)
750
+ # might reject them.
751
+ #
752
+ #
753
+ # @yield [response, operation] Access the result along with the RPC operation
754
+ # @yieldparam response [Google::Iam::V1::Policy]
755
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
756
+ #
757
+ # @return [Google::Iam::V1::Policy]
758
+ #
759
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
760
+ #
761
+ def set_iam_policy request, options = nil
762
+ raise ArgumentError, "request must be provided" if request.nil?
763
+
764
+ request = Gapic::Protobuf.coerce request, to: Google::Iam::V1::SetIamPolicyRequest
765
+
766
+ # Converts hash and nil to an options object
767
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
768
+
769
+ # Customize the options with defaults
770
+ metadata = @config.rpcs.set_iam_policy.metadata.to_h
771
+
772
+ # Set x-goog-api-client header
773
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
774
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
775
+ gapic_version: Google::Cloud::Billing::V1::VERSION
776
+
777
+ header_params = {
778
+ "resource" => request.resource
779
+ }
780
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
781
+ metadata[:"x-goog-request-params"] ||= request_params_header
782
+
783
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
784
+ metadata: metadata,
785
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
786
+ options.apply_defaults metadata: @config.metadata,
787
+ retry_policy: @config.retry_policy
788
+
789
+ @cloud_billing_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
790
+ yield response, operation if block_given?
791
+ return response
792
+ end
793
+ rescue GRPC::BadStatus => e
794
+ raise Google::Cloud::Error.from_error(e)
795
+ end
796
+
797
+ ##
798
+ # Tests the access control policy for a billing account. This method takes
799
+ # the resource and a set of permissions as input and returns the subset of
800
+ # the input permissions that the caller is allowed for that resource.
801
+ #
802
+ # @overload test_iam_permissions(request, options = nil)
803
+ # @param request [Google::Iam::V1::TestIamPermissionsRequest | Hash]
804
+ # Tests the access control policy for a billing account. This method takes
805
+ # the resource and a set of permissions as input and returns the subset of
806
+ # the input permissions that the caller is allowed for that resource.
807
+ # @param options [Gapic::CallOptions, Hash]
808
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
809
+ #
810
+ # @overload test_iam_permissions(resource: nil, permissions: nil)
811
+ # @param resource [String]
812
+ # REQUIRED: The resource for which the policy detail is being requested.
813
+ # `resource` is usually specified as a path. For example, a Project
814
+ # resource is specified as `projects/\\\{project\}`.
815
+ # @param permissions [Array<String>]
816
+ # The set of permissions to check for the `resource`. Permissions with
817
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
818
+ # information see
819
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
820
+ #
821
+ #
822
+ # @yield [response, operation] Access the result along with the RPC operation
823
+ # @yieldparam response [Google::Iam::V1::TestIamPermissionsResponse]
824
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
825
+ #
826
+ # @return [Google::Iam::V1::TestIamPermissionsResponse]
827
+ #
828
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
829
+ #
830
+ def test_iam_permissions request, options = nil
831
+ raise ArgumentError, "request must be provided" if request.nil?
832
+
833
+ request = Gapic::Protobuf.coerce request, to: Google::Iam::V1::TestIamPermissionsRequest
834
+
835
+ # Converts hash and nil to an options object
836
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
837
+
838
+ # Customize the options with defaults
839
+ metadata = @config.rpcs.test_iam_permissions.metadata.to_h
840
+
841
+ # Set x-goog-api-client header
842
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
843
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
844
+ gapic_version: Google::Cloud::Billing::V1::VERSION
845
+
846
+ header_params = {
847
+ "resource" => request.resource
848
+ }
849
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
850
+ metadata[:"x-goog-request-params"] ||= request_params_header
851
+
852
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
853
+ metadata: metadata,
854
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
855
+ options.apply_defaults metadata: @config.metadata,
856
+ retry_policy: @config.retry_policy
857
+
858
+ @cloud_billing_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
859
+ yield response, operation if block_given?
860
+ return response
861
+ end
862
+ rescue GRPC::BadStatus => e
863
+ raise Google::Cloud::Error.from_error(e)
864
+ end
865
+
866
+ ##
867
+ # Configuration class for the CloudBilling API.
868
+ class Configuration
869
+ extend Gapic::Config
870
+
871
+ config_attr :endpoint, "cloudbilling.googleapis.com", String
872
+ config_attr :credentials, nil do |value|
873
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
874
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
875
+ allowed.any? { |klass| klass === value }
876
+ end
877
+ config_attr :scope, nil, String, Array, nil
878
+ config_attr :lib_name, nil, String, nil
879
+ config_attr :lib_version, nil, String, nil
880
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
881
+ config_attr :interceptors, nil, Array, nil
882
+ config_attr :timeout, nil, Numeric, nil
883
+ config_attr :metadata, nil, Hash, nil
884
+ config_attr :retry_policy, nil, Hash, Proc, nil
885
+
886
+ def initialize parent_config = nil
887
+ @parent_config = parent_config unless parent_config.nil?
888
+
889
+ yield self if block_given?
890
+ end
891
+
892
+ def rpcs
893
+ @rpcs ||= begin
894
+ parent_rpcs = nil
895
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
896
+ Rpcs.new parent_rpcs
897
+ end
898
+ end
899
+
900
+ ##
901
+ # Configuration RPC class for the CloudBilling API.
902
+ class Rpcs
903
+ attr_reader :get_billing_account
904
+ attr_reader :list_billing_accounts
905
+ attr_reader :update_billing_account
906
+ attr_reader :create_billing_account
907
+ attr_reader :list_project_billing_info
908
+ attr_reader :get_project_billing_info
909
+ attr_reader :update_project_billing_info
910
+ attr_reader :get_iam_policy
911
+ attr_reader :set_iam_policy
912
+ attr_reader :test_iam_permissions
913
+
914
+ def initialize parent_rpcs = nil
915
+ get_billing_account_config = parent_rpcs&.get_billing_account if parent_rpcs&.respond_to? :get_billing_account
916
+ @get_billing_account = Gapic::Config::Method.new get_billing_account_config
917
+ list_billing_accounts_config = parent_rpcs&.list_billing_accounts if parent_rpcs&.respond_to? :list_billing_accounts
918
+ @list_billing_accounts = Gapic::Config::Method.new list_billing_accounts_config
919
+ update_billing_account_config = parent_rpcs&.update_billing_account if parent_rpcs&.respond_to? :update_billing_account
920
+ @update_billing_account = Gapic::Config::Method.new update_billing_account_config
921
+ create_billing_account_config = parent_rpcs&.create_billing_account if parent_rpcs&.respond_to? :create_billing_account
922
+ @create_billing_account = Gapic::Config::Method.new create_billing_account_config
923
+ list_project_billing_info_config = parent_rpcs&.list_project_billing_info if parent_rpcs&.respond_to? :list_project_billing_info
924
+ @list_project_billing_info = Gapic::Config::Method.new list_project_billing_info_config
925
+ get_project_billing_info_config = parent_rpcs&.get_project_billing_info if parent_rpcs&.respond_to? :get_project_billing_info
926
+ @get_project_billing_info = Gapic::Config::Method.new get_project_billing_info_config
927
+ update_project_billing_info_config = parent_rpcs&.update_project_billing_info if parent_rpcs&.respond_to? :update_project_billing_info
928
+ @update_project_billing_info = Gapic::Config::Method.new update_project_billing_info_config
929
+ get_iam_policy_config = parent_rpcs&.get_iam_policy if parent_rpcs&.respond_to? :get_iam_policy
930
+ @get_iam_policy = Gapic::Config::Method.new get_iam_policy_config
931
+ set_iam_policy_config = parent_rpcs&.set_iam_policy if parent_rpcs&.respond_to? :set_iam_policy
932
+ @set_iam_policy = Gapic::Config::Method.new set_iam_policy_config
933
+ test_iam_permissions_config = parent_rpcs&.test_iam_permissions if parent_rpcs&.respond_to? :test_iam_permissions
934
+ @test_iam_permissions = Gapic::Config::Method.new test_iam_permissions_config
935
+
936
+ yield self if block_given?
937
+ end
938
+ end
939
+ end
940
+ end
941
+ end
942
+ end
943
+ end
944
+ end
945
+ end
946
+
947
+ # rubocop:disable Lint/HandleExceptions
948
+
949
+ # Once client is loaded, load helpers.rb if it exists.
950
+ begin
951
+ require "google/cloud/billing/v1/cloud_billing/helpers"
952
+ rescue LoadError
953
+ end
954
+
955
+ # rubocop:enable Lint/HandleExceptions