google-cloud-monitoring 0.38.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -54
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +361 -0
  6. data/README.md +34 -50
  7. data/lib/google-cloud-monitoring.rb +6 -5
  8. data/lib/google/cloud/monitoring.rb +255 -443
  9. data/lib/google/cloud/monitoring/dashboard.rb +88 -117
  10. data/lib/google/cloud/monitoring/{v3/doc/google/protobuf/wrappers.rb → dashboard/version.rb} +12 -9
  11. data/lib/google/cloud/monitoring/version.rb +6 -2
  12. metadata +71 -128
  13. data/LICENSE +0 -201
  14. data/lib/google/cloud/monitoring/dashboard/v1.rb +0 -148
  15. data/lib/google/cloud/monitoring/dashboard/v1/credentials.rb +0 -46
  16. data/lib/google/cloud/monitoring/dashboard/v1/dashboards_service_client.rb +0 -457
  17. data/lib/google/cloud/monitoring/dashboard/v1/dashboards_service_client_config.json +0 -51
  18. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/common.rb +0 -394
  19. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/dashboard.rb +0 -53
  20. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/dashboards_service.rb +0 -82
  21. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/layouts.rb +0 -71
  22. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/metrics.rb +0 -151
  23. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/scorecard.rb +0 -102
  24. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/text.rb +0 -43
  25. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/widget.rb +0 -41
  26. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/monitoring/dashboard/v1/xychart.rb +0 -141
  27. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/protobuf/duration.rb +0 -91
  28. data/lib/google/cloud/monitoring/dashboard/v1/doc/google/protobuf/empty.rb +0 -29
  29. data/lib/google/cloud/monitoring/v3.rb +0 -532
  30. data/lib/google/cloud/monitoring/v3/alert_policy_service_client.rb +0 -553
  31. data/lib/google/cloud/monitoring/v3/alert_policy_service_client_config.json +0 -51
  32. data/lib/google/cloud/monitoring/v3/credentials.rb +0 -44
  33. data/lib/google/cloud/monitoring/v3/doc/google/api/distribution.rb +0 -200
  34. data/lib/google/cloud/monitoring/v3/doc/google/api/label.rb +0 -42
  35. data/lib/google/cloud/monitoring/v3/doc/google/api/metric.rb +0 -245
  36. data/lib/google/cloud/monitoring/v3/doc/google/api/monitored_resource.rb +0 -108
  37. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/alert.rb +0 -344
  38. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/alert_service.rb +0 -138
  39. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/common.rb +0 -449
  40. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/group.rb +0 -75
  41. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/group_service.rb +0 -167
  42. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/metric.rb +0 -85
  43. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/metric_service.rb +0 -230
  44. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/mutation_record.rb +0 -29
  45. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/notification.rb +0 -156
  46. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/notification_service.rb +0 -221
  47. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/service.rb +0 -361
  48. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/service_service.rb +0 -197
  49. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/uptime.rb +0 -364
  50. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/uptime_service.rb +0 -136
  51. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/any.rb +0 -131
  52. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/duration.rb +0 -91
  53. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/empty.rb +0 -29
  54. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/field_mask.rb +0 -222
  55. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/struct.rb +0 -74
  56. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/timestamp.rb +0 -113
  57. data/lib/google/cloud/monitoring/v3/doc/google/rpc/status.rb +0 -39
  58. data/lib/google/cloud/monitoring/v3/group_service_client.rb +0 -606
  59. data/lib/google/cloud/monitoring/v3/group_service_client_config.json +0 -56
  60. data/lib/google/cloud/monitoring/v3/metric_service_client.rb +0 -750
  61. data/lib/google/cloud/monitoring/v3/metric_service_client_config.json +0 -66
  62. data/lib/google/cloud/monitoring/v3/notification_channel_service_client.rb +0 -811
  63. data/lib/google/cloud/monitoring/v3/notification_channel_service_client_config.json +0 -76
  64. data/lib/google/cloud/monitoring/v3/service_monitoring_service_client.rb +0 -788
  65. data/lib/google/cloud/monitoring/v3/service_monitoring_service_client_config.json +0 -76
  66. data/lib/google/cloud/monitoring/v3/uptime_check_service_client.rb +0 -550
  67. data/lib/google/cloud/monitoring/v3/uptime_check_service_client_config.json +0 -56
  68. data/lib/google/monitoring/dashboard/v1/common_pb.rb +0 -95
  69. data/lib/google/monitoring/dashboard/v1/dashboard_pb.rb +0 -29
  70. data/lib/google/monitoring/dashboard/v1/dashboards_service_pb.rb +0 -51
  71. data/lib/google/monitoring/dashboard/v1/dashboards_service_services_pb.rb +0 -76
  72. data/lib/google/monitoring/dashboard/v1/drilldowns_pb.rb +0 -17
  73. data/lib/google/monitoring/dashboard/v1/layouts_pb.rb +0 -41
  74. data/lib/google/monitoring/dashboard/v1/metrics_pb.rb +0 -76
  75. data/lib/google/monitoring/dashboard/v1/scorecard_pb.rb +0 -38
  76. data/lib/google/monitoring/dashboard/v1/service_pb.rb +0 -17
  77. data/lib/google/monitoring/dashboard/v1/text_pb.rb +0 -28
  78. data/lib/google/monitoring/dashboard/v1/widget_pb.rb +0 -32
  79. data/lib/google/monitoring/dashboard/v1/xychart_pb.rb +0 -66
  80. data/lib/google/monitoring/v3/alert_pb.rb +0 -87
  81. data/lib/google/monitoring/v3/alert_service_pb.rb +0 -53
  82. data/lib/google/monitoring/v3/alert_service_services_pb.rb +0 -63
  83. data/lib/google/monitoring/v3/common_pb.rb +0 -95
  84. data/lib/google/monitoring/v3/dropped_labels_pb.rb +0 -19
  85. data/lib/google/monitoring/v3/group_pb.rb +0 -24
  86. data/lib/google/monitoring/v3/group_service_pb.rb +0 -73
  87. data/lib/google/monitoring/v3/group_service_services_pb.rb +0 -66
  88. data/lib/google/monitoring/v3/metric_pb.rb +0 -82
  89. data/lib/google/monitoring/v3/metric_service_pb.rb +0 -130
  90. data/lib/google/monitoring/v3/metric_service_services_pb.rb +0 -66
  91. data/lib/google/monitoring/v3/mutation_record_pb.rb +0 -21
  92. data/lib/google/monitoring/v3/notification_pb.rb +0 -47
  93. data/lib/google/monitoring/v3/notification_service_pb.rb +0 -90
  94. data/lib/google/monitoring/v3/notification_service_services_pb.rb +0 -94
  95. data/lib/google/monitoring/v3/service_pb.rb +0 -149
  96. data/lib/google/monitoring/v3/service_service_pb.rb +0 -86
  97. data/lib/google/monitoring/v3/service_service_services_pb.rb +0 -65
  98. data/lib/google/monitoring/v3/span_context_pb.rb +0 -19
  99. data/lib/google/monitoring/v3/uptime_pb.rb +0 -123
  100. data/lib/google/monitoring/v3/uptime_service_pb.rb +0 -63
  101. data/lib/google/monitoring/v3/uptime_service_services_pb.rb +0 -67
