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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -5
  3. data/lib/google/cloud/monitoring.rb +164 -6
  4. data/lib/google/cloud/monitoring/credentials.rb +1 -1
  5. data/lib/google/cloud/monitoring/v3.rb +167 -26
  6. data/lib/google/cloud/monitoring/v3/alert_policy_service_client.rb +486 -0
  7. data/lib/google/cloud/monitoring/v3/alert_policy_service_client_config.json +51 -0
  8. data/lib/google/cloud/monitoring/v3/doc/google/api/distribution.rb +1 -1
  9. data/lib/google/cloud/monitoring/v3/doc/google/api/label.rb +1 -1
  10. data/lib/google/cloud/monitoring/v3/doc/google/api/metric.rb +1 -1
  11. data/lib/google/cloud/monitoring/v3/doc/google/api/monitored_resource.rb +1 -1
  12. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/alert.rb +326 -0
  13. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/common.rb +91 -3
  14. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/group.rb +1 -1
  15. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/metric.rb +1 -1
  16. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/mutation_record.rb +28 -0
  17. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/notification.rb +152 -0
  18. data/lib/google/cloud/monitoring/v3/doc/google/monitoring/v3/uptime.rb +223 -0
  19. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/duration.rb +1 -1
  20. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/field_mask.rb +223 -0
  21. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/timestamp.rb +1 -1
  22. data/lib/google/cloud/monitoring/v3/doc/google/protobuf/wrappers.rb +89 -0
  23. data/lib/google/cloud/monitoring/v3/doc/overview.rb +8 -7
  24. data/lib/google/cloud/monitoring/v3/group_service_client.rb +13 -21
  25. data/lib/google/cloud/monitoring/v3/metric_service_client.rb +19 -21
  26. data/lib/google/cloud/monitoring/v3/notification_channel_service_client.rb +557 -0
  27. data/lib/google/cloud/monitoring/v3/notification_channel_service_client_config.json +61 -0
  28. data/lib/google/cloud/monitoring/v3/uptime_check_service_client.rb +476 -0
  29. data/lib/google/cloud/monitoring/v3/uptime_check_service_client_config.json +56 -0
  30. data/lib/google/monitoring/v3/alert_pb.rb +78 -0
  31. data/lib/google/monitoring/v3/alert_service_pb.rb +49 -0
  32. data/lib/google/monitoring/v3/alert_service_services_pb.rb +62 -0
  33. data/lib/google/monitoring/v3/common_pb.rb +20 -0
  34. data/lib/google/monitoring/v3/group_service_services_pb.rb +1 -1
  35. data/lib/google/monitoring/v3/metric_service_services_pb.rb +1 -1
  36. data/lib/google/monitoring/v3/mutation_record_pb.rb +20 -0
  37. data/lib/google/monitoring/v3/notification_pb.rb +44 -0
  38. data/lib/google/monitoring/v3/notification_service_pb.rb +85 -0
  39. data/lib/google/monitoring/v3/notification_service_services_pb.rb +93 -0
  40. data/lib/google/monitoring/v3/uptime_pb.rb +89 -0
  41. data/lib/google/monitoring/v3/uptime_service_pb.rb +57 -0
  42. data/lib/google/monitoring/v3/uptime_service_services_pb.rb +66 -0
  43. metadata +31 -9
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -0,0 +1,89 @@
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
+ module Google
16
+ module Protobuf
17
+ # Wrapper message for +double+.
18
+ #
19
+ # The JSON representation for +DoubleValue+ is JSON number.
20
+ # @!attribute [rw] value
21
+ # @return [Float]
22
+ # The double value.
23
+ class DoubleValue; end
24
+
25
+ # Wrapper message for +float+.
26
+ #
27
+ # The JSON representation for +FloatValue+ is JSON number.
28
+ # @!attribute [rw] value
29
+ # @return [Float]
30
+ # The float value.
31
+ class FloatValue; end
32
+
33
+ # Wrapper message for +int64+.
34
+ #
35
+ # The JSON representation for +Int64Value+ is JSON string.
36
+ # @!attribute [rw] value
37
+ # @return [Integer]
38
+ # The int64 value.
39
+ class Int64Value; end
40
+
41
+ # Wrapper message for +uint64+.
42
+ #
43
+ # The JSON representation for +UInt64Value+ is JSON string.
44
+ # @!attribute [rw] value
45
+ # @return [Integer]
46
+ # The uint64 value.
47
+ class UInt64Value; end
48
+
49
+ # Wrapper message for +int32+.
50
+ #
51
+ # The JSON representation for +Int32Value+ is JSON number.
52
+ # @!attribute [rw] value
53
+ # @return [Integer]
54
+ # The int32 value.
55
+ class Int32Value; end
56
+
57
+ # Wrapper message for +uint32+.
58
+ #
59
+ # The JSON representation for +UInt32Value+ is JSON number.
60
+ # @!attribute [rw] value
61
+ # @return [Integer]
62
+ # The uint32 value.
63
+ class UInt32Value; end
64
+
65
+ # Wrapper message for +bool+.
66
+ #
67
+ # The JSON representation for +BoolValue+ is JSON +true+ and +false+.
68
+ # @!attribute [rw] value
69
+ # @return [true, false]
70
+ # The bool value.
71
+ class BoolValue; end
72
+
73
+ # Wrapper message for +string+.
74
+ #
75
+ # The JSON representation for +StringValue+ is JSON string.
76
+ # @!attribute [rw] value
77
+ # @return [String]
78
+ # The string value.
79
+ class StringValue; end
80
+
81
+ # Wrapper message for +bytes+.
82
+ #
83
+ # The JSON representation for +BytesValue+ is JSON string.
84
+ # @!attribute [rw] value
85
+ # @return [String]
86
+ # The bytes value.
87
+ class BytesValue; end
88
+ end
89
+ end
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@ module Google
20
20
  # # Ruby Client for Stackdriver Monitoring API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
