google-cloud-pubsub-v1 0.1.2 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,13 +63,12 @@ module Google
63
63
  # See {::Google::Cloud::PubSub::V1::IAMPolicy::Client::Configuration}
64
64
  # for a description of the configuration fields.
65
65
  #
66
- # ## Example
66
+ # @example
67
67
  #
68
- # To modify the configuration for all IAMPolicy clients:
69
- #
70
- # ::Google::Cloud::PubSub::V1::IAMPolicy::Client.configure do |config|
71
- # config.timeout = 10.0
72
- # end
68
+ # # Modify the configuration for all IAMPolicy clients
69
+ # ::Google::Cloud::PubSub::V1::IAMPolicy::Client.configure do |config|
70
+ # config.timeout = 10.0
71
+ # end
73
72
  #
74
73
  # @yield [config] Configure the Client client.
75
74
  # @yieldparam config [Client::Configuration]
@@ -82,7 +81,7 @@ module Google
82
81
  parent_config = while namespace.any?
83
82
  parent_name = namespace.join "::"
84
83
  parent_const = const_get parent_name
85
- break parent_const.configure if parent_const&.respond_to? :configure
84
+ break parent_const.configure if parent_const.respond_to? :configure
86
85
  namespace.pop
87
86
  end
88
87
  default_config = Client::Configuration.new parent_config
@@ -116,19 +115,15 @@ module Google
116
115
  ##
117
116
  # Create a new IAMPolicy client object.
118
117
  #
119
- # ## Examples
120
- #
121
- # To create a new IAMPolicy client with the default
122
- # configuration:
118
+ # @example
123
119
  #
124
- # client = ::Google::Cloud::PubSub::V1::IAMPolicy::Client.new
120
+ # # Create a client using the default configuration
121
+ # client = ::Google::Cloud::PubSub::V1::IAMPolicy::Client.new
125
122
  #
126
- # To create a new IAMPolicy client with a custom
127
- # configuration:
128
- #
129
- # client = ::Google::Cloud::PubSub::V1::IAMPolicy::Client.new do |config|
130
- # config.timeout = 10.0
131
- # end
123
+ # # Create a client using a custom configuration
124
+ # client = ::Google::Cloud::PubSub::V1::IAMPolicy::Client.new do |config|
125
+ # config.timeout = 10.0
126
+ # end
132
127
  #
133
128
  # @yield [config] Configure the IAMPolicy client.
134
129
  # @yieldparam config [Client::Configuration]
@@ -148,8 +143,13 @@ module Google
148
143
 
149
144
  # Create credentials
150
145
  credentials = @config.credentials
151
- credentials ||= Credentials.default scope: @config.scope
152
- if credentials.is_a?(String) || credentials.is_a?(Hash)
146
+ # Use self-signed JWT if the endpoint is unchanged from default,
147
+ # but only if the default endpoint does not have a region prefix.
148
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
149
+ !@config.endpoint.split(".").first.include?("-")
150
+ credentials ||= Credentials.default scope: @config.scope,
151
+ enable_self_signed_jwt: enable_self_signed_jwt
152
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
153
153
  credentials = Credentials.new credentials, scope: @config.scope
154
154
  end
155
155
  @quota_project_id = @config.quota_project
@@ -202,6 +202,21 @@ module Google
202
202
  #
203
203
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
204
204
  #
205
+ # @example Basic example
206
+ # require "google/iam/v1"
207
+ #
208
+ # # Create a client object. The client can be reused for multiple calls.
209
+ # client = Google::Cloud::PubSub::V1::IAMPolicy::Client.new
210
+ #
211
+ # # Create a request. To set request fields, pass in keyword arguments.
212
+ # request = Google::Iam::V1::SetIamPolicyRequest.new
213
+ #
214
+ # # Call the set_iam_policy method.
215
+ # result = client.set_iam_policy request
216
+ #
217
+ # # The returned object is of type Google::Iam::V1::Policy.
218
+ # p result
219
+ #
205
220
  def set_iam_policy request, options = nil
