google-cloud-error_reporting 0.27.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,7 @@ require "pathname"
28
28
  require "google/gax"
29
29
 
30
30
  require "google/devtools/clouderrorreporting/v1beta1/error_stats_service_pb"
31
+ require "google/cloud/error_reporting/credentials"
31
32
 
32
33
  module Google
33
34
  module Cloud
@@ -83,22 +84,24 @@ module Google
83
84
  )
84
85
  end
85
86
 
86
- # Parses the project from a project resource.
87
- # @param project_name [String]
88
- # @return [String]
89
- def self.match_project_from_project_name project_name
90
- PROJECT_PATH_TEMPLATE.match(project_name)["project"]
91
- end
92
-
93
- # @param service_path [String]
94
- # The domain name of the API remote host.
95
- # @param port [Integer]
96
- # The port on which to connect to the remote host.
97
- # @param channel [Channel]
98
- # A Channel object through which to make calls.
99
- # @param chan_creds [Grpc::ChannelCredentials]
100
- # A ChannelCredentials for the setting up the RPC client.
101
- # @param client_config[Hash]
87
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
88
+ # Provides the means for authenticating requests made by the client. This parameter can
89
+ # be many types.
90
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
91
+ # authenticating requests made by this client.
92
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
93
+ # credentials for this client.
94
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
95
+ # credentials for this client.
96
+ # A `GRPC::Core::Channel` will be used to make calls through.
97
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
98
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
99
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
100
+ # metadata for requests, generally, to give OAuth credentials.
101
+ # @param scopes [Array<String>]
102
+ # The OAuth scopes for this service. This parameter is ignored if
103
+ # an updater_proc is supplied.
104
+ # @param client_config [Hash]
102
105
  # A Hash for call options for each method. See
103
106
  # Google::Gax#construct_settings for the structure of
104
107
  # this data. Falls back to the default config if not specified
@@ -110,11 +113,11 @@ module Google
110
113
  port: DEFAULT_SERVICE_PORT,
111
114
  channel: nil,
112
115
  chan_creds: nil,
116
+ updater_proc: nil,
117
+ credentials: nil,
113
118
  scopes: ALL_SCOPES,
114
119
  client_config: {},
115
120
  timeout: DEFAULT_TIMEOUT,
116
- app_name: nil,
117
- app_version: nil,
118
121
  lib_name: nil,
119
122
  lib_version: ""
120
123
  # These require statements are intentionally placed here to initialize
@@ -123,14 +126,38 @@ module Google
123
126
  require "google/gax/grpc"
124
127
  require "google/devtools/clouderrorreporting/v1beta1/error_stats_service_services_pb"
125
128
 
129
+ if channel || chan_creds || updater_proc
130
+ warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
131
+ "on 2017/09/08"
132
+ credentials ||= channel
133
+ credentials ||= chan_creds
134
+ credentials ||= updater_proc
135
+ end
136
+ if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
137
+ warn "`service_path` and `port` parameters are deprecated and will be removed"
138
+ end
139
+
140
+ credentials ||= Google::Cloud::ErrorReporting::Credentials.default
126
141
 
127
- if app_name || app_version
128
- warn "`app_name` and `app_version` are no longer being used in the request headers."
142
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
143
+ updater_proc = Google::Cloud::ErrorReporting::Credentials.new(credentials).updater_proc
144
+ end
145
+ if credentials.is_a?(GRPC::Core::Channel)
146
+ channel = credentials
147
+ end
148
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
149
+ chan_creds = credentials
150
+ end
151
+ if credentials.is_a?(Proc)
152
+ updater_proc = credentials
153
+ end
154
+ if credentials.is_a?(Google::Auth::Credentials)
155
+ updater_proc = credentials.updater_proc
129
156
  end
130
157
 
131
158
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
132
159
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
133
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
160
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
134
161
  google_api_client << " grpc/#{GRPC::VERSION}"
135
162
  google_api_client.freeze
136
163
 
@@ -155,6 +182,7 @@ module Google
155
182
  port,
156
183
  chan_creds: chan_creds,
157
184
  channel: channel,
185
+ updater_proc: updater_proc,
158
186
  scopes: scopes,
159
187
  &Google::Devtools::Clouderrorreporting::V1beta1::ErrorStatsService::Stub.method(:new)
160
188
  )
@@ -184,7 +212,7 @@ module Google
184
212
  # Platform project ID</a>.
185
213
  #
