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