google-cloud-logging-v2 0.3.1 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,59 +60,41 @@ 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
67
67
 
68
68
  default_config.rpcs.list_sinks.timeout = 60.0
69
69
  default_config.rpcs.list_sinks.retry_policy = {
70
- initial_delay: 0.1,
71
- max_delay: 60.0,
72
- multiplier: 1.3,
73
- retry_codes: [4, 13, 14]
70
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
74
71
  }
75
72
 
76
73
  default_config.rpcs.get_sink.timeout = 60.0
77
74
  default_config.rpcs.get_sink.retry_policy = {
78
- initial_delay: 0.1,
79
- max_delay: 60.0,
80
- multiplier: 1.3,
81
- retry_codes: [4, 13, 14]
75
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
82
76
  }
83
77
 
84
78
  default_config.rpcs.create_sink.timeout = 120.0
85
79
 
86
80
  default_config.rpcs.update_sink.timeout = 60.0
87
81
  default_config.rpcs.update_sink.retry_policy = {
88
- initial_delay: 0.1,
89
- max_delay: 60.0,
90
- multiplier: 1.3,
91
- retry_codes: [4, 13, 14]
82
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
92
83
  }
93
84
 
94
85
  default_config.rpcs.delete_sink.timeout = 60.0
95
86
  default_config.rpcs.delete_sink.retry_policy = {
96
- initial_delay: 0.1,
97
- max_delay: 60.0,
98
- multiplier: 1.3,
99
- retry_codes: [4, 13, 14]
87
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
100
88
  }
101
89
 
102
90
  default_config.rpcs.list_exclusions.timeout = 60.0
103
91
  default_config.rpcs.list_exclusions.retry_policy = {
104
- initial_delay: 0.1,
105
- max_delay: 60.0,
106
- multiplier: 1.3,
107
- retry_codes: [4, 13, 14]
92
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
108
93
  }
109
94
 
110
95
  default_config.rpcs.get_exclusion.timeout = 60.0
111
96
  default_config.rpcs.get_exclusion.retry_policy = {
112
- initial_delay: 0.1,
113
- max_delay: 60.0,
114
- multiplier: 1.3,
115
- retry_codes: [4, 13, 14]
97
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
116
98
  }
117
99
 
118
100
  default_config.rpcs.create_exclusion.timeout = 120.0
@@ -121,10 +103,7 @@ module Google
121
103
 
122
104
  default_config.rpcs.delete_exclusion.timeout = 60.0
123
105
  default_config.rpcs.delete_exclusion.retry_policy = {
124
- initial_delay: 0.1,
125
- max_delay: 60.0,
126
- multiplier: 1.3,
127
- retry_codes: [4, 13, 14]
106
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
128
107
  }
129
108
 
130
109
  default_config
@@ -188,8 +167,14 @@ module Google
188
167
 
189
168
  # Create credentials
190
169
  credentials = @config.credentials
191
- credentials ||= Credentials.default scope: @config.scope
192
- if credentials.is_a?(String) || credentials.is_a?(Hash)
170
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
171
+ # but only if the default endpoint does not have a region prefix.
172
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
173
+ @config.endpoint == Client.configure.endpoint &&
174
+ !@config.endpoint.split(".").first.include?("-")
175
+ credentials ||= Credentials.default scope: @config.scope,
176
+ enable_self_signed_jwt: enable_self_signed_jwt
177
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
193
178
  credentials = Credentials.new credentials, scope: @config.scope
194
179
  end
195
180
  @quota_project_id = @config.quota_project
@@ -2170,7 +2155,7 @@ module Google
2170
2155
  config_attr :scope, nil, ::String, ::Array, nil
2171
2156
  config_attr :lib_name, nil, ::String, nil
2172
2157
  config_attr :lib_version, nil, ::String, nil
2173
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
2158
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
2174
2159
  config_attr :interceptors, nil, ::Array, nil