186
214
  # Example: <code>projects/my-project-123</code>.
187
- # @param time_range [Google::Devtools::Clouderrorreporting::V1beta1::QueryTimeRange]
215
+ # @param time_range [Google::Devtools::Clouderrorreporting::V1beta1::QueryTimeRange | Hash]
188
216
  # [Optional] List data for the given time range.
189
217
  # If not set a default time range is used. The field time_range_begin
190
218
  # in the response will specify the beginning of this time range.
@@ -192,21 +220,29 @@ module Google
192
220
  # range are returned, unless the request contains an explicit group_id list.
193
221
  # If a group_id list is given, also <code>ErrorGroupStats</code> with zero
194
222
  # occurrences are returned.
223
+ # A hash of the same form as `Google::Devtools::Clouderrorreporting::V1beta1::QueryTimeRange`
224
+ # can also be provided.
195
225
  # @param group_id [Array<String>]
196
226
  # [Optional] List all <code>ErrorGroupStats</code> with these IDs.
197
- # @param service_filter [Google::Devtools::Clouderrorreporting::V1beta1::ServiceContextFilter]
227
+ # @param service_filter [Google::Devtools::Clouderrorreporting::V1beta1::ServiceContextFilter | Hash]
198
228
  # [Optional] List only <code>ErrorGroupStats</code> which belong to a service
199
229
  # context that matches the filter.
200
230
  # Data for all service contexts is returned if this field is not specified.
201
- # @param timed_count_duration [Google::Protobuf::Duration]
231
+ # A hash of the same form as `Google::Devtools::Clouderrorreporting::V1beta1::ServiceContextFilter`
232
+ # can also be provided.
233
+ # @param timed_count_duration [Google::Protobuf::Duration | Hash]
202
234
  # [Optional] The preferred duration for a single returned +TimedCount+.
203
235
  # If not set, no timed counts are returned.
236
+ # A hash of the same form as `Google::Protobuf::Duration`
237
+ # can also be provided.
204
238
  # @param alignment [Google::Devtools::Clouderrorreporting::V1beta1::TimedCountAlignment]
205
239
  # [Optional] The alignment of the timed counts to be returned.
206
240
  # Default is +ALIGNMENT_EQUAL_AT_END+.
207
- # @param alignment_time [Google::Protobuf::Timestamp]
241
+ # @param alignment_time [Google::Protobuf::Timestamp | Hash]
208
242
  # [Optional] Time where the timed counts shall be aligned if rounded
209
243
  # alignment is chosen. Default is 00:00 UTC.
244
+ # A hash of the same form as `Google::Protobuf::Timestamp`
245
+ # can also be provided.
210
246
  # @param order [Google::Devtools::Clouderrorreporting::V1beta1::ErrorGroupOrder]
211
247
  # [Optional] The sort order in which the results are returned.
212
248
  # Default is +COUNT_DESC+.
@@ -226,14 +262,11 @@ module Google
226
262
  # object.
227
263
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
228
264
  # @example
229
- # require "google/cloud/error_reporting/v1beta1/error_stats_service_client"
265
+ # require "google/cloud/error_reporting/v1beta1"
230
266
  #
231
- # ErrorStatsServiceClient = Google::Cloud::ErrorReporting::V1beta1::ErrorStatsServiceClient
232
- # QueryTimeRange = Google::Devtools::Clouderrorreporting::V1beta1::QueryTimeRange
233
- #
234
- # error_stats_service_client = ErrorStatsServiceClient.new
235
- # formatted_project_name = ErrorStatsServiceClient.project_path("[PROJECT]")
236
- # time_range = QueryTimeRange.new
267
+ # error_stats_service_client = Google::Cloud::ErrorReporting::V1beta1::ErrorStats.new
268
+ # formatted_project_name = Google::Cloud::ErrorReporting::V1beta1::ErrorStatsServiceClient.project_path("[PROJECT]")
269
+ # time_range = {}
237
270
  #
238
271
  # # Iterate over all results.
239
272
  # error_stats_service_client.list_group_stats(formatted_project_name, time_range).each do |element|
@@ -259,7 +292,7 @@ module Google
259
292
  order: nil,
260
293
  page_size: nil,
261
294
  options: nil
