google-cloud-monitoring 0.28.0 → 0.29.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.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/README.md +38 -12
- data/lib/google/cloud/monitoring.rb +52 -2
- data/lib/google/cloud/monitoring/v3.rb +124 -52
- data/lib/google/cloud/monitoring/v3/alert_policy_service_client.rb +67 -29
- data/lib/google/cloud/monitoring/v3/credentials.rb +43 -0
- data/lib/google/cloud/monitoring/v3/doc/google/api/metric.rb +7 -11
- data/lib/google/cloud/monitoring/v3/doc/google/api/monitored_resource.rb +27 -3
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/alert.rb +7 -8
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/alert_service.rb +135 -0
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/group_service.rb +145 -0
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/metric.rb +17 -12
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/metric_service.rb +227 -0
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/notification_service.rb +213 -0
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/uptime.rb +49 -29
- data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/uptime_service.rb +131 -0
- data/lib/google/cloud/monitoring/v3/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/monitoring/v3/doc/google/protobuf/empty.rb +28 -0
- data/lib/google/cloud/monitoring/v3/doc/google/protobuf/struct.rb +73 -0
- data/lib/google/cloud/monitoring/v3/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/monitoring/v3/doc/overview.rb +26 -1
- data/lib/google/cloud/monitoring/v3/group_service_client.rb +78 -35
- data/lib/google/cloud/monitoring/v3/metric_service_client.rb +99 -47
- data/lib/google/cloud/monitoring/v3/notification_channel_service_client.rb +87 -39
- data/lib/google/cloud/monitoring/v3/uptime_check_service_client.rb +90 -47
- data/lib/google/monitoring/v3/alert_service_services_pb.rb +1 -1
- data/lib/google/monitoring/v3/dropped_labels_pb.rb +19 -0
- data/lib/google/monitoring/v3/group_service_services_pb.rb +2 -2
- data/lib/google/monitoring/v3/metric_pb.rb +3 -0
- data/lib/google/monitoring/v3/metric_service_pb.rb +2 -0
- data/lib/google/monitoring/v3/metric_service_services_pb.rb +1 -1
- data/lib/google/monitoring/v3/notification_service_services_pb.rb +1 -1
- data/lib/google/monitoring/v3/span_context_pb.rb +18 -0
- data/lib/google/monitoring/v3/uptime_pb.rb +10 -9
- data/lib/google/monitoring/v3/uptime_service_pb.rb +1 -0
- data/lib/google/monitoring/v3/uptime_service_services_pb.rb +1 -1
- metadata +59 -6
- data/lib/google/cloud/monitoring/credentials.rb +0 -33
@@ -25,7 +25,7 @@ require "pathname"
|
|
25
25
|
require "google/gax"
|
26
26
|
|
27
27
|
require "google/monitoring/v3/metric_service_pb"
|
28
|
-
require "google/cloud/monitoring/credentials"
|
28
|
+
require "google/cloud/monitoring/v3/credentials"
|
29
29
|
|
30
30
|
module Google
|
31
31
|
module Cloud
|
@@ -45,6 +45,9 @@ module Google
|
|
45
45
|
# The default port of the service.
|
46
46
|
DEFAULT_SERVICE_PORT = 443
|
47
47
|
|
48
|
+
# The default set of gRPC interceptors.
|
49
|
+
GRPC_INTERCEPTORS = []
|
50
|
+
|
48
51
|
DEFAULT_TIMEOUT = 30
|
49
52
|
|
50
53
|
PAGE_DESCRIPTORS = {
|
@@ -147,11 +150,18 @@ module Google
|
|
147
150
|
# or the specified config is missing data points.
|
148
151
|
# @param timeout [Numeric]
|
149
152
|
# The default timeout, in seconds, for calls made through this client.
|
153
|
+
# @param metadata [Hash]
|
154
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
155
|
+
# @param exception_transformer [Proc]
|
156
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
157
|
+
# custom error handling.
|
150
158
|
def initialize \
|
151
159
|
credentials: nil,
|
152
160
|
scopes: ALL_SCOPES,
|
153
161
|
client_config: {},
|
154
162
|
timeout: DEFAULT_TIMEOUT,
|
163
|
+
metadata: nil,
|
164
|
+
exception_transformer: nil,
|
155
165
|
lib_name: nil,
|
156
166
|
lib_version: ""
|
157
167
|
# These require statements are intentionally placed here to initialize
|
@@ -160,10 +170,10 @@ module Google
|
|
160
170
|
require "google/gax/grpc"
|
161
171
|
require "google/monitoring/v3/metric_service_services_pb"
|
162
172
|
|
163
|
-
credentials ||= Google::Cloud::Monitoring::Credentials.default
|
173
|
+
credentials ||= Google::Cloud::Monitoring::V3::Credentials.default
|
164
174
|
|
165
175
|
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
166
|
-
updater_proc = Google::Cloud::Monitoring::Credentials.new(credentials).updater_proc
|
176
|
+
updater_proc = Google::Cloud::Monitoring::V3::Credentials.new(credentials).updater_proc
|
167
177
|
end
|
168
178
|
if credentials.is_a?(GRPC::Core::Channel)
|
169
179
|
channel = credentials
|
@@ -187,6 +197,7 @@ module Google
|
|
187
197
|
google_api_client.freeze
|
188
198
|
|
189
199
|
headers = { :"x-goog-api-client" => google_api_client }
|
200
|
+
headers.merge!(metadata) unless metadata.nil?
|
190
201
|
client_config_file = Pathname.new(__dir__).join(
|
191
202
|
"metric_service_client_config.json"
|
192
203
|
)
|
@@ -199,13 +210,14 @@ module Google
|
|
199
210
|
timeout,
|
200
211
|
page_descriptors: PAGE_DESCRIPTORS,
|
201
212
|
errors: Google::Gax::Grpc::API_ERRORS,
|
202
|
-
|
213
|
+
metadata: headers
|
203
214
|
)
|
204
215
|
end
|
205
216
|
|
206
217
|
# Allow overriding the service path/port in subclasses.
|
207
218
|
service_path = self.class::SERVICE_ADDRESS
|
208
219
|
port = self.class::DEFAULT_SERVICE_PORT
|
220
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
209
221
|
@metric_service_stub = Google::Gax::Grpc.create_stub(
|
210
222
|
service_path,
|
211
223
|
port,
|
@@ -213,40 +225,49 @@ module Google
|
|
213
225
|
channel: channel,
|
214
226
|
updater_proc: updater_proc,
|
215
227
|
scopes: scopes,
|
228
|
+
interceptors: interceptors,
|
216
229
|
&Google::Monitoring::V3::MetricService::Stub.method(:new)
|
217
230
|
)
|
218
231
|
|
219
232
|
@list_monitored_resource_descriptors = Google::Gax.create_api_call(
|
220
233
|
@metric_service_stub.method(:list_monitored_resource_descriptors),
|
221
|
-
defaults["list_monitored_resource_descriptors"]
|
234
|
+
defaults["list_monitored_resource_descriptors"],
|
235
|
+
exception_transformer: exception_transformer
|
222
236
|
)
|
223
237
|
@get_monitored_resource_descriptor = Google::Gax.create_api_call(
|
224
238
|
@metric_service_stub.method(:get_monitored_resource_descriptor),
|
225
|
-
defaults["get_monitored_resource_descriptor"]
|
239
|
+
defaults["get_monitored_resource_descriptor"],
|
240
|
+
exception_transformer: exception_transformer
|
226
241
|
)
|
227
242
|
@list_metric_descriptors = Google::Gax.create_api_call(
|
228
243
|
@metric_service_stub.method(:list_metric_descriptors),
|
229
|
-
defaults["list_metric_descriptors"]
|
244
|
+
defaults["list_metric_descriptors"],
|
245
|
+
exception_transformer: exception_transformer
|
230
246
|
)
|
231
247
|
@get_metric_descriptor = Google::Gax.create_api_call(
|
232
248
|
@metric_service_stub.method(:get_metric_descriptor),
|
233
|
-
defaults["get_metric_descriptor"]
|
249
|
+
defaults["get_metric_descriptor"],
|
250
|
+
exception_transformer: exception_transformer
|
234
251
|
)
|
235
252
|
@create_metric_descriptor = Google::Gax.create_api_call(
|
236
253
|
@metric_service_stub.method(:create_metric_descriptor),
|
237
|
-
defaults["create_metric_descriptor"]
|
254
|
+
defaults["create_metric_descriptor"],
|
255
|
+
exception_transformer: exception_transformer
|
238
256
|
)
|
239
257
|
@delete_metric_descriptor = Google::Gax.create_api_call(
|
240
258
|
@metric_service_stub.method(:delete_metric_descriptor),
|
241
|
-
defaults["delete_metric_descriptor"]
|
259
|
+
defaults["delete_metric_descriptor"],
|
260
|
+
exception_transformer: exception_transformer
|
242
261
|
)
|
243
262
|
@list_time_series = Google::Gax.create_api_call(
|
244
263
|
@metric_service_stub.method(:list_time_series),
|
245
|
-
defaults["list_time_series"]
|
264
|
+
defaults["list_time_series"],
|
265
|
+
exception_transformer: exception_transformer
|
246
266
|
)
|
247
267
|
@create_time_series = Google::Gax.create_api_call(
|
248
268
|
@metric_service_stub.method(:create_time_series),
|
249
|
-
defaults["create_time_series"]
|
269
|
+
defaults["create_time_series"],
|
270
|
+
exception_transformer: exception_transformer
|
250
271
|
)
|
251
272
|
end
|
252
273
|
|
@@ -274,6 +295,9 @@ module Google
|
|
274
295
|
# @param options [Google::Gax::CallOptions]
|
275
296
|
# Overrides the default settings for this call, e.g, timeout,
|
276
297
|
# retries, etc.
|
298
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
299
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>]
|
300
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
277
301
|
# @return [Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>]
|
278
302
|
# An enumerable of Google::Api::MonitoredResourceDescriptor instances.
|
279
303
|
# See Google::Gax::PagedEnumerable documentation for other
|
@@ -281,9 +305,9 @@ module Google
|
|
281
305
|
# object.
|
282
306
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
283
307
|
# @example
|
284
|
-
# require "google/cloud/monitoring
|
308
|
+
# require "google/cloud/monitoring"
|
285
309
|
#
|
286
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
310
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
287
311
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
|
288
312
|
#
|
289
313
|
# # Iterate over all results.
|
@@ -303,14 +327,15 @@ module Google
|
|
303
327
|
name,
|
304
328
|
filter: nil,
|
305
329
|
page_size: nil,
|
306
|
-
options: nil
|
330
|
+
options: nil,
|
331
|
+
&block
|
307
332
|
req = {
|
308
333
|
name: name,
|
309
334
|
filter: filter,
|
310
335
|
page_size: page_size
|
311
336
|
}.delete_if { |_, v| v.nil? }
|
312
337
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListMonitoredResourceDescriptorsRequest)
|
313
|
-
@list_monitored_resource_descriptors.call(req, options)
|
338
|
+
@list_monitored_resource_descriptors.call(req, options, &block)
|
314
339
|
end
|
315
340
|
|
316
341
|
# Gets a single monitored resource descriptor. This method does not require a Stackdriver account.
|
@@ -323,23 +348,27 @@ module Google
|
|
323
348
|
# @param options [Google::Gax::CallOptions]
|
324
349
|
# Overrides the default settings for this call, e.g, timeout,
|
325
350
|
# retries, etc.
|
351
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
352
|
+
# @yieldparam result [Google::Api::MonitoredResourceDescriptor]
|
353
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
326
354
|
# @return [Google::Api::MonitoredResourceDescriptor]
|
327
355
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
328
356
|
# @example
|
329
|
-
# require "google/cloud/monitoring
|
357
|
+
# require "google/cloud/monitoring"
|
330
358
|
#
|
331
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
359
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
332
360
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.monitored_resource_descriptor_path("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]")
|
333
361
|
# response = metric_service_client.get_monitored_resource_descriptor(formatted_name)
|
334
362
|
|
335
363
|
def get_monitored_resource_descriptor \
|
336
364
|
name,
|
337
|
-
options: nil
|
365
|
+
options: nil,
|
366
|
+
&block
|
338
367
|
req = {
|
339
368
|
name: name
|
340
369
|
}.delete_if { |_, v| v.nil? }
|
341
370
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetMonitoredResourceDescriptorRequest)
|
342
|
-
@get_monitored_resource_descriptor.call(req, options)
|
371
|
+
@get_monitored_resource_descriptor.call(req, options, &block)
|
343
372
|
end
|
344
373
|
|
345
374
|
# Lists metric descriptors that match a filter. This method does not require a Stackdriver account.
|
@@ -365,6 +394,9 @@ module Google
|
|
365
394
|
# @param options [Google::Gax::CallOptions]
|
366
395
|
# Overrides the default settings for this call, e.g, timeout,
|
367
396
|
# retries, etc.
|
397
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
398
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Api::MetricDescriptor>]
|
399
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
368
400
|
# @return [Google::Gax::PagedEnumerable<Google::Api::MetricDescriptor>]
|
369
401
|
# An enumerable of Google::Api::MetricDescriptor instances.
|
370
402
|
# See Google::Gax::PagedEnumerable documentation for other
|
@@ -372,9 +404,9 @@ module Google
|
|
372
404
|
# object.
|
373
405
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
374
406
|
# @example
|
375
|
-
# require "google/cloud/monitoring
|
407
|
+
# require "google/cloud/monitoring"
|
376
408
|
#
|
377
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
409
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
378
410
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
|
379
411
|
#
|
380
412
|
# # Iterate over all results.
|
@@ -394,14 +426,15 @@ module Google
|
|
394
426
|
name,
|
395
427
|
filter: nil,
|
396
428
|
page_size: nil,
|
397
|
-
options: nil
|
429
|
+
options: nil,
|
430
|
+
&block
|
398
431
|
req = {
|
399
432
|
name: name,
|
400
433
|
filter: filter,
|
401
434
|
page_size: page_size
|
402
435
|
}.delete_if { |_, v| v.nil? }
|
403
436
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListMetricDescriptorsRequest)
|
404
|
-
@list_metric_descriptors.call(req, options)
|
437
|
+
@list_metric_descriptors.call(req, options, &block)
|
405
438
|
end
|
406
439
|
|
407
440
|
# Gets a single metric descriptor. This method does not require a Stackdriver account.
|
@@ -414,23 +447,27 @@ module Google
|
|
414
447
|
# @param options [Google::Gax::CallOptions]
|
415
448
|
# Overrides the default settings for this call, e.g, timeout,
|
416
449
|
# retries, etc.
|
450
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
451
|
+
# @yieldparam result [Google::Api::MetricDescriptor]
|
452
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
417
453
|
# @return [Google::Api::MetricDescriptor]
|
418
454
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
419
455
|
# @example
|
420
|
-
# require "google/cloud/monitoring
|
456
|
+
# require "google/cloud/monitoring"
|
421
457
|
#
|
422
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
458
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
423
459
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.metric_descriptor_path("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
424
460
|
# response = metric_service_client.get_metric_descriptor(formatted_name)
|
425
461
|
|
426
462
|
def get_metric_descriptor \
|
427
463
|
name,
|
428
|
-
options: nil
|
464
|
+
options: nil,
|
465
|
+
&block
|
429
466
|
req = {
|
430
467
|
name: name
|
431
468
|
}.delete_if { |_, v| v.nil? }
|
432
469
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetMetricDescriptorRequest)
|
433
|
-
@get_metric_descriptor.call(req, options)
|
470
|
+
@get_metric_descriptor.call(req, options, &block)
|
434
471
|
end
|
435
472
|
|
436
473
|
# Creates a new metric descriptor.
|
@@ -448,12 +485,15 @@ module Google
|
|
448
485
|
# @param options [Google::Gax::CallOptions]
|
449
486
|
# Overrides the default settings for this call, e.g, timeout,
|
450
487
|
# retries, etc.
|
488
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
489
|
+
# @yieldparam result [Google::Api::MetricDescriptor]
|
490
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
451
491
|
# @return [Google::Api::MetricDescriptor]
|
452
492
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
453
493
|
# @example
|
454
|
-
# require "google/cloud/monitoring
|
494
|
+
# require "google/cloud/monitoring"
|
455
495
|
#
|
456
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
496
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
457
497
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
|
458
498
|
#
|
459
499
|
# # TODO: Initialize +metric_descriptor+:
|
@@ -463,13 +503,14 @@ module Google
|
|
463
503
|
def create_metric_descriptor \
|
464
504
|
name,
|
465
505
|
metric_descriptor,
|
466
|
-
options: nil
|
506
|
+
options: nil,
|
507
|
+
&block
|
467
508
|
req = {
|
468
509
|
name: name,
|
469
510
|
metric_descriptor: metric_descriptor
|
470
511
|
}.delete_if { |_, v| v.nil? }
|
471
512
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateMetricDescriptorRequest)
|
472
|
-
@create_metric_descriptor.call(req, options)
|
513
|
+
@create_metric_descriptor.call(req, options, &block)
|
473
514
|
end
|
474
515
|
|
475
516
|
# Deletes a metric descriptor. Only user-created
|
@@ -483,22 +524,26 @@ module Google
|
|
483
524
|
# @param options [Google::Gax::CallOptions]
|
484
525
|
# Overrides the default settings for this call, e.g, timeout,
|
485
526
|
# retries, etc.
|
527
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
528
|
+
# @yieldparam result []
|
529
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
486
530
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
487
531
|
# @example
|
488
|
-
# require "google/cloud/monitoring
|
532
|
+
# require "google/cloud/monitoring"
|
489
533
|
#
|
490
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
534
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
491
535
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.metric_descriptor_path("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
492
536
|
# metric_service_client.delete_metric_descriptor(formatted_name)
|
493
537
|
|
494
538
|
def delete_metric_descriptor \
|
495
539
|
name,
|
496
|
-
options: nil
|
540
|
+
options: nil,
|
541
|
+
&block
|
497
542
|
req = {
|
498
543
|
name: name
|
499
544
|
}.delete_if { |_, v| v.nil? }
|
500
545
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::DeleteMetricDescriptorRequest)
|
501
|
-
@delete_metric_descriptor.call(req, options)
|
546
|
+
@delete_metric_descriptor.call(req, options, &block)
|
502
547
|
nil
|
503
548
|
end
|
504
549
|
|
@@ -530,9 +575,8 @@ module Google
|
|
530
575
|
# A hash of the same form as `Google::Monitoring::V3::Aggregation`
|
531
576
|
# can also be provided.
|
532
577
|
# @param order_by [String]
|
533
|
-
#
|
534
|
-
#
|
535
|
-
# this field must be left blank.
|
578
|
+
# Unsupported: must be left blank. The points in each time series are
|
579
|
+
# returned in reverse time order.
|
536
580
|
# @param page_size [Integer]
|
537
581
|
# The maximum number of resources contained in the underlying API
|
538
582
|
# response. If page streaming is performed per-resource, this
|
@@ -542,6 +586,9 @@ module Google
|
|
542
586
|
# @param options [Google::Gax::CallOptions]
|
543
587
|
# Overrides the default settings for this call, e.g, timeout,
|
544
588
|
# retries, etc.
|
589
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
590
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Monitoring::V3::TimeSeries>]
|
591
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
545
592
|
# @return [Google::Gax::PagedEnumerable<Google::Monitoring::V3::TimeSeries>]
|
546
593
|
# An enumerable of Google::Monitoring::V3::TimeSeries instances.
|
547
594
|
# See Google::Gax::PagedEnumerable documentation for other
|
@@ -549,9 +596,9 @@ module Google
|
|
549
596
|
# object.
|
550
597
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
551
598
|
# @example
|
552
|
-
# require "google/cloud/monitoring
|
599
|
+
# require "google/cloud/monitoring"
|
553
600
|
#
|
554
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
601
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
555
602
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
|
556
603
|
#
|
557
604
|
# # TODO: Initialize +filter+:
|
@@ -584,7 +631,8 @@ module Google
|
|
584
631
|
aggregation: nil,
|
585
632
|
order_by: nil,
|
586
633
|
page_size: nil,
|
587
|
-
options: nil
|
634
|
+
options: nil,
|
635
|
+
&block
|
588
636
|
req = {
|
589
637
|
name: name,
|
590
638
|
filter: filter,
|
@@ -595,7 +643,7 @@ module Google
|
|
595
643
|
page_size: page_size
|
596
644
|
}.delete_if { |_, v| v.nil? }
|
597
645
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListTimeSeriesRequest)
|
598
|
-
@list_time_series.call(req, options)
|
646
|
+
@list_time_series.call(req, options, &block)
|
599
647
|
end
|
600
648
|
|
601
649
|
# Creates or adds data to one or more time series.
|
@@ -617,11 +665,14 @@ module Google
|
|
617
665
|
# @param options [Google::Gax::CallOptions]
|
618
666
|
# Overrides the default settings for this call, e.g, timeout,
|
619
667
|
# retries, etc.
|
668
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
669
|
+
# @yieldparam result []
|
670
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
620
671
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
621
672
|
# @example
|
622
|
-
# require "google/cloud/monitoring
|
673
|
+
# require "google/cloud/monitoring"
|
623
674
|
#
|
624
|
-
# metric_service_client = Google::Cloud::Monitoring::
|
675
|
+
# metric_service_client = Google::Cloud::Monitoring::Metric.new(version: :v3)
|
625
676
|
# formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
|
626
677
|
#
|
627
678
|
# # TODO: Initialize +time_series+:
|
@@ -631,13 +682,14 @@ module Google
|
|
631
682
|
def create_time_series \
|
632
683
|
name,
|
633
684
|
time_series,
|
634
|
-
options: nil
|
685
|
+
options: nil,
|
686
|
+
&block
|
635
687
|
req = {
|
636
688
|
name: name,
|
637
689
|
time_series: time_series
|
638
690
|
}.delete_if { |_, v| v.nil? }
|
639
691
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateTimeSeriesRequest)
|
640
|
-
@create_time_series.call(req, options)
|
692
|
+
@create_time_series.call(req, options, &block)
|
641
693
|
nil
|
642
694
|
end
|
643
695
|
end
|
@@ -25,7 +25,7 @@ require "pathname"
|
|
25
25
|
require "google/gax"
|
26
26
|
|
27
27
|
require "google/monitoring/v3/notification_service_pb"
|
28
|
-
require "google/cloud/monitoring/credentials"
|
28
|
+
require "google/cloud/monitoring/v3/credentials"
|
29
29
|
|
30
30
|
module Google
|
31
31
|
module Cloud
|
@@ -45,6 +45,9 @@ module Google
|
|
45
45
|
# The default port of the service.
|
46
46
|
DEFAULT_SERVICE_PORT = 443
|
47
47
|
|
48
|
+
# The default set of gRPC interceptors.
|
49
|
+
GRPC_INTERCEPTORS = []
|
50
|
+
|
48
51
|
DEFAULT_TIMEOUT = 30
|
49
52
|
|
50
53
|
PAGE_DESCRIPTORS = {
|
@@ -143,11 +146,18 @@ module Google
|
|
143
146
|
# or the specified config is missing data points.
|
144
147
|
# @param timeout [Numeric]
|
145
148
|
# The default timeout, in seconds, for calls made through this client.
|
149
|
+
# @param metadata [Hash]
|
150
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
151
|
+
# @param exception_transformer [Proc]
|
152
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
153
|
+
# custom error handling.
|
146
154
|
def initialize \
|
147
155
|
credentials: nil,
|
148
156
|
scopes: ALL_SCOPES,
|
149
157
|
client_config: {},
|
150
158
|
timeout: DEFAULT_TIMEOUT,
|
159
|
+
metadata: nil,
|
160
|
+
exception_transformer: nil,
|
151
161
|
lib_name: nil,
|
152
162
|
lib_version: ""
|
153
163
|
# These require statements are intentionally placed here to initialize
|
@@ -156,10 +166,10 @@ module Google
|
|
156
166
|
require "google/gax/grpc"
|
157
167
|
require "google/monitoring/v3/notification_service_services_pb"
|
158
168
|
|
159
|
-
credentials ||= Google::Cloud::Monitoring::Credentials.default
|
169
|
+
credentials ||= Google::Cloud::Monitoring::V3::Credentials.default
|
160
170
|
|
161
171
|
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
162
|
-
updater_proc = Google::Cloud::Monitoring::Credentials.new(credentials).updater_proc
|
172
|
+
updater_proc = Google::Cloud::Monitoring::V3::Credentials.new(credentials).updater_proc
|
163
173
|
end
|
164
174
|
if credentials.is_a?(GRPC::Core::Channel)
|
165
175
|
channel = credentials
|
@@ -183,6 +193,7 @@ module Google
|
|
183
193
|
google_api_client.freeze
|
184
194
|
|
185
195
|
headers = { :"x-goog-api-client" => google_api_client }
|
196
|
+
headers.merge!(metadata) unless metadata.nil?
|
186
197
|
client_config_file = Pathname.new(__dir__).join(
|
187
198
|
"notification_channel_service_client_config.json"
|
188
199
|
)
|
@@ -195,13 +206,14 @@ module Google
|
|
195
206
|
timeout,
|
196
207
|
page_descriptors: PAGE_DESCRIPTORS,
|
197
208
|
errors: Google::Gax::Grpc::API_ERRORS,
|
198
|
-
|
209
|
+
metadata: headers
|
199
210
|
)
|
200
211
|
end
|
201
212
|
|
202
213
|
# Allow overriding the service path/port in subclasses.
|
203
214
|
service_path = self.class::SERVICE_ADDRESS
|
204
215
|
port = self.class::DEFAULT_SERVICE_PORT
|
216
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
205
217
|
@notification_channel_service_stub = Google::Gax::Grpc.create_stub(
|
206
218
|
service_path,
|
207
219
|
port,
|
@@ -209,36 +221,44 @@ module Google
|
|
209
221
|
channel: channel,
|
210
222
|
updater_proc: updater_proc,
|
211
223
|
scopes: scopes,
|
224
|
+
interceptors: interceptors,
|
212
225
|
&Google::Monitoring::V3::NotificationChannelService::Stub.method(:new)
|
213
226
|
)
|
214
227
|
|
215
228
|
@list_notification_channel_descriptors = Google::Gax.create_api_call(
|
216
229
|
@notification_channel_service_stub.method(:list_notification_channel_descriptors),
|
217
|
-
defaults["list_notification_channel_descriptors"]
|
230
|
+
defaults["list_notification_channel_descriptors"],
|
231
|
+
exception_transformer: exception_transformer
|
218
232
|
)
|
219
233
|
@get_notification_channel_descriptor = Google::Gax.create_api_call(
|
220
234
|
@notification_channel_service_stub.method(:get_notification_channel_descriptor),
|
221
|
-
defaults["get_notification_channel_descriptor"]
|
235
|
+
defaults["get_notification_channel_descriptor"],
|
236
|
+
exception_transformer: exception_transformer
|
222
237
|
)
|
223
238
|
@list_notification_channels = Google::Gax.create_api_call(
|
224
239
|
@notification_channel_service_stub.method(:list_notification_channels),
|
225
|
-
defaults["list_notification_channels"]
|
240
|
+
defaults["list_notification_channels"],
|
241
|
+
exception_transformer: exception_transformer
|
226
242
|
)
|
227
243
|
@get_notification_channel = Google::Gax.create_api_call(
|
228
244
|
@notification_channel_service_stub.method(:get_notification_channel),
|
229
|
-
defaults["get_notification_channel"]
|
245
|
+
defaults["get_notification_channel"],
|
246
|
+
exception_transformer: exception_transformer
|
230
247
|
)
|
231
248
|
@create_notification_channel = Google::Gax.create_api_call(
|
232
249
|
@notification_channel_service_stub.method(:create_notification_channel),
|
233
|
-
defaults["create_notification_channel"]
|
250
|
+
defaults["create_notification_channel"],
|
251
|
+
exception_transformer: exception_transformer
|
234
252
|
)
|
235
253
|
@update_notification_channel = Google::Gax.create_api_call(
|
236
254
|
@notification_channel_service_stub.method(:update_notification_channel),
|
237
|
-
defaults["update_notification_channel"]
|
255
|
+
defaults["update_notification_channel"],
|
256
|
+
exception_transformer: exception_transformer
|
238
257
|
)
|
239
258
|
@delete_notification_channel = Google::Gax.create_api_call(
|
240
259
|
@notification_channel_service_stub.method(:delete_notification_channel),
|
241
|
-
defaults["delete_notification_channel"]
|
260
|
+
defaults["delete_notification_channel"],
|
261
|
+
exception_transformer: exception_transformer
|
242
262
|
)
|
243
263
|
end
|
244
264
|
|
@@ -266,6 +286,9 @@ module Google
|
|
266
286
|
# @param options [Google::Gax::CallOptions]
|
267
287
|
# Overrides the default settings for this call, e.g, timeout,
|
268
288
|
# retries, etc.
|
289
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
290
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Monitoring::V3::NotificationChannelDescriptor>]
|
291
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
269
292
|
# @return [Google::Gax::PagedEnumerable<Google::Monitoring::V3::NotificationChannelDescriptor>]
|
270
293
|
# An enumerable of Google::Monitoring::V3::NotificationChannelDescriptor instances.
|
271
294
|
# See Google::Gax::PagedEnumerable documentation for other
|
@@ -273,9 +296,9 @@ module Google
|
|
273
296
|
# object.
|
274
297
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
275
298
|
# @example
|
276
|
-
# require "google/cloud/monitoring
|
299
|
+
# require "google/cloud/monitoring"
|
277
300
|
#
|
278
|
-
# notification_channel_service_client = Google::Cloud::Monitoring::
|
301
|
+
# notification_channel_service_client = Google::Cloud::Monitoring::NotificationChannel.new(version: :v3)
|
279
302
|
# formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.project_path("[PROJECT]")
|
280
303
|
#
|
281
304
|
# # Iterate over all results.
|
@@ -294,13 +317,14 @@ module Google
|
|
294
317
|
def list_notification_channel_descriptors \
|
295
318
|
name,
|
296
319
|
page_size: nil,
|
297
|
-
options: nil
|
320
|
+
options: nil,
|
321
|
+
&block
|
298
322
|
req = {
|
299
323
|
name: name,
|
300
324
|
page_size: page_size
|
301
325
|
}.delete_if { |_, v| v.nil? }
|
302
326
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListNotificationChannelDescriptorsRequest)
|
303
|
-
@list_notification_channel_descriptors.call(req, options)
|
327
|
+
@list_notification_channel_descriptors.call(req, options, &block)
|
304
328
|
end
|
305
329
|
|
306
330
|
# Gets a single channel descriptor. The descriptor indicates which fields
|
@@ -312,23 +336,27 @@ module Google
|
|
312
336
|
# @param options [Google::Gax::CallOptions]
|
313
337
|
# Overrides the default settings for this call, e.g, timeout,
|
314
338
|
# retries, etc.
|
339
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
340
|
+
# @yieldparam result [Google::Monitoring::V3::NotificationChannelDescriptor]
|
341
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
315
342
|
# @return [Google::Monitoring::V3::NotificationChannelDescriptor]
|
316
343
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
317
344
|
# @example
|
318
|
-
# require "google/cloud/monitoring
|
345
|
+
# require "google/cloud/monitoring"
|
319
346
|
#
|
320
|
-
# notification_channel_service_client = Google::Cloud::Monitoring::
|
347
|
+
# notification_channel_service_client = Google::Cloud::Monitoring::NotificationChannel.new(version: :v3)
|
321
348
|
# formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.notification_channel_descriptor_path("[PROJECT]", "[CHANNEL_DESCRIPTOR]")
|
322
349
|
# response = notification_channel_service_client.get_notification_channel_descriptor(formatted_name)
|
323
350
|
|
324
351
|
def get_notification_channel_descriptor \
|
325
352
|
name,
|
326
|
-
options: nil
|
353
|
+
options: nil,
|
354
|
+
&block
|
327
355
|
req = {
|
328
356
|
name: name
|
329
357
|
}.delete_if { |_, v| v.nil? }
|
330
358
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetNotificationChannelDescriptorRequest)
|
331
|
-
@get_notification_channel_descriptor.call(req, options)
|
359
|
+
@get_notification_channel_descriptor.call(req, options, &block)
|
332
360
|
end
|
333
361
|
|
334
362
|
# Lists the notification channels that have been created for the project.
|
@@ -362,6 +390,9 @@ module Google
|
|
362
390
|
# @param options [Google::Gax::CallOptions]
|
363
391
|
# Overrides the default settings for this call, e.g, timeout,
|
364
392
|
# retries, etc.
|
393
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
394
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Monitoring::V3::NotificationChannel>]
|
395
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
365
396
|
# @return [Google::Gax::PagedEnumerable<Google::Monitoring::V3::NotificationChannel>]
|
366
397
|
# An enumerable of Google::Monitoring::V3::NotificationChannel instances.
|
367
398
|
# See Google::Gax::PagedEnumerable documentation for other
|
@@ -369,9 +400,9 @@ module Google
|
|
369
400
|
# object.
|
370
401
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
371
402
|
# @example
|
372
|
-
# require "google/cloud/monitoring
|
403
|
+
# require "google/cloud/monitoring"
|
373
404
|
#
|
374
|
-
# notification_channel_service_client = Google::Cloud::Monitoring::
|
405
|
+
# notification_channel_service_client = Google::Cloud::Monitoring::NotificationChannel.new(version: :v3)
|
375
406
|
# formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.project_path("[PROJECT]")
|
376
407
|
#
|
377
408
|
# # Iterate over all results.
|
@@ -392,7 +423,8 @@ module Google
|
|
392
423
|
filter: nil,
|
393
424
|
order_by: nil,
|
394
425
|
page_size: nil,
|
395
|
-
options: nil
|
426
|
+
options: nil,
|
427
|
+
&block
|
396
428
|
req = {
|
397
429
|
name: name,
|
398
430
|
filter: filter,
|
@@ -400,7 +432,7 @@ module Google
|
|
400
432
|
page_size: page_size
|
401
433
|
}.delete_if { |_, v| v.nil? }
|
402
434
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListNotificationChannelsRequest)
|
403
|
-
@list_notification_channels.call(req, options)
|
435
|
+
@list_notification_channels.call(req, options, &block)
|
404
436
|
end
|
405
437
|
|
406
438
|
# Gets a single notification channel. The channel includes the relevant
|
@@ -415,23 +447,27 @@ module Google
|
|
415
447
|
# @param options [Google::Gax::CallOptions]
|
416
448
|
# Overrides the default settings for this call, e.g, timeout,
|
417
449
|
# retries, etc.
|
450
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
451
|
+
# @yieldparam result [Google::Monitoring::V3::NotificationChannel]
|
452
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
418
453
|
# @return [Google::Monitoring::V3::NotificationChannel]
|
419
454
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
420
455
|
# @example
|
421
|
-
# require "google/cloud/monitoring
|
456
|
+
# require "google/cloud/monitoring"
|
422
457
|
#
|
423
|
-
# notification_channel_service_client = Google::Cloud::Monitoring::
|
458
|
+
# notification_channel_service_client = Google::Cloud::Monitoring::NotificationChannel.new(version: :v3)
|
424
459
|
# formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.notification_channel_path("[PROJECT]", "[NOTIFICATION_CHANNEL]")
|
425
460
|
# response = notification_channel_service_client.get_notification_channel(formatted_name)
|
426
461
|
|
427
462
|
def get_notification_channel \
|
428
463
|
name,
|
429
|
-
options: nil
|
464
|
+
options: nil,
|
465
|
+
&block
|
430
466
|
req = {
|
431
467
|
name: name
|
432
468
|
}.delete_if { |_, v| v.nil? }
|
433
469
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetNotificationChannelRequest)
|
434
|
-
@get_notification_channel.call(req, options)
|
470
|
+
@get_notification_channel.call(req, options, &block)
|
435
471
|
end
|
436
472
|
|
437
473
|
# Creates a new notification channel, representing a single notification
|
@@ -453,12 +489,15 @@ module Google
|
|
453
489
|
# @param options [Google::Gax::CallOptions]
|
454
490
|
# Overrides the default settings for this call, e.g, timeout,
|
455
491
|
# retries, etc.
|
492
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
493
|
+
# @yieldparam result [Google::Monitoring::V3::NotificationChannel]
|
494
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
456
495
|
# @return [Google::Monitoring::V3::NotificationChannel]
|
457
496
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
458
497
|
# @example
|
459
|
-
# require "google/cloud/monitoring
|
498
|
+
# require "google/cloud/monitoring"
|
460
499
|
#
|
461
|
-
# notification_channel_service_client = Google::Cloud::Monitoring::
|
500
|
+
# notification_channel_service_client = Google::Cloud::Monitoring::NotificationChannel.new(version: :v3)
|
462
501
|
# formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.project_path("[PROJECT]")
|
463
502
|
#
|
464
503
|
# # TODO: Initialize +notification_channel+:
|
@@ -468,13 +507,14 @@ module Google
|
|
468
507
|
def create_notification_channel \
|
469
508
|
name,
|
470
509
|
notification_channel,
|
471
|
-
options: nil
|
510
|
+
options: nil,
|
511
|
+
&block
|
472
512
|
req = {
|
473
513
|
name: name,
|
474
514
|
notification_channel: notification_channel
|
475
515
|
}.delete_if { |_, v| v.nil? }
|
476
516
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateNotificationChannelRequest)
|
477
|
-
@create_notification_channel.call(req, options)
|
517
|
+
@create_notification_channel.call(req, options, &block)
|
478
518
|
end
|
479
519
|
|
480
520
|
# Updates a notification channel. Fields not specified in the field mask
|
@@ -494,12 +534,15 @@ module Google
|
|
494
534
|
# @param options [Google::Gax::CallOptions]
|
495
535
|
# Overrides the default settings for this call, e.g, timeout,
|
496
536
|
# retries, etc.
|
537
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
538
|
+
# @yieldparam result [Google::Monitoring::V3::NotificationChannel]
|
539
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
497
540
|
# @return [Google::Monitoring::V3::NotificationChannel]
|
498
541
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
499
542
|
# @example
|
500
|
-
# require "google/cloud/monitoring
|
543
|
+
# require "google/cloud/monitoring"
|
501
544
|
#
|
502
|
-
# notification_channel_service_client = Google::Cloud::Monitoring::
|
545
|
+
# notification_channel_service_client = Google::Cloud::Monitoring::NotificationChannel.new(version: :v3)
|
503
546
|
#
|
504
547
|
# # TODO: Initialize +notification_channel+:
|
505
548
|
# notification_channel = {}
|
@@ -508,13 +551,14 @@ module Google
|
|
508
551
|
def update_notification_channel \
|
509
552
|
notification_channel,
|
510
553
|
update_mask: nil,
|
511
|
-
options: nil
|
554
|
+
options: nil,
|
555
|
+
&block
|
512
556
|
req = {
|
513
557
|
notification_channel: notification_channel,
|
514
558
|
update_mask: update_mask
|
515
559
|
}.delete_if { |_, v| v.nil? }
|
516
560
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::UpdateNotificationChannelRequest)
|
517
|
-
@update_notification_channel.call(req, options)
|
561
|
+
@update_notification_channel.call(req, options, &block)
|
518
562
|
end
|
519
563
|
|
520
564
|
# Deletes a notification channel.
|
@@ -530,24 +574,28 @@ module Google
|
|
530
574
|
# @param options [Google::Gax::CallOptions]
|
531
575
|
# Overrides the default settings for this call, e.g, timeout,
|
532
576
|
# retries, etc.
|
577
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
578
|
+
# @yieldparam result []
|
579
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
533
580
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
534
581
|
# @example
|
535
|
-
# require "google/cloud/monitoring
|
582
|
+
# require "google/cloud/monitoring"
|
536
583
|
#
|
537
|
-
# notification_channel_service_client = Google::Cloud::Monitoring::
|
584
|
+
# notification_channel_service_client = Google::Cloud::Monitoring::NotificationChannel.new(version: :v3)
|
538
585
|
# formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.notification_channel_path("[PROJECT]", "[NOTIFICATION_CHANNEL]")
|
539
586
|
# notification_channel_service_client.delete_notification_channel(formatted_name)
|
540
587
|
|
541
588
|
def delete_notification_channel \
|
542
589
|
name,
|
543
590
|
force: nil,
|
544
|
-
options: nil
|
591
|
+
options: nil,
|
592
|
+
&block
|
545
593
|
req = {
|
546
594
|
name: name,
|
547
595
|
force: force
|
548
596
|
}.delete_if { |_, v| v.nil? }
|
549
597
|
req = Google::Gax::to_proto(req, Google::Monitoring::V3::DeleteNotificationChannelRequest)
|
550
|
-
@delete_notification_channel.call(req, options)
|
598
|
+
@delete_notification_channel.call(req, options, &block)
|
551
599
|
nil
|
552
600
|
end
|
553
601
|
end
|