21
  #
22
22
  # [Stackdriver Monitoring API][Product Documentation]:
23
- # Manages your Stackdriver Monitoring data and configurations. Most projects must
24
- # be associated with a Stackdriver account, with a few exceptions as noted on the
25
- # individual method pages.
23
+ # Manages your Stackdriver Monitoring data and configurations. Most projects
24
+ # must be associated with a Stackdriver account, with a few exceptions as
25
+ # noted on the individual method pages.
26
26
  # - [Product Documentation][]
27
27
  #
28
28
  # ## Quick Start
@@ -30,8 +30,9 @@ module Google
30
30
  # steps:
31
31
  #
32
32
  # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
33
- # 2. [Enable the Stackdriver Monitoring API.](https://console.cloud.google.com/apis/api/monitoring)
34
- # 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
33
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
34
+ # 3. [Enable the Stackdriver Monitoring API.](https://console.cloud.google.com/apis/api/monitoring)
35
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
35
36
  #
36
37
  # ### Installation
37
38
  # ```
@@ -74,4 +75,4 @@ module Google
74
75
  end
75
76
  end
76
77
  end
77
- end
78
+ end
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,9 +18,6 @@
18
18
  # and updates to that file get reflected here through a refresh process.
19
19
  # For the short term, the refresh process will only be runnable by Google
20
20
  # engineers.
21
- #
22
- # The only allowed edits are to method and file documentation. A 3-way
23
- # merge preserves those additions if the generated source changes.
24
21
 
25
22
  require "json"
26
23
  require "pathname"
@@ -82,6 +79,7 @@ module Google
82
79
  "https://www.googleapis.com/auth/monitoring.write"
83
80
  ].freeze
84
81
 
82
+
85
83
  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
86
84
  "projects/{project}"
87
85
  )
@@ -139,11 +137,6 @@ module Google
139
137
  # @param timeout [Numeric]
140
138
  # The default timeout, in seconds, for calls made through this client.
141
139
  def initialize \
142
- service_path: SERVICE_ADDRESS,
143
- port: DEFAULT_SERVICE_PORT,
144
- channel: nil,
145
- chan_creds: nil,
146
- updater_proc: nil,
147
140
  credentials: nil,
148
141
  scopes: ALL_SCOPES,
149
142
  client_config: {},
@@ -156,17 +149,6 @@ module Google
156
149
  require "google/gax/grpc"
157
150
  require "google/monitoring/v3/group_service_services_pb"
158
151
 
159
- if channel || chan_creds || updater_proc
160
- warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
161
- "on 2017/09/08"
162
- credentials ||= channel
163
- credentials ||= chan_creds
164
- credentials ||= updater_proc
165
- end
166
- if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
167
- warn "`service_path` and `port` parameters are deprecated and will be removed"
168
- end
169
-
170
152
  credentials ||= Google::Cloud::Monitoring::Credentials.default
171
153
 
172
154
  if credentials.is_a?(String) || credentials.is_a?(Hash)
@@ -185,9 +167,11 @@ module Google
185
167
  updater_proc = credentials.updater_proc
186
168
  end
187
169
 
170
+ package_version = Gem.loaded_specs['google-cloud-monitoring'].version.version
171
+
188
172
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
189
173
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
190
- google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
174
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
191
175
  google_api_client << " grpc/#{GRPC::VERSION}"