2175
2160
  config_attr :timeout, nil, ::Numeric, nil
2176
2161
  config_attr :metadata, nil, ::Hash, nil
@@ -2191,7 +2176,7 @@ module Google
2191
2176
  def rpcs
2192
2177
  @rpcs ||= begin
2193
2178
  parent_rpcs = nil
2194
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
2179
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
2195
2180
  Rpcs.new parent_rpcs
2196
2181
  end
2197
2182
  end
@@ -2332,51 +2317,51 @@ module Google
2332
2317
 
2333
2318
  # @private
2334
2319
  def initialize parent_rpcs = nil
2335
- list_buckets_config = parent_rpcs&.list_buckets if parent_rpcs&.respond_to? :list_buckets
2320
+ list_buckets_config = parent_rpcs.list_buckets if parent_rpcs.respond_to? :list_buckets
2336
2321
  @list_buckets = ::Gapic::Config::Method.new list_buckets_config
2337
- get_bucket_config = parent_rpcs&.get_bucket if parent_rpcs&.respond_to? :get_bucket
2322
+ get_bucket_config = parent_rpcs.get_bucket if parent_rpcs.respond_to? :get_bucket
2338
2323
  @get_bucket = ::Gapic::Config::Method.new get_bucket_config
2339
- create_bucket_config = parent_rpcs&.create_bucket if parent_rpcs&.respond_to? :create_bucket
2324
+ create_bucket_config = parent_rpcs.create_bucket if parent_rpcs.respond_to? :create_bucket
2340
2325
  @create_bucket = ::Gapic::Config::Method.new create_bucket_config
2341
- update_bucket_config = parent_rpcs&.update_bucket if parent_rpcs&.respond_to? :update_bucket
2326
+ update_bucket_config = parent_rpcs.update_bucket if parent_rpcs.respond_to? :update_bucket
2342
2327
  @update_bucket = ::Gapic::Config::Method.new update_bucket_config
2343
- delete_bucket_config = parent_rpcs&.delete_bucket if parent_rpcs&.respond_to? :delete_bucket
2328
+ delete_bucket_config = parent_rpcs.delete_bucket if parent_rpcs.respond_to? :delete_bucket
2344
2329
  @delete_bucket = ::Gapic::Config::Method.new delete_bucket_config
2345
- undelete_bucket_config = parent_rpcs&.undelete_bucket if parent_rpcs&.respond_to? :undelete_bucket
2330
+ undelete_bucket_config = parent_rpcs.undelete_bucket if parent_rpcs.respond_to? :undelete_bucket
2346
2331
  @undelete_bucket = ::Gapic::Config::Method.new undelete_bucket_config
2347
- list_views_config = parent_rpcs&.list_views if parent_rpcs&.respond_to? :list_views
2332
+ list_views_config = parent_rpcs.list_views if parent_rpcs.respond_to? :list_views
2348
2333
  @list_views = ::Gapic::Config::Method.new list_views_config
2349
- get_view_config = parent_rpcs&.get_view if parent_rpcs&.respond_to? :get_view
2334
+ get_view_config = parent_rpcs.get_view if parent_rpcs.respond_to? :get_view
2350
2335
  @get_view = ::Gapic::Config::Method.new get_view_config
2351
- create_view_config = parent_rpcs&.create_view if parent_rpcs&.respond_to? :create_view
2336
+ create_view_config = parent_rpcs.create_view if parent_rpcs.respond_to? :create_view
2352
2337
  @create_view = ::Gapic::Config::Method.new create_view_config
2353
- update_view_config = parent_rpcs&.update_view if parent_rpcs&.respond_to? :update_view
2338
+ update_view_config = parent_rpcs.update_view if parent_rpcs.respond_to? :update_view
2354
2339
  @update_view = ::Gapic::Config::Method.new update_view_config