262
- req = Google::Devtools::Clouderrorreporting::V1beta1::ListGroupStatsRequest.new({
295
+ req = {
263
296
  project_name: project_name,
264
297
  time_range: time_range,
265
298
  group_id: group_id,
@@ -269,7 +302,8 @@ module Google
269
302
  alignment_time: alignment_time,
270
303
  order: order,
271
304
  page_size: page_size
272
- }.delete_if { |_, v| v.nil? })
305
+ }.delete_if { |_, v| v.nil? }
306
+ req = Google::Gax::to_proto(req, Google::Devtools::Clouderrorreporting::V1beta1::ListGroupStatsRequest)
273
307
  @list_group_stats.call(req, options)
274
308
  end
275
309
 
@@ -278,19 +312,23 @@ module Google
278
312
  # @param project_name [String]
279
313
  # [Required] The resource name of the Google Cloud Platform project. Written
280
314
  # as +projects/+ plus the
281
- # {Google Cloud Platform project
282
- # ID}[https://support.google.com/cloud/answer/6158840].
315
+ # [Google Cloud Platform project
316
+ # ID](https://support.google.com/cloud/answer/6158840).
283
317
  # Example: +projects/my-project-123+.
284
318
  # @param group_id [String]
285
319
  # [Required] The group for which events shall be returned.
286
- # @param service_filter [Google::Devtools::Clouderrorreporting::V1beta1::ServiceContextFilter]
320
+ # @param service_filter [Google::Devtools::Clouderrorreporting::V1beta1::ServiceContextFilter | Hash]
287
321
  # [Optional] List only ErrorGroups which belong to a service context that
288
322
  # matches the filter.
289
323
  # Data for all service contexts is returned if this field is not specified.
290
- # @param time_range [Google::Devtools::Clouderrorreporting::V1beta1::QueryTimeRange]
324
+ # A hash of the same form as `Google::Devtools::Clouderrorreporting::V1beta1::ServiceContextFilter`
325
+ # can also be provided.
326
+ # @param time_range [Google::Devtools::Clouderrorreporting::V1beta1::QueryTimeRange | Hash]
291
327
  # [Optional] List only data for the given time range.
292
328
  # If not set a default time range is used. The field time_range_begin
293
329
  # in the response will specify the beginning of this time range.
330
+ # A hash of the same form as `Google::Devtools::Clouderrorreporting::V1beta1::QueryTimeRange`
331
+ # can also be provided.
294
332
  # @param page_size [Integer]
295
333
  # The maximum number of resources contained in the underlying API
296
334
  # response. If page streaming is performed per-resource, this
@@ -307,12 +345,10 @@ module Google
307
345
  # object.
308
346
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
309
347
  # @example
310
- # require "google/cloud/error_reporting/v1beta1/error_stats_service_client"
311
- #
312
- # ErrorStatsServiceClient = Google::Cloud::ErrorReporting::V1beta1::ErrorStatsServiceClient
348
+ # require "google/cloud/error_reporting/v1beta1"
313
349
  #
314
- # error_stats_service_client = ErrorStatsServiceClient.new
315
- # formatted_project_name = ErrorStatsServiceClient.project_path("[PROJECT]")
350
+ # error_stats_service_client = Google::Cloud::ErrorReporting::V1beta1::ErrorStats.new
351
+ # formatted_project_name = Google::Cloud::ErrorReporting::V1beta1::ErrorStatsServiceClient.project_path("[PROJECT]")
316
352
  # group_id = ''
317
353
  #
318
354
  # # Iterate over all results.
@@ -335,13 +371,14 @@ module Google
335
371
  time_range: nil,
336
372
  page_size: nil,
337
373
  options: nil
338
- req = Google::Devtools::Clouderrorreporting::V1beta1::ListEventsRequest.new({
374
+ req = {
339
375
  project_name: project_name,
340
376
  group_id: group_id,
341
377
  service_filter: service_filter,
342
378
  time_range: time_range,
343
379
  page_size: page_size
344
- }.delete_if { |_, v| v.nil? })
380
+ }.delete_if { |_, v| v.nil? }
381
+ req = Google::Gax::to_proto(req, Google::Devtools::Clouderrorreporting::V1beta1::ListEventsRequest)
345
382
  @list_events.call(req, options)
346
383
  end
347
384
 
@@ -350,8 +387,8 @@ module Google
350
387
  # @param project_name [String]
351
388
  # [Required] The resource name of the Google Cloud Platform project. Written
352
389
  # as +projects/+ plus the
353
- # {Google Cloud Platform project
354
- # ID}[https://support.google.com/cloud/answer/6158840].
390
+ # [Google Cloud Platform project
391
+ # ID](https://support.google.com/cloud/answer/6158840).
355
392
  # Example: +projects/my-project-123+.