206
221
  raise ::ArgumentError, "request must be provided" if request.nil?
207
222
 
@@ -219,16 +234,20 @@ module Google
219
234
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
220
235
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
221
236
 
222
- header_params = {
223
- "resource" => request.resource
224
- }
237
+ header_params = {}
238
+ if request.resource
239
+ header_params["resource"] = request.resource
240
+ end
241
+
225
242
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
226
243
  metadata[:"x-goog-request-params"] ||= request_params_header
227
244
 
228
245
  options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
229
246
  metadata: metadata,
230
247
  retry_policy: @config.rpcs.set_iam_policy.retry_policy
231
- options.apply_defaults metadata: @config.metadata,
248
+
249
+ options.apply_defaults timeout: @config.timeout,
250
+ metadata: @config.metadata,
232
251
  retry_policy: @config.retry_policy
233
252
 
234
253
  @iam_policy_stub.call_rpc :set_iam_policy, request, options: options do |response, operation|
@@ -274,6 +293,21 @@ module Google
274
293
  #
275
294
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
276
295
  #
296
+ # @example Basic example
297
+ # require "google/iam/v1"
298
+ #
299
+ # # Create a client object. The client can be reused for multiple calls.
300
+ # client = Google::Cloud::PubSub::V1::IAMPolicy::Client.new
301
+ #
302
+ # # Create a request. To set request fields, pass in keyword arguments.
303
+ # request = Google::Iam::V1::GetIamPolicyRequest.new
304
+ #
305
+ # # Call the get_iam_policy method.
306
+ # result = client.get_iam_policy request
307
+ #
308
+ # # The returned object is of type Google::Iam::V1::Policy.
309
+ # p result
310
+ #
277
311
  def get_iam_policy request, options = nil
278
312
  raise ::ArgumentError, "request must be provided" if request.nil?
279
313
 
@@ -291,16 +325,20 @@ module Google
291
325
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
292
326
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
293
327
 
294
- header_params = {
295
- "resource" => request.resource
296
- }
328
+ header_params = {}
329
+ if request.resource
330
+ header_params["resource"] = request.resource
331
+ end
332
+
297
333
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
298
334
  metadata[:"x-goog-request-params"] ||= request_params_header
299
335
 
300
336
  options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
301
337
  metadata: metadata,
302
338
  retry_policy: @config.rpcs.get_iam_policy.retry_policy
303
- options.apply_defaults metadata: @config.metadata,
339
+
340
+ options.apply_defaults timeout: @config.timeout,
341
+ metadata: @config.metadata,
304
342
  retry_policy: @config.retry_policy
305
343
 
306
344
  @iam_policy_stub.call_rpc :get_iam_policy, request, options: options do |response, operation|
@@ -352,6 +390,21 @@ module Google
352
390
  #
353
391
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
354
392
  #
393
+ # @example Basic example
394
+ # require "google/iam/v1"
395
+ #
396
+ # # Create a client object. The client can be reused for multiple calls.
397
+ # client = Google::Cloud::PubSub::V1::IAMPolicy::Client.new
398
+ #
399
+ # # Create a request. To set request fields, pass in keyword arguments.
400
+ # request = Google::Iam::V1::TestIamPermissionsRequest.new
401
+ #
402
+ # # Call the test_iam_permissions method.
403
+ # result = client.test_iam_permissions request
404
+ #
405
+ # # The returned object is of type Google::Iam::V1::TestIamPermissionsResponse.
406
+ # p result
407
+ #
355
408
  def test_iam_permissions request, options = nil
356
409
  raise ::ArgumentError, "request must be provided" if request.nil?
357
410
 
@@ -369,16 +422,20 @@ module Google
369
422
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
370
423
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
371
424
 
372
- header_params = {
373
- "resource" => request.resource
374
- }
425
+ header_params = {}
426
+ if request.resource
427
+ header_params["resource"] = request.resource
428
+ end
429
+
375
430
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
376
431
  metadata[:"x-goog-request-params"] ||= request_params_header
