google-cloud-billing-v1 0.1.1 → 0.2.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.
@@ -40,7 +40,18 @@ module Google
40
40
  attr_reader :cloud_catalog_stub
41
41
 
42
42
  ##
43
- # Configuration for the CloudCatalog Client API.
43
+ # Configure the CloudCatalog Client class.
44
+ #
45
+ # See {Google::Cloud::Billing::V1::CloudCatalog::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # ## Example
49
+ #
50
+ # To modify the configuration for all CloudCatalog clients:
51
+ #
52
+ # Google::Cloud::Billing::V1::CloudCatalog::Client.configure do |config|
53
+ # config.timeout = 10_000
54
+ # end
44
55
  #
45
56
  # @yield [config] Configure the Client client.
46
57
  # @yieldparam config [Client::Configuration]
@@ -56,7 +67,13 @@ module Google
56
67
  break parent_const.configure if parent_const&.respond_to? :configure
57
68
  namespace.pop
58
69
  end
59
- Client::Configuration.new parent_config
70
+ default_config = Client::Configuration.new parent_config
71
+
72
+ default_config.rpcs.list_services.timeout = 60.0
73
+
74
+ default_config.rpcs.list_skus.timeout = 60.0
75
+
76
+ default_config
60
77
  end
61
78
  yield @configure if block_given?
62
79
  @configure
@@ -69,6 +86,9 @@ module Google
69
86
  # but structural changes (adding new fields, etc.) are not allowed. Structural changes
70
87
  # should be made on {Client.configure}.
71
88
  #
89
+ # See {Google::Cloud::Billing::V1::CloudCatalog::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
72
92
  # @yield [config] Configure the Client client.
73
93
  # @yieldparam config [Client::Configuration]
74
94
  #
@@ -80,9 +100,23 @@ module Google
80
100
  end
81
101
 
82
102
  ##
83
- # Create a new Client client object.
103
+ # Create a new CloudCatalog client object.
84
104
  #
85
- # @yield [config] Configure the Client client.
105
+ # ## Examples
106
+ #
107
+ # To create a new CloudCatalog client with the default
108
+ # configuration:
109
+ #
110
+ # client = Google::Cloud::Billing::V1::CloudCatalog::Client.new
111
+ #
112
+ # To create a new CloudCatalog client with a custom
113
+ # configuration:
114
+ #
115
+ # client = Google::Cloud::Billing::V1::CloudCatalog::Client.new do |config|
116
+ # config.timeout = 10_000
117
+ # end
118
+ #
119
+ # @yield [config] Configure the CloudCatalog client.
86
120
  # @yieldparam config [Client::Configuration]
87
121
  #
88
122
  def initialize
@@ -104,7 +138,7 @@ module Google
104
138
  if credentials.is_a?(String) || credentials.is_a?(Hash)
105
139
  credentials = Credentials.new credentials, scope: @config.scope
106
140
  end
107
-
141
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
108
142
 
