google-cloud-debugger 0.28.2 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,37 +25,22 @@ module Google
25
25
  # @private Represents the gRPC Debugger service, including all the API
26
26
  # methods.
27
27
  class Service
28
- attr_accessor :project, :credentials, :host, :timeout, :client_config
28
+ attr_accessor :project, :credentials, :timeout, :client_config
29
29
 
30
30
  ##
31
31
  # Creates a new Service instance.
32
- def initialize project, credentials, host: nil, timeout: nil,
33
- client_config: nil
32
+ def initialize project, credentials, timeout: nil, client_config: nil
34
33
  @project = project
35
34
  @credentials = credentials
36
- @host = host || V2::Controller2Client::SERVICE_ADDRESS
37
35
  @timeout = timeout
38
36
  @client_config = client_config || {}
39
37
  end
40
38
 
41
- def channel
42
- require "grpc"
43
- GRPC::Core::Channel.new host, nil, chan_creds
44
- end
45
-
46
- def chan_creds
47
- return credentials if insecure?
48
- require "grpc"
49
- GRPC::Core::ChannelCredentials.new.compose \
50
- GRPC::Core::CallCredentials.new credentials.client.updater_proc
51
- end
52
-
53
39
  def cloud_debugger
54
40
  return mocked_debugger if mocked_debugger
55
41
  @debugger ||=