356
393
  # @param options [Google::Gax::CallOptions]
357
394
  # Overrides the default settings for this call, e.g, timeout,
@@ -359,20 +396,19 @@ module Google
359
396
  # @return [Google::Devtools::Clouderrorreporting::V1beta1::DeleteEventsResponse]
360
397
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
361
398
  # @example
362
- # require "google/cloud/error_reporting/v1beta1/error_stats_service_client"
363
- #
364
- # ErrorStatsServiceClient = Google::Cloud::ErrorReporting::V1beta1::ErrorStatsServiceClient
399
+ # require "google/cloud/error_reporting/v1beta1"
365
400
  #
366
- # error_stats_service_client = ErrorStatsServiceClient.new
367
- # formatted_project_name = ErrorStatsServiceClient.project_path("[PROJECT]")
401
+ # error_stats_service_client = Google::Cloud::ErrorReporting::V1beta1::ErrorStats.new
402
+ # formatted_project_name = Google::Cloud::ErrorReporting::V1beta1::ErrorStatsServiceClient.project_path("[PROJECT]")
368
403
  # response = error_stats_service_client.delete_events(formatted_project_name)
369
404
 
370
405
  def delete_events \
371
406
  project_name,
372
407
  options: nil
373
- req = Google::Devtools::Clouderrorreporting::V1beta1::DeleteEventsRequest.new({
408
+ req = {
374
409
  project_name: project_name
375
- }.delete_if { |_, v| v.nil? })
410
+ }.delete_if { |_, v| v.nil? }
411
+ req = Google::Gax::to_proto(req, Google::Devtools::Clouderrorreporting::V1beta1::DeleteEventsRequest)
376
412
  @delete_events.call(req, options)
377
413
  end
378
414
  end
@@ -28,6 +28,7 @@ require "pathname"
28
28
  require "google/gax"
29
29
 
30
30
  require "google/devtools/clouderrorreporting/v1beta1/report_errors_service_pb"
31
+ require "google/cloud/error_reporting/credentials"
31
32
 
32
33
  module Google
33
34
  module Cloud
@@ -69,22 +70,24 @@ module Google
69
70
  )
70
71
  end
71
72
 
72
- # Parses the project from a project resource.
73
- # @param project_name [String]
74
- # @return [String]
75
- def self.match_project_from_project_name project_name
76
- PROJECT_PATH_TEMPLATE.match(project_name)["project"]
77
- end
78
-
79
- # @param service_path [String]
80
- # The domain name of the API remote host.
81
- # @param port [Integer]
82
- # The port on which to connect to the remote host.
83
- # @param channel [Channel]
84
- # A Channel object through which to make calls.
85
- # @param chan_creds [Grpc::ChannelCredentials]
86
- # A ChannelCredentials for the setting up the RPC client.
87
- # @param client_config[Hash]
73
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
74
+ # Provides the means for authenticating requests made by the client. This parameter can
75
+ # be many types.
76
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
77
+ # authenticating requests made by this client.
78
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
79
+ # credentials for this client.
80
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
81
+ # credentials for this client.
82
+ # A `GRPC::Core::Channel` will be used to make calls through.
83
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
84
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
85
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
86
+ # metadata for requests, generally, to give OAuth credentials.
87
+ # @param scopes [Array<String>]
88
+ # The OAuth scopes for this service. This parameter is ignored if
89
+ # an updater_proc is supplied.
90
+ # @param client_config [Hash]
88
91
  # A Hash for call options for each method. See
89
92
  # Google::Gax#construct_settings for the structure of
90
93
  # this data. Falls back to the default config if not specified
@@ -96,11 +99,11 @@ module Google
96
99
  port: DEFAULT_SERVICE_PORT,
97
100
  channel: nil,
98
101
  chan_creds: nil,
102
+ updater_proc: nil,
103
+ credentials: nil,
99
104
  scopes: ALL_SCOPES,
100
105
  client_config: {},
101
106
  timeout: DEFAULT_TIMEOUT,
102
- app_name: nil,
103
- app_version: nil,
104
107
  lib_name: nil,
105
108
  lib_version: ""
106
109
  # These require statements are intentionally placed here to initialize
@@ -109,14 +112,38 @@ module Google
109
112
  require "google/gax/grpc"
110
113
  require "google/devtools/clouderrorreporting/v1beta1/report_errors_service_services_pb"