2355
- delete_view_config = parent_rpcs&.delete_view if parent_rpcs&.respond_to? :delete_view
2340
+ delete_view_config = parent_rpcs.delete_view if parent_rpcs.respond_to? :delete_view
2356
2341
  @delete_view = ::Gapic::Config::Method.new delete_view_config
2357
- list_sinks_config = parent_rpcs&.list_sinks if parent_rpcs&.respond_to? :list_sinks
2342
+ list_sinks_config = parent_rpcs.list_sinks if parent_rpcs.respond_to? :list_sinks
2358
2343
  @list_sinks = ::Gapic::Config::Method.new list_sinks_config
2359
- get_sink_config = parent_rpcs&.get_sink if parent_rpcs&.respond_to? :get_sink
2344
+ get_sink_config = parent_rpcs.get_sink if parent_rpcs.respond_to? :get_sink
2360
2345
  @get_sink = ::Gapic::Config::Method.new get_sink_config
2361
- create_sink_config = parent_rpcs&.create_sink if parent_rpcs&.respond_to? :create_sink
2346
+ create_sink_config = parent_rpcs.create_sink if parent_rpcs.respond_to? :create_sink
2362
2347
  @create_sink = ::Gapic::Config::Method.new create_sink_config
2363
- update_sink_config = parent_rpcs&.update_sink if parent_rpcs&.respond_to? :update_sink
2348
+ update_sink_config = parent_rpcs.update_sink if parent_rpcs.respond_to? :update_sink
2364
2349
  @update_sink = ::Gapic::Config::Method.new update_sink_config
2365
- delete_sink_config = parent_rpcs&.delete_sink if parent_rpcs&.respond_to? :delete_sink
2350
+ delete_sink_config = parent_rpcs.delete_sink if parent_rpcs.respond_to? :delete_sink
2366
2351
  @delete_sink = ::Gapic::Config::Method.new delete_sink_config
2367
- list_exclusions_config = parent_rpcs&.list_exclusions if parent_rpcs&.respond_to? :list_exclusions
2352
+ list_exclusions_config = parent_rpcs.list_exclusions if parent_rpcs.respond_to? :list_exclusions
2368
2353
  @list_exclusions = ::Gapic::Config::Method.new list_exclusions_config
2369
- get_exclusion_config = parent_rpcs&.get_exclusion if parent_rpcs&.respond_to? :get_exclusion
2354
+ get_exclusion_config = parent_rpcs.get_exclusion if parent_rpcs.respond_to? :get_exclusion
2370
2355
  @get_exclusion = ::Gapic::Config::Method.new get_exclusion_config
2371
- create_exclusion_config = parent_rpcs&.create_exclusion if parent_rpcs&.respond_to? :create_exclusion
2356
+ create_exclusion_config = parent_rpcs.create_exclusion if parent_rpcs.respond_to? :create_exclusion
2372
2357
  @create_exclusion = ::Gapic::Config::Method.new create_exclusion_config
2373
- update_exclusion_config = parent_rpcs&.update_exclusion if parent_rpcs&.respond_to? :update_exclusion
2358
+ update_exclusion_config = parent_rpcs.update_exclusion if parent_rpcs.respond_to? :update_exclusion
2374
2359
  @update_exclusion = ::Gapic::Config::Method.new update_exclusion_config
2375
- delete_exclusion_config = parent_rpcs&.delete_exclusion if parent_rpcs&.respond_to? :delete_exclusion
2360
+ delete_exclusion_config = parent_rpcs.delete_exclusion if parent_rpcs.respond_to? :delete_exclusion
2376
2361
  @delete_exclusion = ::Gapic::Config::Method.new delete_exclusion_config
2377
- get_cmek_settings_config = parent_rpcs&.get_cmek_settings if parent_rpcs&.respond_to? :get_cmek_settings
2362
+ get_cmek_settings_config = parent_rpcs.get_cmek_settings if parent_rpcs.respond_to? :get_cmek_settings
2378
2363
  @get_cmek_settings = ::Gapic::Config::Method.new get_cmek_settings_config