56
42
  V2::Controller2Client.new(
57
- service_path: host,
58
- channel: channel,
43
+ credentials: credentials,
59
44
  timeout: timeout,
60
45
  client_config: client_config,
61
46
  lib_name: "gccl",
@@ -67,8 +52,7 @@ module Google
67
52
  return mocked_transmitter if mocked_transmitter
68
53
  @transmitter ||=
69
54
  V2::Controller2Client.new(
70
- service_path: host,
71
- channel: channel,
55
+ credentials: credentials,
72
56
  timeout: timeout,
73
57
  client_config: client_config,
74
58
  lib_name: "gccl",
@@ -76,10 +60,6 @@ module Google
76
60
  end
77
61
  attr_accessor :mocked_transmitter
78
62
 
79
- def insecure?
80
- credentials == :this_channel_is_insecure
81
- end
82
-
83
63
  def register_debuggee debuggee_grpc
84
64
  execute do
85
65
  cloud_debugger.register_debuggee debuggee_grpc,
@@ -1,4 +1,5 @@
1
1
  # Copyright 2017, Google Inc. All rights reserved.
2
+ #
2
3
  # Licensed under the Apache License, Version 2.0 (the "License");
3
4
  # you may not use this file except in compliance with the License.
4
5
  # You may obtain a copy of the License at
@@ -13,3 +14,184 @@
13
14
 
14
15
  require "google/cloud/debugger/v2/debugger2_client"
15
16
  require "google/cloud/debugger/v2/controller2_client"
17
+
18
+ module Google
19
+ module Cloud
20
+ # rubocop:disable LineLength
21
+
22
+ ##
23
+ # # Ruby Client for Stackdriver Debugger API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
24
+ #
25
+ # [Stackdriver Debugger API][Product Documentation]:
26
+ # Examines the call stack and variables of a running application
27
+ # without stopping or slowing it down.
28
+ # - [Product Documentation][]
29
+ #
30
+ # ## Quick Start
31
+ # In order to use this library, you first need to go through the following
32
+ # steps:
33
+ #
34
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
35
+ # 2. [Enable the Stackdriver Debugger API.](https://console.cloud.google.com/apis/api/debugger)
36
+ # 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
37
+ #
38
+ # ### Next Steps
39
+ # - Read the [Stackdriver Debugger API Product documentation][Product Documentation]
40
+ # to learn more about the product and see How-to Guides.
41
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
42
+ # to see the full list of Cloud APIs that we cover.
43
+ #
44
+ # [Product Documentation]: https://cloud.google.com/debugger
45
+ #
46
+ #
47
+ module Debugger
48
+ module V2
49
+ # rubocop:enable LineLength
50
+
51
+ module Debugger2
52
+ ##
53
+ # The Debugger service provides the API that allows users to collect run-time
54
+ # information from a running application, without stopping or slowing it down
55
+ # and without modifying its state. An application may include one or
56
+ # more replicated processes performing the same work.
57
+ #
58
+ # A debugged application is represented using the Debuggee concept. The
59
+ # Debugger service provides a way to query for available debuggees, but does
60
+ # not provide a way to create one. A debuggee is created using the Controller
61
+ # service, usually by running a debugger agent with the application.
62
+ #
63
+ # The Debugger service enables the client to set one or more Breakpoints on a
64
+ # Debuggee and collect the results of the set Breakpoints.
65
+ #
66
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
67
+ # Provides the means for authenticating requests made by the client. This parameter can
68
+ # be many types.
69
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
70
+ # authenticating requests made by this client.
71
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
72
+ # credentials for this client.
73
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
74
+ # credentials for this client.
75
+ # A `GRPC::Core::Channel` will be used to make calls through.
76
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
77
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
78
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
79
+ # metadata for requests, generally, to give OAuth credentials.
80
+ # @param scopes [Array<String>]
81
+ # The OAuth scopes for this service. This parameter is ignored if
82
+ # an updater_proc is supplied.
83
+ # @param client_config [Hash]
84
+ # A Hash for call options for each method. See
85
+ # Google::Gax#construct_settings for the structure of
86
+ # this data. Falls back to the default config if not specified
87
+ # or the specified config is missing data points.
88
+ # @param timeout [Numeric]
89
+ # The default timeout, in seconds, for calls made through this client.
90
+ def self.new \
91
+ service_path: nil,
92
+ port: nil,
93
+ channel: nil,
94
+ chan_creds: nil,
95
+ updater_proc: nil,
96
+ credentials: nil,
97
+ scopes: nil,
98
+ client_config: nil,
99
+ timeout: nil,
100
+ lib_name: nil,
101
+ lib_version: nil
102
+ kwargs = {
103
+ service_path: service_path,
104
+ port: port,
105
+ channel: channel,
106
+ chan_creds: chan_creds,
107
+ updater_proc: updater_proc,
108
+ credentials: credentials,
109
+ scopes: scopes,
110
+ client_config: client_config,
111
+ timeout: timeout,
112
+ lib_name: lib_name,
113
+ lib_version: lib_version
114
+ }.select { |_, v| v != nil }
115
+ Google::Cloud::Debugger::V2::Debugger2Client.new(**kwargs)
116
+ end
117
+ end
118
+
119
+ module Controller2
120
+ ##
121
+ # The Controller service provides the API for orchestrating a collection of
122
+ # debugger agents to perform debugging tasks. These agents are each attached
123
+ # to a process of an application which may include one or more replicas.
124
+ #
125
+ # The debugger agents register with the Controller to identify the application
126
+ # being debugged, the Debuggee. All agents that register with the same data,
127
+ # represent the same Debuggee, and are assigned the same +debuggee_id+.
128
+ #
129
+ # The debugger agents call the Controller to retrieve the list of active
130
+ # Breakpoints. Agents with the same +debuggee_id+ get the same breakpoints
131
+ # list. An agent that can fulfill the breakpoint request updates the
132
+ # Controller with the breakpoint result. The controller selects the first
133
+ # result received and discards the rest of the results.
134
+ # Agents that poll again for active breakpoints will no longer have
135
+ # the completed breakpoint in the list and should remove that breakpoint from
136
+ # their attached process.
137
+ #
138
+ # The Controller service does not provide a way to retrieve the results of
139
+ # a completed breakpoint. This functionality is available using the Debugger
140
+ # service.
141
+ #
142
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
143
+ # Provides the means for authenticating requests made by the client. This parameter can
144
+ # be many types.
145
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
146
+ # authenticating requests made by this client.
147
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
148
+ # credentials for this client.
149
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
150
+ # credentials for this client.
151
+ # A `GRPC::Core::Channel` will be used to make calls through.
152
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
153
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
154
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
155
+ # metadata for requests, generally, to give OAuth credentials.
156
+ # @param scopes [Array<String>]
157
+ # The OAuth scopes for this service. This parameter is ignored if
158
+ # an updater_proc is supplied.
159
+ # @param client_config [Hash]
160
+ # A Hash for call options for each method. See
161
+ # Google::Gax#construct_settings for the structure of
162
+ # this data. Falls back to the default config if not specified
163
+ # or the specified config is missing data points.
164
+ # @param timeout [Numeric]
165
+ # The default timeout, in seconds, for calls made through this client.
166
+ def self.new \
167
+ service_path: nil,
168
+ port: nil,
169
+ channel: nil,
170
+ chan_creds: nil,
171
+ updater_proc: nil,
172
+ credentials: nil,
173
+ scopes: nil,
174
+ client_config: nil,
175
+ timeout: nil,
176
+ lib_name: nil,
177
+ lib_version: nil
178
+ kwargs = {
179
+ service_path: service_path,
180
+ port: port,
181
+ channel: channel,
182
+ chan_creds: chan_creds,
183
+ updater_proc: updater_proc,
184
+ credentials: credentials,
185
+ scopes: scopes,
186
+ client_config: client_config,
187
+ timeout: timeout,
188
+ lib_name: lib_name,
189
+ lib_version: lib_version
190
+ }.select { |_, v| v != nil }
191
+ Google::Cloud::Debugger::V2::Controller2Client.new(**kwargs)
192
+ end
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end
@@ -28,6 +28,7 @@ require "pathname"
28
28
  require "google/gax"
29
29
 
30
30
  require "google/devtools/clouddebugger/v2/controller_pb"
31
+ require "google/cloud/debugger/credentials"
31
32
 
32
33
  module Google
33
34
  module Cloud
@@ -74,21 +75,24 @@ module Google
74
75
  "https://www.googleapis.com/auth/cloud_debugger"
75
76
  ].freeze
76
77
 
77
- # @param service_path [String]
78
- # The domain name of the API remote host.
79
- # @param port [Integer]
80
- # The port on which to connect to the remote host.
81
- # @param channel [Channel]
82
- # A Channel object through which to make calls.
83
- # @param chan_creds [Grpc::ChannelCredentials]
84
- # A ChannelCredentials for the setting up the RPC client.
85
- # @param updater_proc [Proc]
86
- # A function that transforms the metadata for requests, e.g., to give
87
- # OAuth credentials.
78
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
79
+ # Provides the means for authenticating requests made by the client. This parameter can
80
+ # be many types.
81
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
82
+ # authenticating requests made by this client.
83
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
84
+ # credentials for this client.
85
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
86
+ # credentials for this client.
87
+ # A `GRPC::Core::Channel` will be used to make calls through.
88
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
89
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
90
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
91
+ # metadata for requests, generally, to give OAuth credentials.
88
92
  # @param scopes [Array<String>]
89
93
  # The OAuth scopes for this service. This parameter is ignored if
90
94
  # an updater_proc is supplied.
91
- # @param client_config[Hash]
95
+ # @param client_config [Hash]
92
96
  # A Hash for call options for each method. See
93
97
  # Google::Gax#construct_settings for the structure of
94
98
  # this data. Falls back to the default config if not specified
@@ -101,11 +105,10 @@ module Google
101
105
  channel: nil,
102
106
  chan_creds: nil,
103
107
  updater_proc: nil,
108
+ credentials: nil,
104
109
  scopes: ALL_SCOPES,
105
110
  client_config: {},
106
111
  timeout: DEFAULT_TIMEOUT,
107
- app_name: nil,
108
- app_version: nil,
109
112
  lib_name: nil,
110
113
  lib_version: ""
111
114
  # These require statements are intentionally placed here to initialize
@@ -114,14 +117,38 @@ module Google
114
117
  require "google/gax/grpc"
115
118
  require "google/devtools/clouddebugger/v2/controller_services_pb"
116
119
 
120
+ if channel || chan_creds || updater_proc
121
+ warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
122
+ "on 2017/09/08"
123
+ credentials ||= channel
124
+ credentials ||= chan_creds
125
+ credentials ||= updater_proc
126
+ end
127
+ if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
128
+ warn "`service_path` and `port` parameters are deprecated and will be removed"
129
+ end
130
+
131
+ credentials ||= Google::Cloud::Debugger::Credentials.default
117
132
 
118
- if app_name || app_version
119
- warn "`app_name` and `app_version` are no longer being used in the request headers."
133
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
134
+ updater_proc = Google::Cloud::Debugger::Credentials.new(credentials).updater_proc
135
+ end
136
+ if credentials.is_a?(GRPC::Core::Channel)
137
+ channel = credentials
138
+ end
139
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
140
+ chan_creds = credentials
141
+ end
142
+ if credentials.is_a?(Proc)
143
+ updater_proc = credentials
144
+ end
145
+ if credentials.is_a?(Google::Auth::Credentials)
146
+ updater_proc = credentials.updater_proc
120
147
  end
121
148
 
122
149
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
123
150
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
124
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
151
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
125
152
  google_api_client << " grpc/#{GRPC::VERSION}"
126
153
  google_api_client.freeze
127
154
 
@@ -168,19 +195,21 @@ module Google
168
195
 
169
196
  # Registers the debuggee with the controller service.
170
197
  #
171
- # All agents attached to the same application should call this method with
172
- # the same request content to get back the same stable +debuggee_id+. Agents
173
- # should call this method again whenever +google.rpc.Code.NOT_FOUND+ is
174
- # returned from any controller method.
198
+ # All agents attached to the same application must call this method with
199
+ # exactly the same request content to get back the same stable +debuggee_id+.
200
+ # Agents should call this method again whenever +google.rpc.Code.NOT_FOUND+
201
+ # is returned from any controller method.
175
202
  #
176
- # This allows the controller service to disable the agent or recover from any
177
- # data loss. If the debuggee is disabled by the server, the response will
178
- # have +is_disabled+ set to +true+.
203
+ # This protocol allows the controller service to disable debuggees, recover
204
+ # from data loss, or change the +debuggee_id+ format. Agents must handle
205
+ # +debuggee_id+ value changing upon re-registration.
179
206
  #
180
- # @param debuggee [Google::Devtools::Clouddebugger::V2::Debuggee]
207
+ # @param debuggee [Google::Devtools::Clouddebugger::V2::Debuggee | Hash]
181
208
  # Debuggee information to register.
182
209
  # The fields +project+, +uniquifier+, +description+ and +agent_version+
183
210
  # of the debuggee must be set.
211
+ # A hash of the same form as `Google::Devtools::Clouddebugger::V2::Debuggee`
212
+ # can also be provided.
184
213
  # @param options [Google::Gax::CallOptions]
185
214
  # Overrides the default settings for this call, e.g, timeout,
186
215
  # retries, etc.
@@ -189,25 +218,23 @@ module Google
189
218
  # @example
190
219
  # require "google/cloud/debugger/v2"
191
220
  #
192
- # Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
193
- # Debuggee = Google::Devtools::Clouddebugger::V2::Debuggee
194
- #
195
- # controller2_client = Controller2Client.new
196
- # debuggee = Debuggee.new
221
+ # controller2_client = Google::Cloud::Debugger::V2::Controller2.new
222
+ # debuggee = {}
197
223
  # response = controller2_client.register_debuggee(debuggee)
198
224
 
199
225
  def register_debuggee \
200
226
  debuggee,
201
227
  options: nil
202
- req = Google::Devtools::Clouddebugger::V2::RegisterDebuggeeRequest.new({
228
+ req = {
203
229
  debuggee: debuggee
204
- }.delete_if { |_, v| v.nil? })
230
+ }.delete_if { |_, v| v.nil? }
231
+ req = Google::Gax::to_proto(req, Google::Devtools::Clouddebugger::V2::RegisterDebuggeeRequest)
205
232
  @register_debuggee.call(req, options)
206
233
  end
207
234
 
208
235
  # Returns the list of all active breakpoints for the debuggee.
209
236
  #
210
- # The breakpoint specification (location, condition, and expression
237
+ # The breakpoint specification (+location+, +condition+, and +expressions+
211
238
  # fields) is semantically immutable, although the field values may
212
239
  # change. For example, an agent may update the location line number
213
240
  # to reflect the actual line where the breakpoint was set, but this
@@ -222,16 +249,17 @@ module Google
222
249
  # @param debuggee_id [String]
223
250
  # Identifies the debuggee.
224
251
  # @param wait_token [String]
225
- # A wait token that, if specified, blocks the method call until the list
226
- # of active breakpoints has changed, or a server selected timeout has
227
- # expired. The value should be set from the last returned response.
252
+ # A token that, if specified, blocks the method call until the list
253
+ # of active breakpoints has changed, or a server-selected timeout has
254
+ # expired. The value should be set from the +next_wait_token+ field in
255
+ # the last response. The initial value should be set to +"init"+.
228
256
  # @param success_on_timeout [true, false]
229
- # If set to +true+, returns +google.rpc.Code.OK+ status and sets the
230
- # +wait_expired+ response field to +true+ when the server-selected timeout
231
- # has expired (recommended).
257
+ # If set to +true+ (recommended), returns +google.rpc.Code.OK+ status and
258
+ # sets the +wait_expired+ response field to +true+ when the server-selected
259
+ # timeout has expired.
232
260
  #
233
- # If set to +false+, returns +google.rpc.Code.ABORTED+ status when the
234
- # server-selected timeout has expired (deprecated).
261
+ # If set to +false+ (deprecated), returns +google.rpc.Code.ABORTED+ status
262
+ # when the server-selected timeout has expired.
235
263
  # @param options [Google::Gax::CallOptions]
236
264
  # Overrides the default settings for this call, e.g, timeout,
237
265
  # retries, etc.
@@ -240,9 +268,7 @@ module Google
240
268
  # @example
241
269
  # require "google/cloud/debugger/v2"
242
270
  #
243
- # Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
244
- #
245
- # controller2_client = Controller2Client.new
271
+ # controller2_client = Google::Cloud::Debugger::V2::Controller2.new
246
272
  # debuggee_id = ''
247
273
  # response = controller2_client.list_active_breakpoints(debuggee_id)
248
274
 
@@ -251,29 +277,32 @@ module Google
251
277
  wait_token: nil,
252
278
  success_on_timeout: nil,
253
279
  options: nil
254
- req = Google::Devtools::Clouddebugger::V2::ListActiveBreakpointsRequest.new({
280
+ req = {
255
281
  debuggee_id: debuggee_id,
256
282
  wait_token: wait_token,
257
283
  success_on_timeout: success_on_timeout
258
- }.delete_if { |_, v| v.nil? })
284
+ }.delete_if { |_, v| v.nil? }
285
+ req = Google::Gax::to_proto(req, Google::Devtools::Clouddebugger::V2::ListActiveBreakpointsRequest)
259
286
  @list_active_breakpoints.call(req, options)
260
287
  end
261
288
 
262
289
  # Updates the breakpoint state or mutable fields.
263
- # The entire Breakpoint message must be sent back to the controller
264
- # service.
290
+ # The entire Breakpoint message must be sent back to the controller service.
265
291
  #
266
292
  # Updates to active breakpoint fields are only allowed if the new value
267
293
  # does not change the breakpoint specification. Updates to the +location+,
268
- # +condition+ and +expression+ fields should not alter the breakpoint
294
+ # +condition+ and +expressions+ fields should not alter the breakpoint
269
295
  # semantics. These may only make changes such as canonicalizing a value
270
296
  # or snapping the location to the correct line of code.
271
297
  #
272
298
  # @param debuggee_id [String]
273
299
  # Identifies the debuggee being debugged.
274
- # @param breakpoint [Google::Devtools::Clouddebugger::V2::Breakpoint]
300
+ # @param breakpoint [Google::Devtools::Clouddebugger::V2::Breakpoint | Hash]
275
301
  # Updated breakpoint information.
276
- # The field 'id' must be set.
302
+ # The field +id+ must be set.
303
+ # The agent must echo all Breakpoint specification fields in the update.
304
+ # A hash of the same form as `Google::Devtools::Clouddebugger::V2::Breakpoint`
305
+ # can also be provided.
277
306
  # @param options [Google::Gax::CallOptions]
278
307
  # Overrides the default settings for this call, e.g, timeout,
279
308
  # retries, etc.
@@ -282,22 +311,20 @@ module Google
282
311
  # @example
283
312
  # require "google/cloud/debugger/v2"
284
313
  #
285
- # Breakpoint = Google::Devtools::Clouddebugger::V2::Breakpoint
286
- # Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
287
- #
288
- # controller2_client = Controller2Client.new
314
+ # controller2_client = Google::Cloud::Debugger::V2::Controller2.new
289
315
  # debuggee_id = ''
290
- # breakpoint = Breakpoint.new
316
+ # breakpoint = {}
291
317
  # response = controller2_client.update_active_breakpoint(debuggee_id, breakpoint)
292
318
 
293
319
  def update_active_breakpoint \
294
320
  debuggee_id,
295
321
  breakpoint,
296
322
  options: nil
297
- req = Google::Devtools::Clouddebugger::V2::UpdateActiveBreakpointRequest.new({
323
+ req = {
298
324
  debuggee_id: debuggee_id,
299
325
  breakpoint: breakpoint
300
- }.delete_if { |_, v| v.nil? })
326
+ }.delete_if { |_, v| v.nil? }
327
+ req = Google::Gax::to_proto(req, Google::Devtools::Clouddebugger::V2::UpdateActiveBreakpointRequest)
301
328
  @update_active_breakpoint.call(req, options)
302
329
  end
303
330
  end