192
176
  google_api_client.freeze
193
177
 
@@ -207,6 +191,10 @@ module Google
207
191
  kwargs: headers
208
192
  )
209
193
  end
194
+
195
+ # Allow overriding the service path/port in subclasses.
196
+ service_path = self.class::SERVICE_ADDRESS
197
+ port = self.class::DEFAULT_SERVICE_PORT
210
198
  @group_service_stub = Google::Gax::Grpc.create_stub(
211
199
  service_path,
212
200
  port,
@@ -366,6 +354,8 @@ module Google
366
354
  #
367
355
  # group_service_client = Google::Cloud::Monitoring::V3::Group.new
368
356
  # formatted_name = Google::Cloud::Monitoring::V3::GroupServiceClient.project_path("[PROJECT]")
357
+ #
358
+ # # TODO: Initialize +group+:
369
359
  # group = {}
370
360
  # response = group_service_client.create_group(formatted_name, group)
371
361
 
@@ -402,6 +392,8 @@ module Google
402
392
  # require "google/cloud/monitoring/v3"
403
393
  #
404
394
  # group_service_client = Google::Cloud::Monitoring::V3::Group.new
395
+ #
396
+ # # TODO: Initialize +group+:
405
397
  # group = {}
406
398
  # response = group_service_client.update_group(group)
407
399
 
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,9 +18,6 @@
18
18
  # and updates to that file get reflected here through a refresh process.
19
19
  # For the short term, the refresh process will only be runnable by Google
20
20
  # engineers.
21
- #
22
- # The only allowed edits are to method and file documentation. A 3-way
23
- # merge preserves those additions if the generated source changes.
24
21
 
25
22
  require "json"
26
23
  require "pathname"
@@ -76,6 +73,7 @@ module Google
76
73
  "https://www.googleapis.com/auth/monitoring.write"
77
74
  ].freeze
78
75
 
76
+
79
77
  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
80
78
  "projects/{project}"
81
79
  )
@@ -150,11 +148,6 @@ module Google
150
148
  # @param timeout [Numeric]
151
149
  # The default timeout, in seconds, for calls made through this client.
152
150
  def initialize \
153
- service_path: SERVICE_ADDRESS,
154
- port: DEFAULT_SERVICE_PORT,
155
- channel: nil,
156
- chan_creds: nil,
157
- updater_proc: nil,
158
151
  credentials: nil,
159
152
  scopes: ALL_SCOPES,
160
153
  client_config: {},
@@ -167,17 +160,6 @@ module Google
167
160
  require "google/gax/grpc"
168
161
  require "google/monitoring/v3/metric_service_services_pb"
169
162
 
170
- if channel || chan_creds || updater_proc
171
- warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
172
- "on 2017/09/08"
173
- credentials ||= channel
174
- credentials ||= chan_creds
175
- credentials ||= updater_proc
176
- end
177
- if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
178
- warn "`service_path` and `port` parameters are deprecated and will be removed"
179
- end
180
-
181
163
  credentials ||= Google::Cloud::Monitoring::Credentials.default
182
164
 
183
165
  if credentials.is_a?(String) || credentials.is_a?(Hash)
@@ -196,9 +178,11 @@ module Google
196
178
  updater_proc = credentials.updater_proc
197
179
  end
198
180
 
181
+ package_version = Gem.loaded_specs['google-cloud-monitoring'].version.version
182
+
199
183
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
200
184
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
201
- google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
185
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
202
186
  google_api_client << " grpc/#{GRPC::VERSION}"
203
187
  google_api_client.freeze
204
188
 
@@ -218,6 +202,10 @@ module Google
218
202
  kwargs: headers
219
203
  )
220
204
  end