2379
- update_cmek_settings_config = parent_rpcs&.update_cmek_settings if parent_rpcs&.respond_to? :update_cmek_settings
2364
+ update_cmek_settings_config = parent_rpcs.update_cmek_settings if parent_rpcs.respond_to? :update_cmek_settings
2380
2365
  @update_cmek_settings = ::Gapic::Config::Method.new update_cmek_settings_config
2381
2366
 
2382
2367
  yield self if block_given?
@@ -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}"
@@ -405,21 +405,21 @@ module Google
405
405
  # @return [::String]
406
406
  def log_view_path **args
407
407
  resources = {
408
- "bucket:location:project:view" => (proc do |project:, location:, bucket:, view:|
408
+ "bucket:location:project:view" => (proc do |project:, location:, bucket:, view:|
409
409
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
410
410
  raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
411
411
  raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/"
412
412
 
413
413
  "projects/#{project}/locations/#{location}/buckets/#{bucket}/views/#{view}"
414
414
  end),
415
- "bucket:location:organization:view" => (proc do |organization:, location:, bucket:, view:|
415
+ "bucket:location:organization:view" => (proc do |organization:, location:, bucket:, view:|
416
416
  raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
417
417
  raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
418
418
  raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/"
419
419
 
420
420
  "organizations/#{organization}/locations/#{location}/buckets/#{bucket}/views/#{view}"
421
421
  end),
422
- "bucket:folder:location:view" => (proc do |folder:, location:, bucket:, view:|
422
+ "bucket:folder:location:view" => (proc do |folder:, location:, bucket:, view:|
423
423
  raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
424
424
  raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
425
425
  raise ::ArgumentError, "bucket cannot contain /" if bucket.to_s.include? "/"
@@ -60,57 +60,39 @@ 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
67
67
 
68
68
  default_config.rpcs.delete_log.timeout = 60.0
69
69
  default_config.rpcs.delete_log.retry_policy = {
70
- initial_delay: 0.1,
71
- max_delay: 60.0,
72
- multiplier: 1.3,
73
- retry_codes: [4, 13, 14]
70
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
74
71
  }
75
72
 
76
73
  default_config.rpcs.write_log_entries.timeout = 60.0
77
74
  default_config.rpcs.write_log_entries.retry_policy = {
78
- initial_delay: 0.1,
79
- max_delay: 60.0,
80
- multiplier: 1.3,
81
- retry_codes: [4, 13, 14]
75
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
82
76
  }
83
77
 
84
78
  default_config.rpcs.list_log_entries.timeout = 60.0
85
79
  default_config.rpcs.list_log_entries.retry_policy = {
86
- initial_delay: 0.1,
87
- max_delay: 60.0,
88
- multiplier: 1.3,
89
- retry_codes: [4, 13, 14]
80
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
90
81
  }
91
82
 
92
83
  default_config.rpcs.list_monitored_resource_descriptors.timeout = 60.0
93
84
  default_config.rpcs.list_monitored_resource_descriptors.retry_policy = {
94
- initial_delay: 0.1,
95
- max_delay: 60.0,
96
- multiplier: 1.3,
97
- retry_codes: [4, 13, 14]
85
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
98
86
  }
99
87
 
100
88
  default_config.rpcs.list_logs.timeout = 60.0
101
89
  default_config.rpcs.list_logs.retry_policy = {
102
- initial_delay: 0.1,
103
- max_delay: 60.0,
104
- multiplier: 1.3,
105
- retry_codes: [4, 13, 14]
90
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
106
91
  }
107
92
 
108
93
  default_config.rpcs.tail_log_entries.timeout = 3600.0
109
94
  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]
95
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
114
96
  }
115
97
 
116
98
  default_config
@@ -174,8 +156,14 @@ module Google
174
156
 
175
157
  # Create credentials
176
158
  credentials = @config.credentials
177
- credentials ||= Credentials.default scope: @config.scope
178
- if credentials.is_a?(String) || credentials.is_a?(Hash)
159
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
160
+ # but only if the default endpoint does not have a region prefix.
161
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
162
+ @config.endpoint == Client.configure.endpoint &&
163
+ !@config.endpoint.split(".").first.include?("-")
164
+ credentials ||= Credentials.default scope: @config.scope,
165
+ enable_self_signed_jwt: enable_self_signed_jwt
166
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
179
167
  credentials = Credentials.new credentials, scope: @config.scope
180
168
  end
181
169
  @quota_project_id = @config.quota_project
@@ -812,7 +800,7 @@ module Google
812
800
  config_attr :scope, nil, ::String, ::Array, nil
813
801
  config_attr :lib_name, nil, ::String, nil
814
802
  config_attr :lib_version, nil, ::String, nil
815
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
803
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
816
804
  config_attr :interceptors, nil, ::Array, nil
817
805
  config_attr :timeout, nil, ::Numeric, nil
818
806
  config_attr :metadata, nil, ::Hash, nil
@@ -833,7 +821,7 @@ module Google
833
821
  def rpcs
834
822
  @rpcs ||= begin
835
823
  parent_rpcs = nil
836
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
824
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
837
825
  Rpcs.new parent_rpcs
838
826
  end
839
827
  end
@@ -889,17 +877,17 @@ module Google
889
877
 
890
878
  # @private
891
879
  def initialize parent_rpcs = nil
892
- delete_log_config = parent_rpcs&.delete_log if parent_rpcs&.respond_to? :delete_log
880
+ delete_log_config = parent_rpcs.delete_log if parent_rpcs.respond_to? :delete_log
893
881
  @delete_log = ::Gapic::Config::Method.new delete_log_config
894
- write_log_entries_config = parent_rpcs&.write_log_entries if parent_rpcs&.respond_to? :write_log_entries
882
+ write_log_entries_config = parent_rpcs.write_log_entries if parent_rpcs.respond_to? :write_log_entries
895
883
  @write_log_entries = ::Gapic::Config::Method.new write_log_entries_config
896
- list_log_entries_config = parent_rpcs&.list_log_entries if parent_rpcs&.respond_to? :list_log_entries
884
+ list_log_entries_config = parent_rpcs.list_log_entries if parent_rpcs.respond_to? :list_log_entries
897
885
  @list_log_entries = ::Gapic::Config::Method.new list_log_entries_config
898
- list_monitored_resource_descriptors_config = parent_rpcs&.list_monitored_resource_descriptors if parent_rpcs&.respond_to? :list_monitored_resource_descriptors
886
+ list_monitored_resource_descriptors_config = parent_rpcs.list_monitored_resource_descriptors if parent_rpcs.respond_to? :list_monitored_resource_descriptors
899
887
  @list_monitored_resource_descriptors = ::Gapic::Config::Method.new list_monitored_resource_descriptors_config
900
- list_logs_config = parent_rpcs&.list_logs if parent_rpcs&.respond_to? :list_logs
888
+ list_logs_config = parent_rpcs.list_logs if parent_rpcs.respond_to? :list_logs
901
889
  @list_logs = ::Gapic::Config::Method.new list_logs_config
902
- tail_log_entries_config = parent_rpcs&.tail_log_entries if parent_rpcs&.respond_to? :tail_log_entries
890
+ tail_log_entries_config = parent_rpcs.tail_log_entries if parent_rpcs.respond_to? :tail_log_entries
903
891
  @tail_log_entries = ::Gapic::Config::Method.new tail_log_entries_config
904
892
 
905
893
  yield self if block_given?
@@ -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,43 +60,31 @@ 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
67
67
 
68
68
  default_config.rpcs.list_log_metrics.timeout = 60.0
69
69
  default_config.rpcs.list_log_metrics.retry_policy = {
70
- initial_delay: 0.1,
71
- max_delay: 60.0,
72
- multiplier: 1.3,
73
- retry_codes: [4, 13, 14]
70
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
74
71
  }
75
72
 
76
73
  default_config.rpcs.get_log_metric.timeout = 60.0
77
74
  default_config.rpcs.get_log_metric.retry_policy = {
78
- initial_delay: 0.1,
79
- max_delay: 60.0,
80
- multiplier: 1.3,
81
- retry_codes: [4, 13, 14]
75
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
82
76
  }
83
77
 
84
78
  default_config.rpcs.create_log_metric.timeout = 60.0
85
79
 
86
80
  default_config.rpcs.update_log_metric.timeout = 60.0
87
81
  default_config.rpcs.update_log_metric.retry_policy = {
88
- initial_delay: 0.1,
89
- max_delay: 60.0,
90
- multiplier: 1.3,
91
- retry_codes: [4, 13, 14]
82
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
92
83
  }
93
84
 
94
85
  default_config.rpcs.delete_log_metric.timeout = 60.0
95
86
  default_config.rpcs.delete_log_metric.retry_policy = {
96
- initial_delay: 0.1,
97
- max_delay: 60.0,
98
- multiplier: 1.3,
99
- retry_codes: [4, 13, 14]
87
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
100
88
  }
101
89
 
102
90
  default_config
@@ -160,8 +148,14 @@ module Google
160
148
 
161
149
  # Create credentials
162
150
  credentials = @config.credentials
163
- credentials ||= Credentials.default scope: @config.scope
164
- if credentials.is_a?(String) || credentials.is_a?(Hash)
151
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
152
+ # but only if the default endpoint does not have a region prefix.
153
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
154
+ @config.endpoint == Client.configure.endpoint &&
155
+ !@config.endpoint.split(".").first.include?("-")
156
+ credentials ||= Credentials.default scope: @config.scope,
157
+ enable_self_signed_jwt: enable_self_signed_jwt
158
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
165
159
  credentials = Credentials.new credentials, scope: @config.scope
166
160
  end
167
161
  @quota_project_id = @config.quota_project
@@ -631,7 +625,7 @@ module Google
631
625
  config_attr :scope, nil, ::String, ::Array, nil
632
626
  config_attr :lib_name, nil, ::String, nil
633
627
  config_attr :lib_version, nil, ::String, nil
634
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
628
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
635
629
  config_attr :interceptors, nil, ::Array, nil
636
630
  config_attr :timeout, nil, ::Numeric, nil
637
631
  config_attr :metadata, nil, ::Hash, nil
@@ -652,7 +646,7 @@ module Google
652
646
  def rpcs
653
647
  @rpcs ||= begin
654
648
  parent_rpcs = nil
655
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
649
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
656
650
  Rpcs.new parent_rpcs
657
651
  end
658
652
  end
@@ -703,15 +697,15 @@ module Google
703
697
 
704
698
  # @private
705
699
  def initialize parent_rpcs = nil
706
- list_log_metrics_config = parent_rpcs&.list_log_metrics if parent_rpcs&.respond_to? :list_log_metrics
700
+ list_log_metrics_config = parent_rpcs.list_log_metrics if parent_rpcs.respond_to? :list_log_metrics
707
701
  @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
702
+ get_log_metric_config = parent_rpcs.get_log_metric if parent_rpcs.respond_to? :get_log_metric
709
703
  @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
704
+ create_log_metric_config = parent_rpcs.create_log_metric if parent_rpcs.respond_to? :create_log_metric
711
705
  @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
706
+ update_log_metric_config = parent_rpcs.update_log_metric if parent_rpcs.respond_to? :update_log_metric
713
707
  @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
708
+ delete_log_metric_config = parent_rpcs.delete_log_metric if parent_rpcs.respond_to? :delete_log_metric
715
709
  @delete_log_metric = ::Gapic::Config::Method.new delete_log_metric_config
716
710
 
717
711
  yield self if block_given?