google-cloud-logging-v2 0.1.3 → 0.5.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.
@@ -89,13 +89,13 @@ module Google
89
89
  # @return [::String]
90
90
  def cmek_settings_path **args
91
91
  resources = {
92
- "project" => (proc do |project:|
92
+ "project" => (proc do |project:|
93
93
  "projects/#{project}/cmekSettings"
94
94
  end),
95
- "organization" => (proc do |organization:|
95
+ "organization" => (proc do |organization:|
96
96
  "organizations/#{organization}/cmekSettings"
97
97
  end),
98
- "folder" => (proc do |folder:|
98
+ "folder" => (proc do |folder:|
99
99
  "folders/#{folder}/cmekSettings"
100
100
  end),
101
101
  "billing_account" => (proc do |billing_account:|
@@ -198,19 +198,19 @@ module Google
198
198
  # @return [::String]
199
199
  def log_bucket_path **args
200
200
  resources = {
201
- "bucket:location:project" => (proc do |project:, location:, bucket:|
201
+ "bucket:location:project" => (proc do |project:, location:, bucket:|
202
202
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
203
203
  raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
204
204
 
205
205
  "projects/#{project}/locations/#{location}/buckets/#{bucket}"
206
206
  end),
207
- "bucket:location:organization" => (proc do |organization:, location:, bucket:|
207
+ "bucket:location:organization" => (proc do |organization:, location:, bucket:|
208
208
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
209
209
  raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
210
210
 
211
211
  "organizations/#{organization}/locations/#{location}/buckets/#{bucket}"
212
212
  end),
213
- "bucket:folder:location" => (proc do |folder:, location:, bucket:|
213
+ "bucket:folder:location" => (proc do |folder:, location:, bucket:|
214
214
  raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
215
215
  raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
216
216
 
@@ -267,17 +267,17 @@ module Google
267
267
  # @return [::String]
268
268
  def log_exclusion_path **args
269
269
  resources = {
270
- "exclusion:project" => (proc do |project:, exclusion:|
270
+ "exclusion:project" => (proc do |project:, exclusion:|
271
271
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
272
272
 
273
273
  "projects/#{project}/exclusions/#{exclusion}"
274
274
  end),
275
- "exclusion:organization" => (proc do |organization:, exclusion:|
275
+ "exclusion:organization" => (proc do |organization:, exclusion:|
276
276
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
277
277
 
278
278
  "organizations/#{organization}/exclusions/#{exclusion}"
279
279
  end),
280
- "exclusion:folder" => (proc do |folder:, exclusion:|
280
+ "exclusion:folder" => (proc do |folder:, exclusion:|
281
281
  raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
282
282
 
283
283
  "folders/#{folder}/exclusions/#{exclusion}"
@@ -332,17 +332,17 @@ module Google
332
332
  # @return [::String]
333
333
  def log_sink_path **args
334
334
  resources = {
335
- "project:sink" => (proc do |project:, sink:|
335
+ "project:sink" => (proc do |project:, sink:|
336
336
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
337
337
 
338
338
  "projects/#{project}/sinks/#{sink}"
339
339
  end),
340
- "organization:sink" => (proc do |organization:, sink:|
340
+ "organization:sink" => (proc do |organization:, sink:|
341
341
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
342
342
 
343
343
  "organizations/#{organization}/sinks/#{sink}"
344
344
  end),
345
- "folder:sink" => (proc do |folder:, sink:|
345
+ "folder:sink" => (proc do |folder:, sink:|
346
346
  raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
347
347
 
348
348
  "folders/#{folder}/sinks/#{sink}"
@@ -359,6 +359,87 @@ module Google
359
359
  resource.call(**args)
360
360
  end
361
361
 
362
+ ##
363
+ # Create a fully-qualified LogView resource string.
364
+ #
365
+ # @overload log_view_path(project:, location:, bucket:, view:)
366
+ # The resource will be in the following format:
367
+ #
368
+ # `projects/{project}/locations/{location}/buckets/{bucket}/views/{view}`
369
+ #
370
+ # @param project [String]
371
+ # @param location [String]
372
+ # @param bucket [String]
373
+ # @param view [String]
374
+ #
375
+ # @overload log_view_path(organization:, location:, bucket:, view:)
376
+ # The resource will be in the following format:
377
+ #
378
+ # `organizations/{organization}/locations/{location}/buckets/{bucket}/views/{view}`
379
+ #
380
+ # @param organization [String]
381
+ # @param location [String]
382
+ # @param bucket [String]
383
+ # @param view [String]
384
+ #
385
+ # @overload log_view_path(folder:, location:, bucket:, view:)
386
+ # The resource will be in the following format:
387
+ #
388
+ # `folders/{folder}/locations/{location}/buckets/{bucket}/views/{view}`
389
+ #
390
+ # @param folder [String]
391
+ # @param location [String]
392
+ # @param bucket [String]
393
+ # @param view [String]
394
+ #
395
+ # @overload log_view_path(billing_account:, location:, bucket:, view:)
396
+ # The resource will be in the following format:
397
+ #
398
+ # `billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/views/{view}`
399
+ #
400
+ # @param billing_account [String]
401
+ # @param location [String]
402
+ # @param bucket [String]
403
+ # @param view [String]
404
+ #
405
+ # @return [::String]
406
+ def log_view_path **args
407
+ resources = {
408
+ "bucket:location:project:view" => (proc do |project:, location:, bucket:, view:|
409
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
410
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
411
+ raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/"
412
+
413
+ "projects/#{project}/locations/#{location}/buckets/#{bucket}/views/#{view}"
414
+ end),
415
+ "bucket:location:organization:view" => (proc do |organization:, location:, bucket:, view:|
416
+ raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
417
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
418
+ raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/"
419
+
420
+ "organizations/#{organization}/locations/#{location}/buckets/#{bucket}/views/#{view}"
421
+ end),
422
+ "bucket:folder:location:view" => (proc do |folder:, location:, bucket:, view:|
423
+ raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
424
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
425
+ raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/"
426
+
427
+ "folders/#{folder}/locations/#{location}/buckets/#{bucket}/views/#{view}"
428
+ end),
429
+ "billing_account:bucket:location:view" => (proc do |billing_account:, location:, bucket:, view:|
430
+ raise ::ArgumentError, "billing_account cannot contain /" if billing_account.to_s.include? "/"
431
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
432
+ raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/"
433
+
434
+ "billingAccounts/#{billing_account}/locations/#{location}/buckets/#{bucket}/views/#{view}"
435
+ end)
436
+ }
437
+
438
+ resource = resources[args.keys.sort.join(":")]
439
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
440
+ resource.call(**args)
441
+ end
442
+
362
443
  ##
363
444
  # Create a fully-qualified Organization resource string.
364
445
  #
@@ -60,7 +60,7 @@ module Google
60
60
  parent_config = while namespace.any?
61
61
  parent_name = namespace.join "::"
62
62
  parent_const = const_get parent_name
63
- break parent_const.configure if parent_const&.respond_to? :configure
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
64
  namespace.pop
65
65
  end
66
66
  default_config = Client::Configuration.new parent_config
@@ -68,41 +68,49 @@ module Google
68
68
  default_config.rpcs.delete_log.timeout = 60.0
69
69
  default_config.rpcs.delete_log.retry_policy = {
70
70
  initial_delay: 0.1,
71
- max_delay: 60.0,
72
- multiplier: 1.3,
73
- retry_codes: [4, 13, 14]
71
+ max_delay: 60.0,
72
+ multiplier: 1.3,
73
+ retry_codes: [4, 13, 14]
74
74
  }
75
75
 
76
76
  default_config.rpcs.write_log_entries.timeout = 60.0
77
77
  default_config.rpcs.write_log_entries.retry_policy = {
78
78
  initial_delay: 0.1,
79
- max_delay: 60.0,
80
- multiplier: 1.3,
81
- retry_codes: [4, 13, 14]
79
+ max_delay: 60.0,
80
+ multiplier: 1.3,
81
+ retry_codes: [4, 13, 14]
82
82
  }
83
83
 
84
84
  default_config.rpcs.list_log_entries.timeout = 60.0
85
85
  default_config.rpcs.list_log_entries.retry_policy = {
86
86
  initial_delay: 0.1,
87
- max_delay: 60.0,
88
- multiplier: 1.3,
89
- retry_codes: [4, 13, 14]
87
+ max_delay: 60.0,
88
+ multiplier: 1.3,
89
+ retry_codes: [4, 13, 14]
90
90
  }
91
91
 
92
92
  default_config.rpcs.list_monitored_resource_descriptors.timeout = 60.0
93
93
  default_config.rpcs.list_monitored_resource_descriptors.retry_policy = {
94
94
  initial_delay: 0.1,
95
- max_delay: 60.0,
96
- multiplier: 1.3,
97
- retry_codes: [4, 13, 14]
95
+ max_delay: 60.0,
96
+ multiplier: 1.3,
97
+ retry_codes: [4, 13, 14]
98
98
  }
99
99
 
100
100
  default_config.rpcs.list_logs.timeout = 60.0
101
101
  default_config.rpcs.list_logs.retry_policy = {
102
102
  initial_delay: 0.1,
103
- max_delay: 60.0,
104
- multiplier: 1.3,
105
- retry_codes: [4, 13, 14]
103
+ max_delay: 60.0,
104
+ multiplier: 1.3,
105
+ retry_codes: [4, 13, 14]
106
+ }
107
+
108
+ default_config.rpcs.tail_log_entries.timeout = 3600.0
109
+ default_config.rpcs.tail_log_entries.retry_policy = {
110
+ initial_delay: 0.1,
111
+ max_delay: 60.0,
112
+ multiplier: 1.3,
113
+ retry_codes: [4, 13, 14]
106
114
  }
107
115
 
108
116
  default_config
@@ -166,7 +174,13 @@ module Google
166
174
 
167
175
  # Create credentials
168
176
  credentials = @config.credentials
169
- credentials ||= Credentials.default scope: @config.scope
177
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
178
+ # but only if the default endpoint does not have a region prefix.
179
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
180
+ @config.endpoint == Client.configure.endpoint &&
181
+ !@config.endpoint.split(".").first.include?("-")
182
+ credentials ||= Credentials.default scope: @config.scope,
183
+ enable_self_signed_jwt: enable_self_signed_jwt
170
184
  if credentials.is_a?(String) || credentials.is_a?(Hash)
171
185
  credentials = Credentials.new credentials, scope: @config.scope
172
186
  end
@@ -425,6 +439,11 @@ module Google
425
439
  # "billingAccounts/[BILLING_ACCOUNT_ID]"
426
440
  # "folders/[FOLDER_ID]"
427
441
  #
442
+ # May alternatively be one or more views
443
+ # projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
444
+ # organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
445
+ # billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
446
+ # folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
428
447
  #
429
448
  # Projects listed in the `project_ids` field are added to this list.
430
449
  # @param filter [::String]
@@ -575,7 +594,7 @@ module Google
575
594
  # @param options [::Gapic::CallOptions, ::Hash]
576
595
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
577
596
  #
578
- # @overload list_logs(parent: nil, page_size: nil, page_token: nil)
597
+ # @overload list_logs(parent: nil, page_size: nil, page_token: nil, resource_names: nil)
579
598
  # Pass arguments to `list_logs` via keyword arguments. Note that at
580
599
  # least one keyword argument is required. To specify no parameters, or to keep all
581
600
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -596,6 +615,18 @@ module Google
596
615
  # preceding call to this method. `pageToken` must be the value of
597
616
  # `nextPageToken` from the previous response. The values of other method
598
617
  # parameters should be identical to those in the previous call.
618
+ # @param resource_names [::Array<::String>]
619
+ # Optional. The resource name that owns the logs:
620
+ # projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
621
+ # organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
622
+ # billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
623
+ # folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
624
+ #
625
+ # To support legacy queries, it could also be:
626
+ # "projects/[PROJECT_ID]"
627
+ # "organizations/[ORGANIZATION_ID]"
628
+ # "billingAccounts/[BILLING_ACCOUNT_ID]"
629
+ # "folders/[FOLDER_ID]"
599
630
  #
600
631
  # @yield [response, operation] Access the result along with the RPC operation
601
632
  # @yieldparam response [::Google::Cloud::Logging::V2::ListLogsResponse]
@@ -642,6 +673,59 @@ module Google
642
673
  raise ::Google::Cloud::Error.from_error(e)
643
674
  end
644
675
 
676
+ ##
677
+ # Streaming read of log entries as they are ingested. Until the stream is
678
+ # terminated, it will continue reading logs.
679
+ #
680
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Logging::V2::TailLogEntriesRequest, ::Hash>]
681
+ # An enumerable of {::Google::Cloud::Logging::V2::TailLogEntriesRequest} instances.
682
+ # @param options [::Gapic::CallOptions, ::Hash]
683
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
684
+ #
685
+ # @yield [response, operation] Access the result along with the RPC operation
686
+ # @yieldparam response [::Enumerable<::Google::Cloud::Logging::V2::TailLogEntriesResponse>]
687
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
688
+ #
689
+ # @return [::Enumerable<::Google::Cloud::Logging::V2::TailLogEntriesResponse>]
690
+ #
691
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
692
+ #
693
+ def tail_log_entries request, options = nil
694
+ unless request.is_a? ::Enumerable
695
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
696
+ request = request.to_enum
697
+ end
698
+
699
+ request = request.lazy.map do |req|
700
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Logging::V2::TailLogEntriesRequest
701
+ end
702
+
703
+ # Converts hash and nil to an options object
704
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
705
+
706
+ # Customize the options with defaults
707
+ metadata = @config.rpcs.tail_log_entries.metadata.to_h
708
+
709
+ # Set x-goog-api-client and x-goog-user-project headers
710
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
711
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
712
+ gapic_version: ::Google::Cloud::Logging::V2::VERSION
713
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
714
+
715
+ options.apply_defaults timeout: @config.rpcs.tail_log_entries.timeout,
716
+ metadata: metadata,
717
+ retry_policy: @config.rpcs.tail_log_entries.retry_policy
718
+ options.apply_defaults metadata: @config.metadata,
719
+ retry_policy: @config.retry_policy
720
+
721
+ @logging_service_stub.call_rpc :tail_log_entries, request, options: options do |response, operation|
722
+ yield response, operation if block_given?
723
+ return response
724
+ end
725
+ rescue ::GRPC::BadStatus => e
726
+ raise ::Google::Cloud::Error.from_error(e)
727
+ end
728
+
645
729
  ##
646
730
  # Configuration class for the LoggingService API.
647
731
  #
@@ -734,7 +818,7 @@ module Google
734
818
  config_attr :scope, nil, ::String, ::Array, nil
735
819
  config_attr :lib_name, nil, ::String, nil
736
820
  config_attr :lib_version, nil, ::String, nil
737
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
821
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
738
822
  config_attr :interceptors, nil, ::Array, nil
739
823
  config_attr :timeout, nil, ::Numeric, nil
740
824
  config_attr :metadata, nil, ::Hash, nil
@@ -755,7 +839,7 @@ module Google
755
839
  def rpcs
756
840
  @rpcs ||= begin
757
841
  parent_rpcs = nil
758
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
842
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
759
843
  Rpcs.new parent_rpcs
760
844
  end
761
845
  end
@@ -767,7 +851,7 @@ module Google
767
851
  # Each configuration object is of type `Gapic::Config::Method` and includes
768
852
  # the following configuration fields:
769
853
  #
770
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
854
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
771
855
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
772
856
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
773
857
  # include the following keys:
@@ -803,19 +887,26 @@ module Google
803
887
  # @return [::Gapic::Config::Method]
804
888
  #
805
889
  attr_reader :list_logs
890
+ ##
891
+ # RPC-specific configuration for `tail_log_entries`
892
+ # @return [::Gapic::Config::Method]
893
+ #
894
+ attr_reader :tail_log_entries
806
895
 
807
896
  # @private
808
897
  def initialize parent_rpcs = nil
809
- delete_log_config = parent_rpcs&.delete_log if parent_rpcs&.respond_to? :delete_log
898
+ delete_log_config = parent_rpcs.delete_log if parent_rpcs.respond_to? :delete_log
810
899
  @delete_log = ::Gapic::Config::Method.new delete_log_config
811
- write_log_entries_config = parent_rpcs&.write_log_entries if parent_rpcs&.respond_to? :write_log_entries
900
+ write_log_entries_config = parent_rpcs.write_log_entries if parent_rpcs.respond_to? :write_log_entries
812
901
  @write_log_entries = ::Gapic::Config::Method.new write_log_entries_config
813
- list_log_entries_config = parent_rpcs&.list_log_entries if parent_rpcs&.respond_to? :list_log_entries
902
+ list_log_entries_config = parent_rpcs.list_log_entries if parent_rpcs.respond_to? :list_log_entries
814
903
  @list_log_entries = ::Gapic::Config::Method.new list_log_entries_config
815
- list_monitored_resource_descriptors_config = parent_rpcs&.list_monitored_resource_descriptors if parent_rpcs&.respond_to? :list_monitored_resource_descriptors
904
+ list_monitored_resource_descriptors_config = parent_rpcs.list_monitored_resource_descriptors if parent_rpcs.respond_to? :list_monitored_resource_descriptors
816
905
  @list_monitored_resource_descriptors = ::Gapic::Config::Method.new list_monitored_resource_descriptors_config
817
- list_logs_config = parent_rpcs&.list_logs if parent_rpcs&.respond_to? :list_logs
906
+ list_logs_config = parent_rpcs.list_logs if parent_rpcs.respond_to? :list_logs
818
907
  @list_logs = ::Gapic::Config::Method.new list_logs_config
908
+ tail_log_entries_config = parent_rpcs.tail_log_entries if parent_rpcs.respond_to? :tail_log_entries
909
+ @tail_log_entries = ::Gapic::Config::Method.new tail_log_entries_config
819
910
 
820
911
  yield self if block_given?
821
912
  end
@@ -90,17 +90,17 @@ module Google
90
90
  # @return [::String]
91
91
  def log_path **args
92
92
  resources = {
93
- "log:project" => (proc do |project:, log:|
93
+ "log:project" => (proc do |project:, log:|
94
94
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
95
95
 
96
96
  "projects/#{project}/logs/#{log}"
97
97
  end),
98
- "log:organization" => (proc do |organization:, log:|
98
+ "log:organization" => (proc do |organization:, log:|
99
99
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
100
100
 
101
101
  "organizations/#{organization}/logs/#{log}"
102
102
  end),
103
- "folder:log" => (proc do |folder:, log:|
103
+ "folder:log" => (proc do |folder:, log:|
104
104
  raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
105
105
 
106
106
  "folders/#{folder}/logs/#{log}"
@@ -60,7 +60,7 @@ module Google
60
60
  parent_config = while namespace.any?
61
61
  parent_name = namespace.join "::"
62
62
  parent_const = const_get parent_name
63
- break parent_const.configure if parent_const&.respond_to? :configure
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
64
  namespace.pop
65
65
  end
66
66
  default_config = Client::Configuration.new parent_config
@@ -68,17 +68,17 @@ module Google
68
68
  default_config.rpcs.list_log_metrics.timeout = 60.0
69
69
  default_config.rpcs.list_log_metrics.retry_policy = {
70
70
  initial_delay: 0.1,
71
- max_delay: 60.0,
72
- multiplier: 1.3,
73
- retry_codes: [4, 13, 14]
71
+ max_delay: 60.0,
72
+ multiplier: 1.3,
73
+ retry_codes: [4, 13, 14]
74
74
  }
75
75
 
76
76
  default_config.rpcs.get_log_metric.timeout = 60.0
77
77
  default_config.rpcs.get_log_metric.retry_policy = {
78
78
  initial_delay: 0.1,
79
- max_delay: 60.0,
80
- multiplier: 1.3,
81
- retry_codes: [4, 13, 14]
79
+ max_delay: 60.0,
80
+ multiplier: 1.3,
81
+ retry_codes: [4, 13, 14]
82
82
  }
83
83
 
84
84
  default_config.rpcs.create_log_metric.timeout = 60.0
@@ -86,17 +86,17 @@ module Google
86
86
  default_config.rpcs.update_log_metric.timeout = 60.0
87
87
  default_config.rpcs.update_log_metric.retry_policy = {
88
88
  initial_delay: 0.1,
89
- max_delay: 60.0,
90
- multiplier: 1.3,
91
- retry_codes: [4, 13, 14]
89
+ max_delay: 60.0,
90
+ multiplier: 1.3,
91
+ retry_codes: [4, 13, 14]
92
92
  }
93
93
 
94
94
  default_config.rpcs.delete_log_metric.timeout = 60.0
95
95
  default_config.rpcs.delete_log_metric.retry_policy = {
96
96
  initial_delay: 0.1,
97
- max_delay: 60.0,
98
- multiplier: 1.3,
99
- retry_codes: [4, 13, 14]
97
+ max_delay: 60.0,
98
+ multiplier: 1.3,
99
+ retry_codes: [4, 13, 14]
100
100
  }
101
101
 
102
102
  default_config
@@ -160,7 +160,13 @@ module Google
160
160
 
161
161
  # Create credentials
162
162
  credentials = @config.credentials
163
- credentials ||= Credentials.default scope: @config.scope
163
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
164
+ # but only if the default endpoint does not have a region prefix.
165
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
166
+ @config.endpoint == Client.configure.endpoint &&
167
+ !@config.endpoint.split(".").first.include?("-")
168
+ credentials ||= Credentials.default scope: @config.scope,
169
+ enable_self_signed_jwt: enable_self_signed_jwt
164
170
  if credentials.is_a?(String) || credentials.is_a?(Hash)
165
171
  credentials = Credentials.new credentials, scope: @config.scope
166
172
  end
@@ -631,7 +637,7 @@ module Google
631
637
  config_attr :scope, nil, ::String, ::Array, nil
632
638
  config_attr :lib_name, nil, ::String, nil
633
639
  config_attr :lib_version, nil, ::String, nil
634
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
640
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
635
641
  config_attr :interceptors, nil, ::Array, nil
636
642
  config_attr :timeout, nil, ::Numeric, nil
637
643
  config_attr :metadata, nil, ::Hash, nil
@@ -652,7 +658,7 @@ module Google
652
658
  def rpcs
653
659
  @rpcs ||= begin
654
660
  parent_rpcs = nil
655
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
661
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
656
662
  Rpcs.new parent_rpcs
657
663
  end
658
664
  end
@@ -664,7 +670,7 @@ module Google
664
670
  # Each configuration object is of type `Gapic::Config::Method` and includes
665
671
  # the following configuration fields:
666
672
  #
667
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
673
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
668
674
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
669
675
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
670
676
  # include the following keys:
@@ -703,15 +709,15 @@ module Google
703
709
 
704
710
  # @private
705
711
  def initialize parent_rpcs = nil
706
- list_log_metrics_config = parent_rpcs&.list_log_metrics if parent_rpcs&.respond_to? :list_log_metrics
712
+ list_log_metrics_config = parent_rpcs.list_log_metrics if parent_rpcs.respond_to? :list_log_metrics
707
713
  @list_log_metrics = ::Gapic::Config::Method.new list_log_metrics_config
708
- get_log_metric_config = parent_rpcs&.get_log_metric if parent_rpcs&.respond_to? :get_log_metric
714
+ get_log_metric_config = parent_rpcs.get_log_metric if parent_rpcs.respond_to? :get_log_metric
709
715
  @get_log_metric = ::Gapic::Config::Method.new get_log_metric_config
710
- create_log_metric_config = parent_rpcs&.create_log_metric if parent_rpcs&.respond_to? :create_log_metric
716
+ create_log_metric_config = parent_rpcs.create_log_metric if parent_rpcs.respond_to? :create_log_metric
711
717
  @create_log_metric = ::Gapic::Config::Method.new create_log_metric_config
712
- update_log_metric_config = parent_rpcs&.update_log_metric if parent_rpcs&.respond_to? :update_log_metric
718
+ update_log_metric_config = parent_rpcs.update_log_metric if parent_rpcs.respond_to? :update_log_metric
713
719
  @update_log_metric = ::Gapic::Config::Method.new update_log_metric_config
714
- delete_log_metric_config = parent_rpcs&.delete_log_metric if parent_rpcs&.respond_to? :delete_log_metric
720
+ delete_log_metric_config = parent_rpcs.delete_log_metric if parent_rpcs.respond_to? :delete_log_metric
715
721
  @delete_log_metric = ::Gapic::Config::Method.new delete_log_metric_config
716
722
 
717
723
  yield self if block_given?