205
+
206
+ # Allow overriding the service path/port in subclasses.
207
+ service_path = self.class::SERVICE_ADDRESS
208
+ port = self.class::DEFAULT_SERVICE_PORT
221
209
  @metric_service_stub = Google::Gax::Grpc.create_stub(
222
210
  service_path,
223
211
  port,
@@ -467,6 +455,8 @@ module Google
467
455
  #
468
456
  # metric_service_client = Google::Cloud::Monitoring::V3::Metric.new
469
457
  # formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
458
+ #
459
+ # # TODO: Initialize +metric_descriptor+:
470
460
  # metric_descriptor = {}
471
461
  # response = metric_service_client.create_metric_descriptor(formatted_name, metric_descriptor)
472
462
 
@@ -563,8 +553,14 @@ module Google
563
553
  #
564
554
  # metric_service_client = Google::Cloud::Monitoring::V3::Metric.new
565
555
  # formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
556
+ #
557
+ # # TODO: Initialize +filter+:
566
558
  # filter = ''
559
+ #
560
+ # # TODO: Initialize +interval+:
567
561
  # interval = {}
562
+ #
563
+ # # TODO: Initialize +view+:
568
564
  # view = :FULL
569
565
  #
570
566
  # # Iterate over all results.
@@ -627,6 +623,8 @@ module Google
627
623
  #
628
624
  # metric_service_client = Google::Cloud::Monitoring::V3::Metric.new
629
625
  # formatted_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path("[PROJECT]")
626
+ #
627
+ # # TODO: Initialize +time_series+:
630
628
  # time_series = []
631
629
  # metric_service_client.create_time_series(formatted_name, time_series)
632
630
 
@@ -0,0 +1,557 @@
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/notification_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/notification_service_pb"
28
+ require "google/cloud/monitoring/credentials"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Monitoring
33
+ module V3
34
+ # The Notification Channel API provides access to configuration that
35
+ # controls how messages related to incidents are sent.
36
+ #
37
+ # @!attribute [r] notification_channel_service_stub
38
+ # @return [Google::Monitoring::V3::NotificationChannelService::Stub]
39
+ class NotificationChannelServiceClient
40
+ attr_reader :notification_channel_service_stub
41
+
42
+ # The default address of the service.
43
+ SERVICE_ADDRESS = "monitoring.googleapis.com".freeze
44
+
45
+ # The default port of the service.
46
+ DEFAULT_SERVICE_PORT = 443
47
+
48
+ DEFAULT_TIMEOUT = 30
49
+
50
+ PAGE_DESCRIPTORS = {
51
+ "list_notification_channel_descriptors" => Google::Gax::PageDescriptor.new(
52
+ "page_token",
53
+ "next_page_token",
54
+ "channel_descriptors"),
55
+ "list_notification_channels" => Google::Gax::PageDescriptor.new(
56
+ "page_token",
57
+ "next_page_token",
58
+ "notification_channels")
59
+ }.freeze
60
+
61
+ private_constant :PAGE_DESCRIPTORS
62
+
63
+ # The scopes needed to make gRPC calls to all of the methods defined in
64
+ # this service.
65
+ ALL_SCOPES = [
66
+ "https://www.googleapis.com/auth/cloud-platform",
67
+ "https://www.googleapis.com/auth/monitoring",
68
+ "https://www.googleapis.com/auth/monitoring.read",
69
+ "https://www.googleapis.com/auth/monitoring.write"
70
+ ].freeze
71
+
72
+
73
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
74
+ "projects/{project}"
75
+ )
76
+
77
+ private_constant :PROJECT_PATH_TEMPLATE
78
+
79
+ NOTIFICATION_CHANNEL_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
80
+ "projects/{project}/notificationChannels/{notification_channel}"
81
+ )
82
+
83
+ private_constant :NOTIFICATION_CHANNEL_PATH_TEMPLATE
84
+
85
+ NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
86
+ "projects/{project}/notificationChannelDescriptors/{channel_descriptor}"
87
+ )
88
+
89
+ private_constant :NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE
90
+
91
+ # Returns a fully-qualified project resource name string.
92
+ # @param project [String]
93
+ # @return [String]
94
+ def self.project_path project
95
+ PROJECT_PATH_TEMPLATE.render(
96
+ :"project" => project
97
+ )
98
+ end
99
+
100
+ # Returns a fully-qualified notification_channel resource name string.
101
+ # @param project [String]
102
+ # @param notification_channel [String]
103
+ # @return [String]
104
+ def self.notification_channel_path project, notification_channel
105
+ NOTIFICATION_CHANNEL_PATH_TEMPLATE.render(
106
+ :"project" => project,
107
+ :"notification_channel" => notification_channel
108
+ )
109
+ end
110
+
111
+ # Returns a fully-qualified notification_channel_descriptor resource name string.
112
+ # @param project [String]
113
+ # @param channel_descriptor [String]
114
+ # @return [String]
115
+ def self.notification_channel_descriptor_path project, channel_descriptor
116
+ NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.render(
117
+ :"project" => project,
118
+ :"channel_descriptor" => channel_descriptor
119
+ )
120
+ end
121
+
122
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
123
+ # Provides the means for authenticating requests made by the client. This parameter can
124
+ # be many types.
125
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
126
+ # authenticating requests made by this client.
127
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
128
+ # credentials for this client.
129
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
130
+ # credentials for this client.
131
+ # A `GRPC::Core::Channel` will be used to make calls through.
132
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
133
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
134
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
135
+ # metadata for requests, generally, to give OAuth credentials.
136
+ # @param scopes [Array<String>]
137
+ # The OAuth scopes for this service. This parameter is ignored if
138
+ # an updater_proc is supplied.
139
+ # @param client_config [Hash]
140
+ # A Hash for call options for each method. See
141
+ # Google::Gax#construct_settings for the structure of
142
+ # this data. Falls back to the default config if not specified
143
+ # or the specified config is missing data points.
144
+ # @param timeout [Numeric]
145
+ # The default timeout, in seconds, for calls made through this client.
146
+ def initialize \
147
+ credentials: nil,
148
+ scopes: ALL_SCOPES,
149
+ client_config: {},
150
+ timeout: DEFAULT_TIMEOUT,
151
+ lib_name: nil,
152
+ lib_version: ""
153
+ # These require statements are intentionally placed here to initialize
154
+ # the gRPC module only when it's required.
155
+ # See https://github.com/googleapis/toolkit/issues/446
156
+ require "google/gax/grpc"
157
+ require "google/monitoring/v3/notification_service_services_pb"
158
+
159
+ credentials ||= Google::Cloud::Monitoring::Credentials.default
160
+
161
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
162
+ updater_proc = Google::Cloud::Monitoring::Credentials.new(credentials).updater_proc
163
+ end
164
+ if credentials.is_a?(GRPC::Core::Channel)
165
+ channel = credentials
166
+ end
167
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
168
+ chan_creds = credentials
169
+ end
170
+ if credentials.is_a?(Proc)
171
+ updater_proc = credentials
172
+ end
173
+ if credentials.is_a?(Google::Auth::Credentials)
174
+ updater_proc = credentials.updater_proc
175
+ end
176
+
177
+ package_version = Gem.loaded_specs['google-cloud-monitoring'].version.version
178
+
179
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
180
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
181
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
182
+ google_api_client << " grpc/#{GRPC::VERSION}"
183
+ google_api_client.freeze
184
+
185
+ headers = { :"x-goog-api-client" => google_api_client }
186
+ client_config_file = Pathname.new(__dir__).join(
187
+ "notification_channel_service_client_config.json"
188
+ )
189
+ defaults = client_config_file.open do |f|
190
+ Google::Gax.construct_settings(
191
+ "google.monitoring.v3.NotificationChannelService",
192
+ JSON.parse(f.read),
193
+ client_config,
194
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
195
+ timeout,
196
+ page_descriptors: PAGE_DESCRIPTORS,
197
+ errors: Google::Gax::Grpc::API_ERRORS,
198
+ kwargs: headers
199
+ )
200
+ end
201
+
202
+ # Allow overriding the service path/port in subclasses.
203
+ service_path = self.class::SERVICE_ADDRESS
204
+ port = self.class::DEFAULT_SERVICE_PORT
205
+ @notification_channel_service_stub = Google::Gax::Grpc.create_stub(
206
+ service_path,
207
+ port,
208
+ chan_creds: chan_creds,
209
+ channel: channel,
210
+ updater_proc: updater_proc,
211
+ scopes: scopes,
212
+ &Google::Monitoring::V3::NotificationChannelService::Stub.method(:new)
213
+ )
214
+
215
+ @list_notification_channel_descriptors = Google::Gax.create_api_call(
216
+ @notification_channel_service_stub.method(:list_notification_channel_descriptors),
217
+ defaults["list_notification_channel_descriptors"]
218
+ )
219
+ @get_notification_channel_descriptor = Google::Gax.create_api_call(
220
+ @notification_channel_service_stub.method(:get_notification_channel_descriptor),
221
+ defaults["get_notification_channel_descriptor"]
222
+ )
223
+ @list_notification_channels = Google::Gax.create_api_call(
224
+ @notification_channel_service_stub.method(:list_notification_channels),
225
+ defaults["list_notification_channels"]
226
+ )
227
+ @get_notification_channel = Google::Gax.create_api_call(
228
+ @notification_channel_service_stub.method(:get_notification_channel),
229
+ defaults["get_notification_channel"]
230
+ )
231
+ @create_notification_channel = Google::Gax.create_api_call(
232
+ @notification_channel_service_stub.method(:create_notification_channel),
233
+ defaults["create_notification_channel"]
234
+ )
235
+ @update_notification_channel = Google::Gax.create_api_call(
236
+ @notification_channel_service_stub.method(:update_notification_channel),
237
+ defaults["update_notification_channel"]
238
+ )
239
+ @delete_notification_channel = Google::Gax.create_api_call(
240
+ @notification_channel_service_stub.method(:delete_notification_channel),
241
+ defaults["delete_notification_channel"]
242
+ )
243
+ end
244
+
245
+ # Service calls
246
+
247
+ # Lists the descriptors for supported channel types. The use of descriptors
248
+ # makes it possible for new channel types to be dynamically added.
249
+ #
250
+ # @param name [String]
251
+ # The REST resource name of the parent from which to retrieve
252
+ # the notification channel descriptors. The expected syntax is:
253
+ #
254
+ # projects/[PROJECT_ID]
255
+ #
256
+ # Note that this names the parent container in which to look for the
257
+ # descriptors; to retrieve a single descriptor by name, use the
258
+ # {Google::Monitoring::V3::NotificationChannelService::GetNotificationChannelDescriptor GetNotificationChannelDescriptor}
259
+ # operation, instead.
260
+ # @param page_size [Integer]
261
+ # The maximum number of resources contained in the underlying API
262
+ # response. If page streaming is performed per-resource, this
263
+ # parameter does not affect the return value. If page streaming is
264
+ # performed per-page, this determines the maximum number of
265
+ # resources in a page.
266
+ # @param options [Google::Gax::CallOptions]
267
+ # Overrides the default settings for this call, e.g, timeout,
268
+ # retries, etc.
269
+ # @return [Google::Gax::PagedEnumerable<Google::Monitoring::V3::NotificationChannelDescriptor>]
270
+ # An enumerable of Google::Monitoring::V3::NotificationChannelDescriptor instances.
271
+ # See Google::Gax::PagedEnumerable documentation for other
272
+ # operations such as per-page iteration or access to the response
273
+ # object.
274
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
275
+ # @example
276
+ # require "google/cloud/monitoring/v3"
277
+ #
278
+ # notification_channel_service_client = Google::Cloud::Monitoring::V3::NotificationChannel.new
279
+ # formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.project_path("[PROJECT]")
280
+ #
281
+ # # Iterate over all results.
282
+ # notification_channel_service_client.list_notification_channel_descriptors(formatted_name).each do |element|
283
+ # # Process element.
284
+ # end
285
+ #
286
+ # # Or iterate over results one page at a time.
287
+ # notification_channel_service_client.list_notification_channel_descriptors(formatted_name).each_page do |page|
288
+ # # Process each page at a time.
289
+ # page.each do |element|
290
+ # # Process element.
291
+ # end
292
+ # end
293
+
294
+ def list_notification_channel_descriptors \
295
+ name,
296
+ page_size: nil,
297
+ options: nil
298
+ req = {
299
+ name: name,
300
+ page_size: page_size
301
+ }.delete_if { |_, v| v.nil? }
302
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListNotificationChannelDescriptorsRequest)
303
+ @list_notification_channel_descriptors.call(req, options)
304
+ end
305
+
306
+ # Gets a single channel descriptor. The descriptor indicates which fields
307
+ # are expected / permitted for a notification channel of the given type.
308
+ #
309
+ # @param name [String]
310
+ # The channel type for which to execute the request. The format is
311
+ # +projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}+.
312
+ # @param options [Google::Gax::CallOptions]
313
+ # Overrides the default settings for this call, e.g, timeout,
314
+ # retries, etc.
315
+ # @return [Google::Monitoring::V3::NotificationChannelDescriptor]
316
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
317
+ # @example
318
+ # require "google/cloud/monitoring/v3"
319
+ #
320
+ # notification_channel_service_client = Google::Cloud::Monitoring::V3::NotificationChannel.new
321
+ # formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.notification_channel_descriptor_path("[PROJECT]", "[CHANNEL_DESCRIPTOR]")
322
+ # response = notification_channel_service_client.get_notification_channel_descriptor(formatted_name)
323
+
324
+ def get_notification_channel_descriptor \
325
+ name,
326
+ options: nil
327
+ req = {
328
+ name: name
329
+ }.delete_if { |_, v| v.nil? }
330
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetNotificationChannelDescriptorRequest)
331
+ @get_notification_channel_descriptor.call(req, options)
332
+ end
333
+
334
+ # Lists the notification channels that have been created for the project.
335
+ #
336
+ # @param name [String]
337
+ # The project on which to execute the request. The format is
338
+ # +projects/[PROJECT_ID]+. That is, this names the container
339
+ # in which to look for the notification channels; it does not name a
340
+ # specific channel. To query a specific channel by REST resource name, use
341
+ # the
342
+ # {Google::Monitoring::V3::NotificationChannelService::GetNotificationChannel +GetNotificationChannel+} operation.
343
+ # @param filter [String]
344
+ # If provided, this field specifies the criteria that must be met by
345
+ # notification channels to be included in the response.
346
+ #
347
+ # For more details, see [sorting and
348
+ # filtering](/monitoring/api/v3/sorting-and-filtering).
349
+ # @param order_by [String]
350
+ # A comma-separated list of fields by which to sort the result. Supports
351
+ # the same set of fields as in +filter+. Entries can be prefixed with
352
+ # a minus sign to sort in descending rather than ascending order.
353
+ #
354
+ # For more details, see [sorting and
355
+ # filtering](/monitoring/api/v3/sorting-and-filtering).
356
+ # @param page_size [Integer]
357
+ # The maximum number of resources contained in the underlying API
358
+ # response. If page streaming is performed per-resource, this
359
+ # parameter does not affect the return value. If page streaming is
360
+ # performed per-page, this determines the maximum number of
361
+ # resources in a page.
362
+ # @param options [Google::Gax::CallOptions]
363
+ # Overrides the default settings for this call, e.g, timeout,
364
+ # retries, etc.
365
+ # @return [Google::Gax::PagedEnumerable<Google::Monitoring::V3::NotificationChannel>]
366
+ # An enumerable of Google::Monitoring::V3::NotificationChannel instances.
367
+ # See Google::Gax::PagedEnumerable documentation for other
368
+ # operations such as per-page iteration or access to the response
369
+ # object.
370
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
371
+ # @example
372
+ # require "google/cloud/monitoring/v3"
373
+ #
374
+ # notification_channel_service_client = Google::Cloud::Monitoring::V3::NotificationChannel.new
375
+ # formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.project_path("[PROJECT]")
376
+ #
377
+ # # Iterate over all results.
378
+ # notification_channel_service_client.list_notification_channels(formatted_name).each do |element|
379
+ # # Process element.
380
+ # end
381
+ #
382
+ # # Or iterate over results one page at a time.
383
+ # notification_channel_service_client.list_notification_channels(formatted_name).each_page do |page|
384
+ # # Process each page at a time.
385
+ # page.each do |element|
386
+ # # Process element.
387
+ # end
388
+ # end
389
+
390
+ def list_notification_channels \
391
+ name,
392
+ filter: nil,
393
+ order_by: nil,
394
+ page_size: nil,
395
+ options: nil
396
+ req = {
397
+ name: name,
398
+ filter: filter,
399
+ order_by: order_by,
400
+ page_size: page_size
401
+ }.delete_if { |_, v| v.nil? }
402
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::ListNotificationChannelsRequest)
403
+ @list_notification_channels.call(req, options)
404
+ end
405
+
406
+ # Gets a single notification channel. The channel includes the relevant
407
+ # configuration details with which the channel was created. However, the
408
+ # response may truncate or omit passwords, API keys, or other private key
409
+ # matter and thus the response may not be 100% identical to the information
410
+ # that was supplied in the call to the create method.
411
+ #
412
+ # @param name [String]
413
+ # The channel for which to execute the request. The format is
414
+ # +projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]+.
415
+ # @param options [Google::Gax::CallOptions]
416
+ # Overrides the default settings for this call, e.g, timeout,
417
+ # retries, etc.
418
+ # @return [Google::Monitoring::V3::NotificationChannel]
419
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
420
+ # @example
421
+ # require "google/cloud/monitoring/v3"
422
+ #
423
+ # notification_channel_service_client = Google::Cloud::Monitoring::V3::NotificationChannel.new
424
+ # formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.notification_channel_path("[PROJECT]", "[NOTIFICATION_CHANNEL]")
425
+ # response = notification_channel_service_client.get_notification_channel(formatted_name)
426
+
427
+ def get_notification_channel \
428
+ name,
429
+ options: nil
430
+ req = {
431
+ name: name
432
+ }.delete_if { |_, v| v.nil? }
433
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::GetNotificationChannelRequest)
434
+ @get_notification_channel.call(req, options)
435
+ end
436
+
437
+ # Creates a new notification channel, representing a single notification
438
+ # endpoint such as an email address, SMS number, or pagerduty service.
439
+ #
440
+ # @param name [String]
441
+ # The project on which to execute the request. The format is:
442
+ #
443
+ # projects/[PROJECT_ID]
444
+ #
445
+ # Note that this names the container into which the channel will be
446
+ # written. This does not name the newly created channel. The resulting
447
+ # channel's name will have a normalized version of this field as a prefix,
448
+ # but will add +/notificationChannels/[CHANNEL_ID]+ to identify the channel.
449
+ # @param notification_channel [Google::Monitoring::V3::NotificationChannel | Hash]
450
+ # The definition of the +NotificationChannel+ to create.
451
+ # A hash of the same form as `Google::Monitoring::V3::NotificationChannel`
452
+ # can also be provided.
453
+ # @param options [Google::Gax::CallOptions]
454
+ # Overrides the default settings for this call, e.g, timeout,
455
+ # retries, etc.
456
+ # @return [Google::Monitoring::V3::NotificationChannel]
457
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
458
+ # @example
459
+ # require "google/cloud/monitoring/v3"
460
+ #
461
+ # notification_channel_service_client = Google::Cloud::Monitoring::V3::NotificationChannel.new
462
+ # formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.project_path("[PROJECT]")
463
+ #
464
+ # # TODO: Initialize +notification_channel+:
465
+ # notification_channel = {}
466
+ # response = notification_channel_service_client.create_notification_channel(formatted_name, notification_channel)
467
+
468
+ def create_notification_channel \
469
+ name,
470
+ notification_channel,
471
+ options: nil
472
+ req = {
473
+ name: name,
474
+ notification_channel: notification_channel
475
+ }.delete_if { |_, v| v.nil? }
476
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::CreateNotificationChannelRequest)
477
+ @create_notification_channel.call(req, options)
478
+ end
479
+
480
+ # Updates a notification channel. Fields not specified in the field mask
481
+ # remain unchanged.
482
+ #
483
+ # @param notification_channel [Google::Monitoring::V3::NotificationChannel | Hash]
484
+ # A description of the changes to be applied to the specified
485
+ # notification channel. The description must provide a definition for
486
+ # fields to be updated; the names of these fields should also be
487
+ # included in the +update_mask+.
488
+ # A hash of the same form as `Google::Monitoring::V3::NotificationChannel`
489
+ # can also be provided.
490
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
491
+ # The fields to update.
492
+ # A hash of the same form as `Google::Protobuf::FieldMask`
493
+ # can also be provided.
494
+ # @param options [Google::Gax::CallOptions]
495
+ # Overrides the default settings for this call, e.g, timeout,
496
+ # retries, etc.
497
+ # @return [Google::Monitoring::V3::NotificationChannel]
498
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
499
+ # @example
500
+ # require "google/cloud/monitoring/v3"
501
+ #
502
+ # notification_channel_service_client = Google::Cloud::Monitoring::V3::NotificationChannel.new
503
+ #
504
+ # # TODO: Initialize +notification_channel+:
505
+ # notification_channel = {}
506
+ # response = notification_channel_service_client.update_notification_channel(notification_channel)
507
+
508
+ def update_notification_channel \
509
+ notification_channel,
510
+ update_mask: nil,
511
+ options: nil
512
+ req = {
513
+ notification_channel: notification_channel,
514
+ update_mask: update_mask
515
+ }.delete_if { |_, v| v.nil? }
516
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::UpdateNotificationChannelRequest)
517
+ @update_notification_channel.call(req, options)
518
+ end
519
+
520
+ # Deletes a notification channel.
521
+ #
522
+ # @param name [String]
523
+ # The channel for which to execute the request. The format is
524
+ # +projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]+.
525
+ # @param force [true, false]
526
+ # If true, the notification channel will be deleted regardless of its
527
+ # use in alert policies (the policies will be updated to remove the
528
+ # channel). If false, channels that are still referenced by an existing
529
+ # alerting policy will fail to be deleted in a delete operation.
530
+ # @param options [Google::Gax::CallOptions]
531
+ # Overrides the default settings for this call, e.g, timeout,
532
+ # retries, etc.
533
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
534
+ # @example
535
+ # require "google/cloud/monitoring/v3"
536
+ #
537
+ # notification_channel_service_client = Google::Cloud::Monitoring::V3::NotificationChannel.new
538
+ # formatted_name = Google::Cloud::Monitoring::V3::NotificationChannelServiceClient.notification_channel_path("[PROJECT]", "[NOTIFICATION_CHANNEL]")
539
+ # notification_channel_service_client.delete_notification_channel(formatted_name)
540
+
541
+ def delete_notification_channel \
542
+ name,
543
+ force: nil,
544
+ options: nil
545
+ req = {
546
+ name: name,
547
+ force: force
548
+ }.delete_if { |_, v| v.nil? }
549
+ req = Google::Gax::to_proto(req, Google::Monitoring::V3::DeleteNotificationChannelRequest)
550
+ @delete_notification_channel.call(req, options)
551
+ nil
552
+ end
553
+ end
554
+ end
555
+ end
556
+ end
557
+ end