377
432
 
378
433
  options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
379
434
  metadata: metadata,
380
435
  retry_policy: @config.rpcs.test_iam_permissions.retry_policy
381
- options.apply_defaults metadata: @config.metadata,
436
+
437
+ options.apply_defaults timeout: @config.timeout,
438
+ metadata: @config.metadata,
382
439
  retry_policy: @config.retry_policy
383
440
 
384
441
  @iam_policy_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation|
@@ -402,22 +459,21 @@ module Google
402
459
  # Configuration can be applied globally to all clients, or to a single client
403
460
  # on construction.
404
461
  #
405
- # # Examples
406
- #
407
- # To modify the global config, setting the timeout for set_iam_policy
408
- # to 20 seconds, and all remaining timeouts to 10 seconds:
409
- #
410
- # ::Google::Cloud::PubSub::V1::IAMPolicy::Client.configure do |config|
411
- # config.timeout = 10.0
412
- # config.rpcs.set_iam_policy.timeout = 20.0
413
- # end
462
+ # @example
414
463
  #
415
- # To apply the above configuration only to a new client:
464
+ # # Modify the global config, setting the timeout for
465
+ # # set_iam_policy to 20 seconds,
466
+ # # and all remaining timeouts to 10 seconds.
467
+ # ::Google::Cloud::PubSub::V1::IAMPolicy::Client.configure do |config|
468
+ # config.timeout = 10.0
469
+ # config.rpcs.set_iam_policy.timeout = 20.0
470
+ # end
416
471
  #
417
- # client = ::Google::Cloud::PubSub::V1::IAMPolicy::Client.new do |config|
418
- # config.timeout = 10.0
419
- # config.rpcs.set_iam_policy.timeout = 20.0
420
- # end
472
+ # # Apply the above configuration only to a new client.
473
+ # client = ::Google::Cloud::PubSub::V1::IAMPolicy::Client.new do |config|
474
+ # config.timeout = 10.0
475
+ # config.rpcs.set_iam_policy.timeout = 20.0
476
+ # end
421
477
  #
422
478
  # @!attribute [rw] endpoint
423
479
  # The hostname or hostname:port of the service endpoint.
@@ -481,7 +537,7 @@ module Google
481
537
  config_attr :scope, nil, ::String, ::Array, nil
482
538
  config_attr :lib_name, nil, ::String, nil
483
539
  config_attr :lib_version, nil, ::String, nil
484
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
540
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
485
541
  config_attr :interceptors, nil, ::Array, nil
486
542
  config_attr :timeout, nil, ::Numeric, nil
487
543
  config_attr :metadata, nil, ::Hash, nil
@@ -502,7 +558,7 @@ module Google
502
558
  def rpcs
503
559
  @rpcs ||= begin
504
560
  parent_rpcs = nil
505
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
561
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
506
562
  Rpcs.new parent_rpcs
507
563
  end
508
564
  end
@@ -514,7 +570,7 @@ module Google
514
570
  # Each configuration object is of type `Gapic::Config::Method` and includes
515
571
  # the following configuration fields:
516
572
  #
517
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
573
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
518
574
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
519
575
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
520
576
  # include the following keys:
@@ -543,11 +599,11 @@ module Google
543
599
 
544
600
  # @private
545
601
  def initialize parent_rpcs = nil
546
- set_iam_policy_config = parent_rpcs&.set_iam_policy if parent_rpcs&.respond_to? :set_iam_policy
602
+ set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
547
603
  @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
548
- get_iam_policy_config = parent_rpcs&.get_iam_policy if parent_rpcs&.respond_to? :get_iam_policy
604
+ get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
549
605
  @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
550
- test_iam_permissions_config = parent_rpcs&.test_iam_permissions if parent_rpcs&.respond_to? :test_iam_permissions
606
+ test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions
551
607
  @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config
552
608
 
553
609
  yield self if block_given?