109
143
  @cloud_catalog_stub = Gapic::ServiceStub.new(
110
144
  Google::Cloud::Billing::V1::CloudCatalog::Stub,
@@ -149,15 +183,16 @@ module Google
149
183
  request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::ListServicesRequest
150
184
 
151
185
  # Converts hash and nil to an options object
152
- options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
186
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
153
187
 
154
188
  # Customize the options with defaults
155
189
  metadata = @config.rpcs.list_services.metadata.to_h
156
190
 
157
- # Set x-goog-api-client header
191
+ # Set x-goog-api-client and x-goog-user-project headers
158
192
  metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
159
193
  lib_name: @config.lib_name, lib_version: @config.lib_version,
160
194
  gapic_version: ::Google::Cloud::Billing::V1::VERSION
195
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
161
196
 
162
197
  options.apply_defaults timeout: @config.rpcs.list_services.timeout,
163
198
  metadata: metadata,
@@ -227,15 +262,16 @@ module Google
227
262
  request = Gapic::Protobuf.coerce request, to: Google::Cloud::Billing::V1::ListSkusRequest
228
263
 
229
264
  # Converts hash and nil to an options object
230
- options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
265
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
231
266
 
232
267
  # Customize the options with defaults
233
268
  metadata = @config.rpcs.list_skus.metadata.to_h
234
269
 
235
- # Set x-goog-api-client header
270
+ # Set x-goog-api-client and x-goog-user-project headers
236
271
  metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
237
272
  lib_name: @config.lib_name, lib_version: @config.lib_version,
238
273
  gapic_version: ::Google::Cloud::Billing::V1::VERSION
274
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
239
275
 
240
276
  header_params = {
241
277
  "parent" => request.parent
@@ -260,6 +296,81 @@ module Google
260
296
 
261
297
  ##
262
298
  # Configuration class for the CloudCatalog API.
299
+ #
300
+ # This class represents the configuration for CloudCatalog,
301
+ # providing control over timeouts, retry behavior, logging, transport
302
+ # parameters, and other low-level controls. Certain parameters can also be
303
+ # applied individually to specific RPCs. See
304
+ # {Google::Cloud::Billing::V1::CloudCatalog::Client::Configuration::Rpcs}
305
+ # for a list of RPCs that can be configured independently.
306
+ #
307
+ # Configuration can be applied globally to all clients, or to a single client
308
+ # on construction.
309
+ #
310
+ # # Examples
311
+ #
312
+ # To modify the global config, setting the timeout for list_services
313
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
314
+ #
315
+ # Google::Cloud::Billing::V1::CloudCatalog::Client.configure do |config|
316
+ # config.timeout = 10_000
317
+ # config.rpcs.list_services.timeout = 20_000
318
+ # end
319
+ #
320
+ # To apply the above configuration only to a new client:
321
+ #
322
+ # client = Google::Cloud::Billing::V1::CloudCatalog::Client.new do |config|
323
+ # config.timeout = 10_000
324
+ # config.rpcs.list_services.timeout = 20_000
325
+ # end
326
+ #
327
+ # @!attribute [rw] endpoint
328
+ # The hostname or hostname:port of the service endpoint.
329
+ # Defaults to `"cloudbilling.googleapis.com"`.
330
+ # @return [String]
331
+ # @!attribute [rw] credentials
332
+ # Credentials to send with calls. You may provide any of the following types:
333
+ # * (`String`) The path to a service account key file in JSON format
334
+ # * (`Hash`) A service account key as a Hash
335
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
336
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
337
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
338
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
339
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
340
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
341
+ # * (`nil`) indicating no credentials
342
+ # @return [Object]
343
+ # @!attribute [rw] scope
344
+ # The OAuth scopes
345
+ # @return [Array<String>]
346
+ # @!attribute [rw] lib_name
347
+ # The library name as recorded in instrumentation and logging
348
+ # @return [String]
349
+ # @!attribute [rw] lib_version
350
+ # The library version as recorded in instrumentation and logging
351
+ # @return [String]
352
+ # @!attribute [rw] channel_args
353
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
354
+ # `GRPC::Core::Channel` object is provided as the credential.
355
+ # @return [Hash]
356
+ # @!attribute [rw] interceptors
357
+ # An array of interceptors that are run before calls are executed.
358
+ # @return [Array<GRPC::ClientInterceptor>]
359
+ # @!attribute [rw] timeout
360
+ # The call timeout in milliseconds.
361
+ # @return [Numeric]
362
+ # @!attribute [rw] metadata
363
+ # Additional gRPC headers to be sent with the call.
364
+ # @return [Hash{Symbol=>String}]
365
+ # @!attribute [rw] retry_policy
366
+ # The retry policy. The value is a hash with the following keys:
367
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
368
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
369
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
370
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
371
+ # trigger a retry.
372
+ # @return [Hash]
373
+ #
263
374
  class Configuration
264
375
  extend Gapic::Config
265
376
 
@@ -278,12 +389,17 @@ module Google
278
389
  config_attr :metadata, nil, Hash, nil
279
390
  config_attr :retry_policy, nil, Hash, Proc, nil
280
391
 
392
+ # @private
281
393
  def initialize parent_config = nil
282
394
  @parent_config = parent_config unless parent_config.nil?
283
395
 
284
396
  yield self if block_given?
285
397
  end
286
398
 
399
+ ##
400
+ # Configurations for individual RPCs
401
+ # @return [Rpcs]
402
+ #
287
403
  def rpcs
288
404
  @rpcs ||= begin
289
405
  parent_rpcs = nil
@@ -294,10 +410,34 @@ module Google
294
410
 
295
411
  ##
296
412
  # Configuration RPC class for the CloudCatalog API.
413
+ #
414
+ # Includes fields providing the configuration for each RPC in this service.
415
+ # Each configuration object is of type `Gapic::Config::Method` and includes
416
+ # the following configuration fields:
417
+ #
418
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
419
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
420
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
421
+ # include the following keys:
422
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
423
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
424
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
425
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
426
+ # trigger a retry.
427
+ #
297
428
  class Rpcs
429
+ ##
430
+ # RPC-specific configuration for `list_services`
431
+ # @return [Gapic::Config::Method]
432
+ #
298
433
  attr_reader :list_services
434
+ ##
435
+ # RPC-specific configuration for `list_skus`
436
+ # @return [Gapic::Config::Method]
437
+ #
299
438
  attr_reader :list_skus
300
439
 
440
+ # @private
301
441
  def initialize parent_rpcs = nil
302
442
  list_services_config = parent_rpcs&.list_services if parent_rpcs&.respond_to? :list_services
303
443
  @list_services = Gapic::Config::Method.new list_services_config
@@ -21,7 +21,7 @@ module Google
21
21
  module Cloud
22
22
  module Billing
23
23
  module V1
24
- VERSION = "0.1.1"
24
+ VERSION = "0.2.0"
25
25
  end
26
26
  end
27
27
  end
@@ -27,110 +27,110 @@ module Google
27
27
  #
28
28
  # Example:
29
29
  #
30
- # message Topic \\\{
30
+ # message Topic {
31
31
  # // Indicates this message defines a resource schema.
32
- # // Declares the resource type in the format of \\\{service\}/\\\{kind\}.
33
- # // For Kubernetes resources, the format is \\\{api group\}/\\\{kind\}.
34
- # option (google.api.resource) = \\\{
32
+ # // Declares the resource type in the format of {service}/{kind}.
33
+ # // For Kubernetes resources, the format is {api group}/{kind}.
34
+ # option (google.api.resource) = {
35
35
  # type: "pubsub.googleapis.com/Topic"
36
- # name_descriptor: \\\{
37
- # pattern: "projects/\\\{project\}/topics/\\\{topic\}"
36
+ # name_descriptor: {
37
+ # pattern: "projects/{project}/topics/{topic}"
38
38
  # parent_type: "cloudresourcemanager.googleapis.com/Project"
39
- # parent_name_extractor: "projects/\\\{project\}"
40
- # \}
41
- # \};
42
- # \}
39
+ # parent_name_extractor: "projects/{project}"
40
+ # }
41
+ # };
42
+ # }
43
43
  #
44
44
  # The ResourceDescriptor Yaml config will look like:
45
45
  #
46
46
  # resources:
47
47
  # - type: "pubsub.googleapis.com/Topic"
48
48
  # name_descriptor:
49
- # - pattern: "projects/\\\{project\}/topics/\\\{topic\}"
49
+ # - pattern: "projects/\\{project}/topics/\\{topic}"
50
50
  # parent_type: "cloudresourcemanager.googleapis.com/Project"
51
- # parent_name_extractor: "projects/\\\{project\}"
51
+ # parent_name_extractor: "projects/\\{project}"
52
52
  #
53
53
  # Sometimes, resources have multiple patterns, typically because they can
54
54
  # live under multiple parents.
55
55
  #
56
56
  # Example:
57
57
  #
58
- # message LogEntry \\\{
59
- # option (google.api.resource) = \\\{
58
+ # message LogEntry {
59
+ # option (google.api.resource) = {
60
60
  # type: "logging.googleapis.com/LogEntry"
61
- # name_descriptor: \\\{
62
- # pattern: "projects/\\\{project\}/logs/\\\{log\}"
61
+ # name_descriptor: {
62
+ # pattern: "projects/{project}/logs/{log}"
63
63
  # parent_type: "cloudresourcemanager.googleapis.com/Project"
64
- # parent_name_extractor: "projects/\\\{project\}"
65
- # \}
66
- # name_descriptor: \\\{
67
- # pattern: "folders/\\\{folder\}/logs/\\\{log\}"
64
+ # parent_name_extractor: "projects/{project}"
65
+ # }
66
+ # name_descriptor: {
67
+ # pattern: "folders/{folder}/logs/{log}"
68
68
  # parent_type: "cloudresourcemanager.googleapis.com/Folder"
69
- # parent_name_extractor: "folders/\\\{folder\}"
70
- # \}
71
- # name_descriptor: \\\{
72
- # pattern: "organizations/\\\{organization\}/logs/\\\{log\}"
69
+ # parent_name_extractor: "folders/{folder}"
70
+ # }
71
+ # name_descriptor: {
72
+ # pattern: "organizations/{organization}/logs/{log}"
73
73
  # parent_type: "cloudresourcemanager.googleapis.com/Organization"
74
- # parent_name_extractor: "organizations/\\\{organization\}"
75
- # \}
76
- # name_descriptor: \\\{
77
- # pattern: "billingAccounts/\\\{billing_account\}/logs/\\\{log\}"
74
+ # parent_name_extractor: "organizations/{organization}"
75
+ # }
76
+ # name_descriptor: {
77
+ # pattern: "billingAccounts/{billing_account}/logs/{log}"
78
78
  # parent_type: "billing.googleapis.com/BillingAccount"
79
- # parent_name_extractor: "billingAccounts/\\\{billing_account\}"
80
- # \}
81
- # \};
82
- # \}
79
+ # parent_name_extractor: "billingAccounts/{billing_account}"
80
+ # }
81
+ # };
82
+ # }
83
83
  #
84
84
  # The ResourceDescriptor Yaml config will look like:
85
85
  #
86
86
  # resources:
87
87
  # - type: 'logging.googleapis.com/LogEntry'
88
88
  # name_descriptor:
89
- # - pattern: "projects/\\\{project\}/logs/\\\{log\}"
89
+ # - pattern: "projects/{project}/logs/{log}"
90
90
  # parent_type: "cloudresourcemanager.googleapis.com/Project"
91
- # parent_name_extractor: "projects/\\\{project\}"
92
- # - pattern: "folders/\\\{folder\}/logs/\\\{log\}"
91
+ # parent_name_extractor: "projects/{project}"
92
+ # - pattern: "folders/{folder}/logs/{log}"
93
93
  # parent_type: "cloudresourcemanager.googleapis.com/Folder"
94
- # parent_name_extractor: "folders/\\\{folder\}"
95
- # - pattern: "organizations/\\\{organization\}/logs/\\\{log\}"
94
+ # parent_name_extractor: "folders/{folder}"
95
+ # - pattern: "organizations/{organization}/logs/{log}"
96
96
  # parent_type: "cloudresourcemanager.googleapis.com/Organization"
97
- # parent_name_extractor: "organizations/\\\{organization\}"
98
- # - pattern: "billingAccounts/\\\{billing_account\}/logs/\\\{log\}"
97
+ # parent_name_extractor: "organizations/{organization}"
98
+ # - pattern: "billingAccounts/{billing_account}/logs/{log}"
99
99
  # parent_type: "billing.googleapis.com/BillingAccount"
100
- # parent_name_extractor: "billingAccounts/\\\{billing_account\}"
100
+ # parent_name_extractor: "billingAccounts/{billing_account}"
101
101
  #
102
102
  # For flexible resources, the resource name doesn't contain parent names, but
103
103
  # the resource itself has parents for policy evaluation.
104
104
  #
105
105
  # Example:
106
106
  #
107
- # message Shelf \\\{
108
- # option (google.api.resource) = \\\{
107
+ # message Shelf {
108
+ # option (google.api.resource) = {
109
109
  # type: "library.googleapis.com/Shelf"
110
- # name_descriptor: \\\{
111
- # pattern: "shelves/\\\{shelf\}"
110
+ # name_descriptor: {
111
+ # pattern: "shelves/{shelf}"
112
112
  # parent_type: "cloudresourcemanager.googleapis.com/Project"
113
- # \}
114
- # name_descriptor: \\\{
115
- # pattern: "shelves/\\\{shelf\}"
113
+ # }
114
+ # name_descriptor: {
115
+ # pattern: "shelves/{shelf}"
116
116
  # parent_type: "cloudresourcemanager.googleapis.com/Folder"
117
- # \}
118
- # \};
119
- # \}
117
+ # }
118
+ # };
119
+ # }
120
120
  #
121
121
  # The ResourceDescriptor Yaml config will look like:
122
122
  #
123
123
  # resources:
124
124
  # - type: 'library.googleapis.com/Shelf'
125
125
  # name_descriptor:
126
- # - pattern: "shelves/\\\{shelf\}"
126
+ # - pattern: "shelves/{shelf}"
127
127
  # parent_type: "cloudresourcemanager.googleapis.com/Project"
128
- # - pattern: "shelves/\\\{shelf\}"
128
+ # - pattern: "shelves/{shelf}"
129
129
  # parent_type: "cloudresourcemanager.googleapis.com/Folder"
130
130
  # @!attribute [rw] type
131
131
  # @return [String]
132
132
  # The resource type. It must be in the format of
133
- # \\\{service_name\}/\\\{resource_type_kind\}. The `resource_type_kind` must be
133
+ # \\{service_name}/\\{resource_type_kind}. The `resource_type_kind` must be
134
134
  # singular and must not include version numbers.
135
135
  #
136
136
  # Example: `storage.googleapis.com/Bucket`
@@ -147,14 +147,14 @@ module Google
147
147
  # The path pattern must follow the syntax, which aligns with HTTP binding
148
148
  # syntax:
149
149
  #
150
- # Template = Segment \\\{ "/" Segment \} ;
150
+ # Template = Segment { "/" Segment } ;
151
151
  # Segment = LITERAL | Variable ;
152
- # Variable = "\\\{" LITERAL "\}" ;
152
+ # Variable = "{" LITERAL "}" ;
153
153
  #
154
154
  # Examples:
155
155
  #
156
- # - "projects/\\\{project\}/topics/\\\{topic\}"
157
- # - "projects/\\\{project\}/knowledgeBases/\\\{knowledge_base\}"
156
+ # - "projects/\\{project}/topics/\\{topic}"
157
+ # - "projects/\\{project}/knowledgeBases/\\{knowledge_base}"
158
158
  #
159
159
  # The components in braces correspond to the IDs for each resource in the
160
160
  # hierarchy. It is expected that, if multiple patterns are provided,
@@ -165,26 +165,26 @@ module Google
165
165
  # Optional. The field on the resource that designates the resource name
166
166
  # field. If omitted, this is assumed to be "name".
167
167
  # @!attribute [rw] history
168
- # @return [ENUM(History)]
168
+ # @return [Google::Api::ResourceDescriptor::History]
169
169
  # Optional. The historical or future-looking state of the resource pattern.
170
170
  #
171
171
  # Example:
172
172
  #
173
173
  # // The InspectTemplate message originally only supported resource
174
174
  # // names with organization, and project was added later.
175
- # message InspectTemplate \\\{
176
- # option (google.api.resource) = \\\{
175
+ # message InspectTemplate {
176
+ # option (google.api.resource) = {
177
177
  # type: "dlp.googleapis.com/InspectTemplate"
178
178
  # pattern:
179
- # "organizations/\\\{organization\}/inspectTemplates/\\\{inspect_template\}"
180
- # pattern: "projects/\\\{project\}/inspectTemplates/\\\{inspect_template\}"
179
+ # "organizations/{organization}/inspectTemplates/{inspect_template}"
180
+ # pattern: "projects/{project}/inspectTemplates/{inspect_template}"
181
181
  # history: ORIGINALLY_SINGLE_PATTERN
182
- # \};
183
- # \}
182
+ # };
183
+ # }
184
184
  # @!attribute [rw] plural
185
185
  # @return [String]
186
186
  # The plural name used in the resource name, such as 'projects' for
187
- # the name of 'projects/\\\{project\}'. It is the same concept of the `plural`
187
+ # the name of 'projects/\\{project}'. It is the same concept of the `plural`
188
188
  # field in k8s CRD spec
189
189
  # https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
190
190
  # @!attribute [rw] singular
@@ -221,11 +221,11 @@ module Google
221
221
  #
222
222
  # Example:
223
223
  #
224
- # message Subscription \\\{
225
- # string topic = 2 [(google.api.resource_reference) = \\\{
224
+ # message Subscription {
225
+ # string topic = 2 [(google.api.resource_reference) = {
226
226
  # type: "pubsub.googleapis.com/Topic"
227
- # \}];
228
- # \}
227
+ # }];
228
+ # }
229
229
  # @!attribute [rw] child_type
230
230
  # @return [String]
231
231
  # The resource type of a child collection that the annotated field
@@ -234,11 +234,11 @@ module Google
234
234
  #
235
235
  # Example:
236
236
  #
237
- # message ListLogEntriesRequest \\\{
238
- # string parent = 1 [(google.api.resource_reference) = \\\{
237
+ # message ListLogEntriesRequest {
238
+ # string parent = 1 [(google.api.resource_reference) = {
239
239
  # child_type: "logging.googleapis.com/LogEntry"
240
- # \};
241
- # \}
240
+ # };
241
+ # }
242
242
  class ResourceReference
243
243
  include Google::Protobuf::MessageExts
244
244
  extend Google::Protobuf::MessageExts::ClassMethods