111
114
 
115
+ if channel || chan_creds || updater_proc
116
+ warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
117
+ "on 2017/09/08"
118
+ credentials ||= channel
119
+ credentials ||= chan_creds
120
+ credentials ||= updater_proc
121
+ end
122
+ if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
123
+ warn "`service_path` and `port` parameters are deprecated and will be removed"
124
+ end
125
+
126
+ credentials ||= Google::Cloud::ErrorReporting::Credentials.default
112
127
 
113
- if app_name || app_version
114
- warn "`app_name` and `app_version` are no longer being used in the request headers."
128
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
129
+ updater_proc = Google::Cloud::ErrorReporting::Credentials.new(credentials).updater_proc
130
+ end
131
+ if credentials.is_a?(GRPC::Core::Channel)
132
+ channel = credentials
133
+ end
134
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
135
+ chan_creds = credentials
136
+ end
137
+ if credentials.is_a?(Proc)
138
+ updater_proc = credentials
139
+ end
140
+ if credentials.is_a?(Google::Auth::Credentials)
141
+ updater_proc = credentials.updater_proc
115
142
  end
116
143
 
117
144
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
118
145
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
119
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
146
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
120
147
  google_api_client << " grpc/#{GRPC::VERSION}"
121
148
  google_api_client.freeze
122
149
 
@@ -140,6 +167,7 @@ module Google
140
167
  port,
141
168
  chan_creds: chan_creds,
142
169
  channel: channel,
170
+ updater_proc: updater_proc,
143
171
  scopes: scopes,
144
172
  &Google::Devtools::Clouderrorreporting::V1beta1::ReportErrorsService::Stub.method(:new)
145
173
  )
@@ -164,34 +192,34 @@ module Google
164
192
  # @param project_name [String]
165
193
  # [Required] The resource name of the Google Cloud Platform project. Written
166
194
  # as +projects/+ plus the
167
- # {Google Cloud Platform project ID}[https://support.google.com/cloud/answer/6158840].
195
+ # [Google Cloud Platform project ID](https://support.google.com/cloud/answer/6158840).
168
196
  # Example: +projects/my-project-123+.
169
- # @param event [Google::Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent]
197
+ # @param event [Google::Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent | Hash]
170
198
  # [Required] The error event to be reported.
199
+ # A hash of the same form as `Google::Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent`
200
+ # can also be provided.
171
201
  # @param options [Google::Gax::CallOptions]
172
202
  # Overrides the default settings for this call, e.g, timeout,
173
203
  # retries, etc.
174
204
  # @return [Google::Devtools::Clouderrorreporting::V1beta1::ReportErrorEventResponse]
175
205
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
176
206
  # @example
177
- # require "google/cloud/error_reporting/v1beta1/report_errors_service_client"
178
- #
179
- # ReportErrorsServiceClient = Google::Cloud::ErrorReporting::V1beta1::ReportErrorsServiceClient
180
- # ReportedErrorEvent = Google::Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent
207
+ # require "google/cloud/error_reporting/v1beta1"
181
208
  #
182
- # report_errors_service_client = ReportErrorsServiceClient.new
183
- # formatted_project_name = ReportErrorsServiceClient.project_path("[PROJECT]")
184
- # event = ReportedErrorEvent.new
209
+ # report_errors_service_client = Google::Cloud::ErrorReporting::V1beta1::ReportErrors.new
210
+ # formatted_project_name = Google::Cloud::ErrorReporting::V1beta1::ReportErrorsServiceClient.project_path("[PROJECT]")
211
+ # event = {}
185
212
  # response = report_errors_service_client.report_error_event(formatted_project_name, event)
186
213
 
187
214
  def report_error_event \
188
215
  project_name,
189
216
  event,
190
217
  options: nil
191
- req = Google::Devtools::Clouderrorreporting::V1beta1::ReportErrorEventRequest.new({
218
+ req = {
192
219
  project_name: project_name,
193
220
  event: event
194
- }.delete_if { |_, v| v.nil? })
221
+ }.delete_if { |_, v| v.nil? }
222
+ req = Google::Gax::to_proto(req, Google::Devtools::Clouderrorreporting::V1beta1::ReportErrorEventRequest)
195
223
  @report_error_event.call(req, options)
196
224
  end
197
225
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module ErrorReporting
19
- VERSION = "0.27.0".freeze
19
+ VERSION = "0.28.0".freeze
20
20
  end
21
21
  end
22
22
  end