@@ -1,553 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/alert_service.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/monitoring/v3/alert_service_pb"
29
- require "google/cloud/monitoring/v3/credentials"
30
- require "google/cloud/monitoring/version"
31
-
32
- module Google
33
- module Cloud
34
- module Monitoring
35
- module V3
36
- # The AlertPolicyService API is used to manage (list, create, delete,
37
- # edit) alert policies in Stackdriver Monitoring. An alerting policy is
38
- # a description of the conditions under which some aspect of your
39
- # system is considered to be "unhealthy" and the ways to notify
40
- # people or services about this state. In addition to using this API, alert
41
- # policies can also be managed through
42
- # [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/),
43
- # which can be reached by clicking the "Monitoring" tab in
44
- # [Cloud Console](https://console.cloud.google.com/).
45
- #
46
- # @!attribute [r] alert_policy_service_stub
47
- # @return [Google::Monitoring::V3::AlertPolicyService::Stub]
48
- class AlertPolicyServiceClient
49
- # @private
50
- attr_reader :alert_policy_service_stub
51
-
52
- # The default address of the service.
53
- SERVICE_ADDRESS = "monitoring.googleapis.com".freeze
54
-
55
- # The default port of the service.
56
- DEFAULT_SERVICE_PORT = 443
57
-
58
- # The default set of gRPC interceptors.
59
- GRPC_INTERCEPTORS = []
60
-
61
- DEFAULT_TIMEOUT = 30
62
-
63
- PAGE_DESCRIPTORS = {
64
- "list_alert_policies" => Google::Gax::PageDescriptor.new(
65
- "page_token",
66
- "next_page_token",
67
- "alert_policies")
68
- }.freeze
69
-
70
- private_constant :PAGE_DESCRIPTORS
71
-
72
- # The scopes needed to make gRPC calls to all of the methods defined in
73
- # this service.
74
- ALL_SCOPES = [
75
- "https://www.googleapis.com/auth/cloud-platform",
76
- "https://www.googleapis.com/auth/monitoring",
77
- "https://www.googleapis.com/auth/monitoring.read",
78
- "https://www.googleapis.com/auth/monitoring.write"
79
- ].freeze
80
-
81
-
82
- ALERT_POLICY_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
83
- "projects/{project}/alertPolicies/{alert_policy}"
84
- )
85
-
86
- private_constant :ALERT_POLICY_PATH_TEMPLATE
87
-
88
- ALERT_POLICY_CONDITION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
89
- "projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}"
90
- )
91
-
92
- private_constant :ALERT_POLICY_CONDITION_PATH_TEMPLATE
93
-
94
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
95
- "projects/{project}"
96
- )
97
-
98
- private_constant :PROJECT_PATH_TEMPLATE
99
-
100
- # Returns a fully-qualified alert_policy resource name string.
101
- # @param project [String]
102
- # @param alert_policy [String]
103
- # @return [String]
104
- def self.alert_policy_path project, alert_policy
105
- ALERT_POLICY_PATH_TEMPLATE.render(
106
- :"project" => project,
107
- :"alert_policy" => alert_policy
108
- )
109
- end
110
-
111
- # Returns a fully-qualified alert_policy_condition resource name string.
112
- # @param project [String]
113
- # @param alert_policy [String]
114
- # @param condition [String]
115
- # @return [String]
116
- def self.alert_policy_condition_path project, alert_policy, condition
117
- ALERT_POLICY_CONDITION_PATH_TEMPLATE.render(
118
- :"project" => project,
119
- :"alert_policy" => alert_policy,
120
- :"condition" => condition
121
- )
122
- end
123
-
124
- # Returns a fully-qualified project resource name string.
125
- # @param project [String]
126
- # @return [String]
127
- def self.project_path project
128
- PROJECT_PATH_TEMPLATE.render(
129
- :"project" => project
130
- )
131
- end
132
-
133
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
134
- # Provides the means for authenticating requests made by the client. This parameter can
135
- # be many types.
136
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
137
- # authenticating requests made by this client.
138
- # A `String` will be treated as the path to the keyfile to be used for the construction of
139
- # credentials for this client.
140
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
141
- # credentials for this client.
142
- # A `GRPC::Core::Channel` will be used to make calls through.
143
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
144
- # should already be composed with a `GRPC::Core::CallCredentials` object.
145
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
146
- # metadata for requests, generally, to give OAuth credentials.
147
- # @param scopes [Array<String>]
148
- # The OAuth scopes for this service. This parameter is ignored if
149
- # an updater_proc is supplied.
150
- # @param client_config [Hash]
151
- # A Hash for call options for each method. See
152
- # Google::Gax#construct_settings for the structure of
153
- # this data. Falls back to the default config if not specified
154
- # or the specified config is missing data points.
155
- # @param timeout [Numeric]
156
- # The default timeout, in seconds, for calls made through this client.
157
- # @param metadata [Hash]
158
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
159
- # @param service_address [String]
160
- # Override for the service hostname, or `nil` to leave as the default.
161
- # @param service_port [Integer]
162
- # Override for the service port, or `nil` to leave as the default.
163
- # @param exception_transformer [Proc]
164
- # An optional proc that intercepts any exceptions raised during an API call to inject
165
- # custom error handling.
166
- def initialize \
167
- credentials: nil,
168
- scopes: ALL_SCOPES,
169
- client_config: {},
170
- timeout: DEFAULT_TIMEOUT,
171
- metadata: nil,
172
- service_address: nil,
173
- service_port: nil,
174
- exception_transformer: nil,
175
- lib_name: nil,
176
- lib_version: ""
177
- # These require statements are intentionally placed here to initialize
178
- # the gRPC module only when it's required.
179
- # See https://github.com/googleapis/toolkit/issues/446
180
- require "google/gax/grpc"
181
- require "google/monitoring/v3/alert_service_services_pb"
182
-
183
- credentials ||= Google::Cloud::Monitoring::V3::Credentials.default
184
-
185
- if credentials.is_a?(String) || credentials.is_a?(Hash)
186
- updater_proc = Google::Cloud::Monitoring::V3::Credentials.new(credentials).updater_proc
187
- end
188
- if credentials.is_a?(GRPC::Core::Channel)
189
- channel = credentials
190
- end
191
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
192
- chan_creds = credentials
193
- end
194
- if credentials.is_a?(Proc)
195
- updater_proc = credentials
196
- end
197
- if credentials.is_a?(Google::Auth::Credentials)
198
- updater_proc = credentials.updater_proc
199
- end
200
-
201
- package_version = Google::Cloud::Monitoring::VERSION
202
-
203
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
204
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
205
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
206
- google_api_client << " grpc/#{GRPC::VERSION}"
207
- google_api_client.freeze
208
-
209
- headers = { :"x-goog-api-client" => google_api_client }
210
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
211
- headers[:"x-goog-user-project"] = credentials.quota_project_id
212
- end
213
- headers.merge!(metadata) unless metadata.nil?
214
- client_config_file = Pathname.new(__dir__).join(
215
- "alert_policy_service_client_config.json"
216
- )
217
- defaults = client_config_file.open do |f|
218
- Google::Gax.construct_settings(
219
- "google.monitoring.v3.AlertPolicyService",
220
- JSON.parse(f.read),
221
- client_config,
222
- Google::Gax::Grpc::STATUS_CODE_NAMES,
223
- timeout,
224
- page_descriptors: PAGE_DESCRIPTORS,
225
- errors: Google::Gax::Grpc::API_ERRORS,
226
- metadata: headers
227
- )
228
- end
229
-
230
- # Allow overriding the service path/port in subclasses.
231
- service_path = service_address || self.class::SERVICE_ADDRESS
232
- port = service_port || self.class::DEFAULT_SERVICE_PORT
233
- interceptors = self.class::GRPC_INTERCEPTORS
234
- @alert_policy_service_stub = Google::Gax::Grpc.create_stub(
235
- service_path,
236
- port,
237
- chan_creds: chan_creds,
238
- channel: channel,
239
- updater_proc: updater_proc,
240
- scopes: scopes,
241
- interceptors: interceptors,
242
- &Google::Monitoring::V3::AlertPolicyService::Stub.method(:new)
243
- )
244
-
245
- @list_alert_policies = Google::Gax.create_api_call(
246
- @alert_policy_service_stub.method(:list_alert_policies),
247
- defaults["list_alert_policies"],
248
- exception_transformer: exception_transformer,
249
- params_extractor: proc do |request|
250
- {'name' => request.name}
251
- end
252
- )
253
- @get_alert_policy = Google::Gax.create_api_call(
254
- @alert_policy_service_stub.method(:get_alert_policy),
255
- defaults["get_alert_policy"],
256
- exception_transformer: exception_transformer,
257
- params_extractor: proc do |request|
258
- {'name' => request.name}
259
- end
260
- )
261
- @create_alert_policy = Google::Gax.create_api_call(
262
- @alert_policy_service_stub.method(:create_alert_policy),
263
- defaults["create_alert_policy"],
264
- exception_transformer: exception_transformer,
265
- params_extractor: proc do |request|
266
- {'name' => request.name}
267
- end
268
- )
269
- @delete_alert_policy = Google::Gax.create_api_call(
270
- @alert_policy_service_stub.method(:delete_alert_policy),
271
- defaults["delete_alert_policy"],
272
- exception_transformer: exception_transformer,
273
- params_extractor: proc do |request|
274
- {'name' => request.name}
275
- end
276
- )
277
- @update_alert_policy = Google::Gax.create_api_call(
278
- @alert_policy_service_stub.method(:update_alert_policy),
279
- defaults["update_alert_policy"],
280
- exception_transformer: exception_transformer,
281
- params_extractor: proc do |request|
282
- {'alert_policy.name' => request.alert_policy.name}
283
- end
284
- )
285
- end
286
-
287
- # Service calls
288
-
289
- # Lists the existing alerting policies for the project.
290
- #
291
- # @param name [String]
292
- # Required. The project whose alert policies are to be listed. The format is:
293
- #
294
- # projects/[PROJECT_ID_OR_NUMBER]
295
- #
296
- # Note that this field names the parent container in which the alerting
297
- # policies to be listed are stored. To retrieve a single alerting policy
298
- # by name, use the
299
- # {Google::Monitoring::V3::AlertPolicyService::GetAlertPolicy GetAlertPolicy}
300
- # operation, instead.
301
- # @param filter [String]
302
- # If provided, this field specifies the criteria that must be met by
303
- # alert policies to be included in the response.
304
- #
305
- # For more details, see [sorting and
306
- # filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
307
- # @param order_by [String]
308
- # A comma-separated list of fields by which to sort the result. Supports
309
- # the same set of field references as the `filter` field. Entries can be
310
- # prefixed with a minus sign to sort by the field in descending order.
311
- #
312
- # For more details, see [sorting and
313
- # filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
314
- # @param page_size [Integer]
315
- # The maximum number of resources contained in the underlying API
316
- # response. If page streaming is performed per-resource, this
317
- # parameter does not affect the return value. If page streaming is
318
- # performed per-page, this determines the maximum number of
319
- # resources in a page.
320
- # @param options [Google::Gax::CallOptions]
321
- # Overrides the default settings for this call, e.g, timeout,
322
- # retries, etc.
323
- # @yield [result, operation] Access the result along with the RPC operation
324
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Monitoring::V3::AlertPolicy>]
325
- # @yieldparam operation [GRPC::ActiveCall::Operation]
326
- # @return [Google::Gax::PagedEnumerable<Google::Monitoring::V3::AlertPolicy>]
327
- # An enumerable of Google::Monitoring::V3::AlertPolicy instances.
328
- # See Google::Gax::PagedEnumerable documentation for other
329
- # operations such as per-page iteration or access to the response
330
- # object.
331
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
332
- # @example
333
- # require "google/cloud/monitoring"
334
- #
335
- # alert_policy_client = Google::Cloud::Monitoring::AlertPolicy.new(version: :v3)
336
- # formatted_name = Google::Cloud::Monitoring::V3::AlertPolicyServiceClient.project_path("[PROJECT]")
337
- #
338
- # # Iterate over all results.
339
- # alert_policy_client.list_alert_policies(formatted_name).each do |element|
340
- # # Process element.
341
- # end
342
- #
343
- # # Or iterate over results one page at a time.
344
- # alert_policy_client.list_alert_policies(formatted_name).each_page do |page|
345
- # # Process each page at a time.
346
- # page.each do |element|
347
- # # Process element.
348
- # end
349
- # end
350
-
351
- def list_alert_policies \
352
- name,
353
- filter: nil,
354
- order_by: nil,
355
- page_size: nil,
356
- options: nil,
357
- &block
358
- req = {
359
- name: name,
360
- filter: filter,
361
- order_by: order_by,
362
- page_size: page_size
363
- }.delete_if { |_, v| v.nil? }
364
- req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListAlertPoliciesRequest)
365
- @list_alert_policies.call(req, options, &block)
366
- end
367
-
368
- # Gets a single alerting policy.
369
- #
370
- # @param name [String]
371
- # Required. The alerting policy to retrieve. The format is:
372
- #
373
- # projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
374
- # @param options [Google::Gax::CallOptions]
375
- # Overrides the default settings for this call, e.g, timeout,
376
- # retries, etc.
377
- # @yield [result, operation] Access the result along with the RPC operation
378
- # @yieldparam result [Google::Monitoring::V3::AlertPolicy]
379
- # @yieldparam operation [GRPC::ActiveCall::Operation]
380
- # @return [Google::Monitoring::V3::AlertPolicy]
381
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
382
- # @example
383
- # require "google/cloud/monitoring"
384
- #
385
- # alert_policy_client = Google::Cloud::Monitoring::AlertPolicy.new(version: :v3)
386
- # formatted_name = Google::Cloud::Monitoring::V3::AlertPolicyServiceClient.alert_policy_path("[PROJECT]", "[ALERT_POLICY]")
387
- # response = alert_policy_client.get_alert_policy(formatted_name)
388
-
389
- def get_alert_policy \
390
- name,
391
- options: nil,
392
- &block
393
- req = {
394
- name: name
395
- }.delete_if { |_, v| v.nil? }
396
- req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetAlertPolicyRequest)
397
- @get_alert_policy.call(req, options, &block)
398
- end
399
-
400
- # Creates a new alerting policy.
401
- #
402
- # @param name [String]
403
- # Required. The project in which to create the alerting policy. The format is:
404
- #
405
- # projects/[PROJECT_ID_OR_NUMBER]
406
- #
407
- # Note that this field names the parent container in which the alerting
408
- # policy will be written, not the name of the created policy. The alerting
409
- # policy that is returned will have a name that contains a normalized
410
- # representation of this name as a prefix but adds a suffix of the form
411
- # `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the
412
- # container.
413
- # @param alert_policy [Google::Monitoring::V3::AlertPolicy | Hash]
414
- # Required. The requested alerting policy. You should omit the `name` field in this
415
- # policy. The name will be returned in the new policy, including
416
- # a new `[ALERT_POLICY_ID]` value.
417
- # A hash of the same form as `Google::Monitoring::V3::AlertPolicy`
418
- # can also be provided.
419
- # @param options [Google::Gax::CallOptions]
420
- # Overrides the default settings for this call, e.g, timeout,
421
- # retries, etc.
422
- # @yield [result, operation] Access the result along with the RPC operation
423
- # @yieldparam result [Google::Monitoring::V3::AlertPolicy]
424
- # @yieldparam operation [GRPC::ActiveCall::Operation]
425
- # @return [Google::Monitoring::V3::AlertPolicy]
426
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
427
- # @example
428
- # require "google/cloud/monitoring"
429
- #
430
- # alert_policy_client = Google::Cloud::Monitoring::AlertPolicy.new(version: :v3)
431
- # formatted_name = Google::Cloud::Monitoring::V3::AlertPolicyServiceClient.project_path("[PROJECT]")
432
- #
433
- # # TODO: Initialize `alert_policy`:
434
- # alert_policy = {}
435
- # response = alert_policy_client.create_alert_policy(formatted_name, alert_policy)
436
-
437
- def create_alert_policy \
438
- name,
439
- alert_policy,
440
- options: nil,
441
- &block
442
- req = {
443
- name: name,
444
- alert_policy: alert_policy
445
- }.delete_if { |_, v| v.nil? }
446
- req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateAlertPolicyRequest)
447
- @create_alert_policy.call(req, options, &block)
448
- end
449
-
450
- # Deletes an alerting policy.
451
- #
452
- # @param name [String]
453
- # Required. The alerting policy to delete. The format is:
454
- #
455
- # projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
456
- #
457
- # For more information, see {Google::Monitoring::V3::AlertPolicy AlertPolicy}.
458
- # @param options [Google::Gax::CallOptions]
459
- # Overrides the default settings for this call, e.g, timeout,
460
- # retries, etc.
461
- # @yield [result, operation] Access the result along with the RPC operation
462
- # @yieldparam result []
463
- # @yieldparam operation [GRPC::ActiveCall::Operation]
464
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
465
- # @example
466
- # require "google/cloud/monitoring"
467
- #
468
- # alert_policy_client = Google::Cloud::Monitoring::AlertPolicy.new(version: :v3)
469
- # formatted_name = Google::Cloud::Monitoring::V3::AlertPolicyServiceClient.alert_policy_path("[PROJECT]", "[ALERT_POLICY]")
470
- # alert_policy_client.delete_alert_policy(formatted_name)
471
-
472
- def delete_alert_policy \
473
- name,
474
- options: nil,
475
- &block
476
- req = {
477
- name: name
478
- }.delete_if { |_, v| v.nil? }
479
- req = Google::Gax::to_proto(req, Google::Monitoring::V3::DeleteAlertPolicyRequest)
480
- @delete_alert_policy.call(req, options, &block)
481
- nil
482
- end
483
-
484
- # Updates an alerting policy. You can either replace the entire policy with
485
- # a new one or replace only certain fields in the current alerting policy by
486
- # specifying the fields to be updated via `updateMask`. Returns the
487
- # updated alerting policy.
488
- #
489
- # @param alert_policy [Google::Monitoring::V3::AlertPolicy | Hash]
490
- # Required. The updated alerting policy or the updated values for the
491
- # fields listed in `update_mask`.
492
- # If `update_mask` is not empty, any fields in this policy that are
493
- # not in `update_mask` are ignored.
494
- # A hash of the same form as `Google::Monitoring::V3::AlertPolicy`
495
- # can also be provided.
496
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
497
- # Optional. A list of alerting policy field names. If this field is not
498
- # empty, each listed field in the existing alerting policy is set to the
499
- # value of the corresponding field in the supplied policy (`alert_policy`),
500
- # or to the field's default value if the field is not in the supplied
501
- # alerting policy. Fields not listed retain their previous value.
502
- #
503
- # Examples of valid field masks include `display_name`, `documentation`,
504
- # `documentation.content`, `documentation.mime_type`, `user_labels`,
505
- # `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc.
506
- #
507
- # If this field is empty, then the supplied alerting policy replaces the
508
- # existing policy. It is the same as deleting the existing policy and
509
- # adding the supplied policy, except for the following:
510
- #
511
- # * The new policy will have the same `[ALERT_POLICY_ID]` as the former
512
- # policy. This gives you continuity with the former policy in your
513
- # notifications and incidents.
514
- # * Conditions in the new policy will keep their former `[CONDITION_ID]` if
515
- # the supplied condition includes the `name` field with that
516
- # `[CONDITION_ID]`. If the supplied condition omits the `name` field,
517
- # then a new `[CONDITION_ID]` is created.
518
- # A hash of the same form as `Google::Protobuf::FieldMask`
519
- # can also be provided.
520
- # @param options [Google::Gax::CallOptions]
521
- # Overrides the default settings for this call, e.g, timeout,
522
- # retries, etc.
523
- # @yield [result, operation] Access the result along with the RPC operation
524
- # @yieldparam result [Google::Monitoring::V3::AlertPolicy]
525
- # @yieldparam operation [GRPC::ActiveCall::Operation]
526
- # @return [Google::Monitoring::V3::AlertPolicy]
527
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
528
- # @example
529
- # require "google/cloud/monitoring"
530
- #
531
- # alert_policy_client = Google::Cloud::Monitoring::AlertPolicy.new(version: :v3)
532
- #
533
- # # TODO: Initialize `alert_policy`:
534
- # alert_policy = {}
535
- # response = alert_policy_client.update_alert_policy(alert_policy)
536
-
537
- def update_alert_policy \
538
- alert_policy,
539
- update_mask: nil,
540
- options: nil,
541
- &block
542
- req = {
543
- alert_policy: alert_policy,
544
- update_mask: update_mask
545
- }.delete_if { |_, v| v.nil? }
546
- req = Google::Gax::to_proto(req, Google::Monitoring::V3::UpdateAlertPolicyRequest)
547
- @update_alert_policy.call(req, options, &block)
548
- end
549
- end
550
- end
551
- end
552
- end
553
- end