google-cloud-dataproc 0.2.2 → 0.3.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/dataproc.rb +56 -3
  4. data/lib/google/cloud/dataproc/v1.rb +62 -3
  5. data/lib/google/cloud/dataproc/v1/cluster_controller_client.rb +65 -5
  6. data/lib/google/cloud/dataproc/v1/cluster_controller_client_config.json +10 -7
  7. data/lib/google/cloud/dataproc/v1/clusters_pb.rb +11 -0
  8. data/lib/google/cloud/dataproc/v1/clusters_services_pb.rb +3 -2
  9. data/lib/google/cloud/dataproc/v1/credentials.rb +1 -1
  10. data/lib/google/cloud/dataproc/v1/doc/google/cloud/dataproc/v1/clusters.rb +128 -45
  11. data/lib/google/cloud/dataproc/v1/doc/google/cloud/dataproc/v1/jobs.rb +32 -15
  12. data/lib/google/cloud/dataproc/v1/doc/google/cloud/dataproc/v1/workflow_templates.rb +519 -0
  13. data/lib/google/cloud/dataproc/v1/doc/google/longrunning/operations.rb +1 -43
  14. data/lib/google/cloud/dataproc/v1/doc/google/protobuf/any.rb +1 -1
  15. data/lib/google/cloud/dataproc/v1/doc/google/protobuf/duration.rb +1 -1
  16. data/lib/google/cloud/dataproc/v1/doc/google/protobuf/empty.rb +1 -1
  17. data/lib/google/cloud/dataproc/v1/doc/google/protobuf/field_mask.rb +1 -1
  18. data/lib/google/cloud/dataproc/v1/doc/google/protobuf/timestamp.rb +1 -1
  19. data/lib/google/cloud/dataproc/v1/doc/google/rpc/status.rb +1 -1
  20. data/lib/google/cloud/dataproc/v1/job_controller_client.rb +16 -2
  21. data/lib/google/cloud/dataproc/v1/job_controller_client_config.json +9 -6
  22. data/lib/google/cloud/dataproc/v1/jobs_pb.rb +2 -0
  23. data/lib/google/cloud/dataproc/v1/jobs_services_pb.rb +2 -1
  24. data/lib/google/cloud/dataproc/v1/operations_pb.rb +0 -2
  25. data/lib/google/cloud/dataproc/v1/workflow_template_service_client.rb +690 -0
  26. data/lib/google/cloud/dataproc/v1/workflow_template_service_client_config.json +64 -0
  27. data/lib/google/cloud/dataproc/v1/workflow_templates_pb.rb +181 -0
  28. data/lib/google/cloud/dataproc/v1/workflow_templates_services_pb.rb +102 -0
  29. data/lib/google/cloud/dataproc/v1beta2.rb +281 -0
  30. data/lib/google/cloud/dataproc/v1beta2/cluster_controller_client.rb +799 -0
  31. data/lib/google/cloud/dataproc/v1beta2/cluster_controller_client_config.json +59 -0
  32. data/lib/google/cloud/dataproc/v1beta2/clusters_pb.rb +189 -0
  33. data/lib/google/cloud/dataproc/v1beta2/clusters_services_pb.rb +60 -0
  34. data/lib/google/cloud/dataproc/v1beta2/credentials.rb +41 -0
  35. data/lib/google/cloud/dataproc/v1beta2/doc/google/cloud/dataproc/v1beta2/clusters.rb +666 -0
  36. data/lib/google/cloud/dataproc/v1beta2/doc/google/cloud/dataproc/v1beta2/jobs.rb +691 -0
  37. data/lib/google/cloud/dataproc/v1beta2/doc/google/cloud/dataproc/v1beta2/workflow_templates.rb +524 -0
  38. data/lib/google/cloud/dataproc/v1beta2/doc/google/longrunning/operations.rb +51 -0
  39. data/lib/google/cloud/dataproc/v1beta2/doc/google/protobuf/any.rb +130 -0
  40. data/lib/google/cloud/dataproc/v1beta2/doc/google/protobuf/duration.rb +91 -0
  41. data/lib/google/cloud/dataproc/v1beta2/doc/google/protobuf/empty.rb +29 -0
  42. data/lib/google/cloud/dataproc/v1beta2/doc/google/protobuf/field_mask.rb +230 -0
  43. data/lib/google/cloud/dataproc/v1beta2/doc/google/protobuf/timestamp.rb +109 -0
  44. data/lib/google/cloud/dataproc/v1beta2/doc/google/rpc/status.rb +84 -0
  45. data/lib/google/cloud/dataproc/v1beta2/job_controller_client.rb +581 -0
  46. data/lib/google/cloud/dataproc/v1beta2/job_controller_client_config.json +59 -0
  47. data/lib/google/cloud/dataproc/v1beta2/jobs_pb.rb +248 -0
  48. data/lib/google/cloud/dataproc/v1beta2/jobs_services_pb.rb +61 -0
  49. data/lib/google/cloud/dataproc/v1beta2/operations_pb.rb +44 -0
  50. data/lib/google/cloud/dataproc/v1beta2/shared_pb.rb +18 -0
  51. data/lib/google/cloud/dataproc/v1beta2/workflow_template_service_client.rb +698 -0
  52. data/lib/google/cloud/dataproc/v1beta2/workflow_template_service_client_config.json +64 -0
  53. data/lib/google/cloud/dataproc/v1beta2/workflow_templates_pb.rb +183 -0
  54. data/lib/google/cloud/dataproc/v1beta2/workflow_templates_services_pb.rb +102 -0
  55. metadata +36 -5
@@ -0,0 +1,799 @@
1
+ # Copyright 2019 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/cloud/dataproc/v1beta2/clusters.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+
23
+ require "json"
24
+ require "pathname"
25
+
26
+ require "google/gax"
27
+ require "google/gax/operation"
28
+ require "google/longrunning/operations_client"
29
+
30
+ require "google/cloud/dataproc/v1beta2/clusters_pb"
31
+ require "google/cloud/dataproc/v1beta2/credentials"
32
+
33
+ module Google
34
+ module Cloud
35
+ module Dataproc
36
+ module V1beta2
37
+ # The ClusterControllerService provides methods to manage clusters
38
+ # of Compute Engine instances.
39
+ #
40
+ # @!attribute [r] cluster_controller_stub
41
+ # @return [Google::Cloud::Dataproc::V1beta2::ClusterController::Stub]
42
+ class ClusterControllerClient
43
+ # @private
44
+ attr_reader :cluster_controller_stub
45
+
46
+ # The default address of the service.
47
+ SERVICE_ADDRESS = "dataproc.googleapis.com".freeze
48
+
49
+ # The default port of the service.
50
+ DEFAULT_SERVICE_PORT = 443
51
+
52
+ # The default set of gRPC interceptors.
53
+ GRPC_INTERCEPTORS = []
54
+
55
+ DEFAULT_TIMEOUT = 30
56
+
57
+ PAGE_DESCRIPTORS = {
58
+ "list_clusters" => Google::Gax::PageDescriptor.new(
59
+ "page_token",
60
+ "next_page_token",
61
+ "clusters")
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
+ ].freeze
71
+
72
+ # @private
73
+ class OperationsClient < Google::Longrunning::OperationsClient
74
+ self::SERVICE_ADDRESS = ClusterControllerClient::SERVICE_ADDRESS
75
+ self::GRPC_INTERCEPTORS = ClusterControllerClient::GRPC_INTERCEPTORS
76
+ end
77
+
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.
92
+ # @param scopes [Array<String>]
93
+ # The OAuth scopes for this service. This parameter is ignored if
94
+ # an updater_proc is supplied.
95
+ # @param client_config [Hash]
96
+ # A Hash for call options for each method. See
97
+ # Google::Gax#construct_settings for the structure of
98
+ # this data. Falls back to the default config if not specified
99
+ # or the specified config is missing data points.
100
+ # @param timeout [Numeric]
101
+ # The default timeout, in seconds, for calls made through this client.
102
+ # @param metadata [Hash]
103
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
104
+ # @param exception_transformer [Proc]
105
+ # An optional proc that intercepts any exceptions raised during an API call to inject
106
+ # custom error handling.
107
+ def initialize \
108
+ credentials: nil,
109
+ scopes: ALL_SCOPES,
110
+ client_config: {},
111
+ timeout: DEFAULT_TIMEOUT,
112
+ metadata: nil,
113
+ exception_transformer: nil,
114
+ lib_name: nil,
115
+ lib_version: ""
116
+ # These require statements are intentionally placed here to initialize
117
+ # the gRPC module only when it's required.
118
+ # See https://github.com/googleapis/toolkit/issues/446
119
+ require "google/gax/grpc"
120
+ require "google/cloud/dataproc/v1beta2/clusters_services_pb"
121
+
122
+ credentials ||= Google::Cloud::Dataproc::V1beta2::Credentials.default
123
+
124
+ @operations_client = OperationsClient.new(
125
+ credentials: credentials,
126
+ scopes: scopes,
127
+ client_config: client_config,
128
+ timeout: timeout,
129
+ lib_name: lib_name,
130
+ lib_version: lib_version,
131
+ )
132
+
133
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
134
+ updater_proc = Google::Cloud::Dataproc::V1beta2::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
147
+ end
148
+
149
+ package_version = Gem.loaded_specs['google-cloud-dataproc'].version.version
150
+
151
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
152
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
153
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
154
+ google_api_client << " grpc/#{GRPC::VERSION}"
155
+ google_api_client.freeze
156
+
157
+ headers = { :"x-goog-api-client" => google_api_client }
158
+ headers.merge!(metadata) unless metadata.nil?
159
+ client_config_file = Pathname.new(__dir__).join(
160
+ "cluster_controller_client_config.json"
161
+ )
162
+ defaults = client_config_file.open do |f|
163
+ Google::Gax.construct_settings(
164
+ "google.cloud.dataproc.v1beta2.ClusterController",
165
+ JSON.parse(f.read),
166
+ client_config,
167
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
168
+ timeout,
169
+ page_descriptors: PAGE_DESCRIPTORS,
170
+ errors: Google::Gax::Grpc::API_ERRORS,
171
+ metadata: headers
172
+ )
173
+ end
174
+
175
+ # Allow overriding the service path/port in subclasses.
176
+ service_path = self.class::SERVICE_ADDRESS
177
+ port = self.class::DEFAULT_SERVICE_PORT
178
+ interceptors = self.class::GRPC_INTERCEPTORS
179
+ @cluster_controller_stub = Google::Gax::Grpc.create_stub(
180
+ service_path,
181
+ port,
182
+ chan_creds: chan_creds,
183
+ channel: channel,
184
+ updater_proc: updater_proc,
185
+ scopes: scopes,
186
+ interceptors: interceptors,
187
+ &Google::Cloud::Dataproc::V1beta2::ClusterController::Stub.method(:new)
188
+ )
189
+
190
+ @create_cluster = Google::Gax.create_api_call(
191
+ @cluster_controller_stub.method(:create_cluster),
192
+ defaults["create_cluster"],
193
+ exception_transformer: exception_transformer
194
+ )
195
+ @update_cluster = Google::Gax.create_api_call(
196
+ @cluster_controller_stub.method(:update_cluster),
197
+ defaults["update_cluster"],
198
+ exception_transformer: exception_transformer
199
+ )
200
+ @delete_cluster = Google::Gax.create_api_call(
201
+ @cluster_controller_stub.method(:delete_cluster),
202
+ defaults["delete_cluster"],
203
+ exception_transformer: exception_transformer
204
+ )
205
+ @get_cluster = Google::Gax.create_api_call(
206
+ @cluster_controller_stub.method(:get_cluster),
207
+ defaults["get_cluster"],
208
+ exception_transformer: exception_transformer
209
+ )
210
+ @list_clusters = Google::Gax.create_api_call(
211
+ @cluster_controller_stub.method(:list_clusters),
212
+ defaults["list_clusters"],
213
+ exception_transformer: exception_transformer
214
+ )
215
+ @diagnose_cluster = Google::Gax.create_api_call(
216
+ @cluster_controller_stub.method(:diagnose_cluster),
217
+ defaults["diagnose_cluster"],
218
+ exception_transformer: exception_transformer
219
+ )
220
+ end
221
+
222
+ # Service calls
223
+
224
+ # Creates a cluster in a project.
225
+ #
226
+ # @param project_id [String]
227
+ # Required. The ID of the Google Cloud Platform project that the cluster
228
+ # belongs to.
229
+ # @param region [String]
230
+ # Required. The Cloud Dataproc region in which to handle the request.
231
+ # @param cluster [Google::Cloud::Dataproc::V1beta2::Cluster | Hash]
232
+ # Required. The cluster to create.
233
+ # A hash of the same form as `Google::Cloud::Dataproc::V1beta2::Cluster`
234
+ # can also be provided.
235
+ # @param request_id [String]
236
+ # Optional. A unique id used to identify the request. If the server
237
+ # receives two {Google::Cloud::Dataproc::V1beta2::CreateClusterRequest CreateClusterRequest} requests with the same
238
+ # id, then the second request will be ignored and the
239
+ # first {Google::Longrunning::Operation} created and stored in the backend
240
+ # is returned.
241
+ #
242
+ # It is recommended to always set this value to a
243
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
244
+ #
245
+ # The id must contain only letters (a-z, A-Z), numbers (0-9),
246
+ # underscores (_), and hyphens (-). The maximum length is 40 characters.
247
+ # @param options [Google::Gax::CallOptions]
248
+ # Overrides the default settings for this call, e.g, timeout,
249
+ # retries, etc.
250
+ # @return [Google::Gax::Operation]
251
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
252
+ # @example
253
+ # require "google/cloud/dataproc"
254
+ #
255
+ # cluster_controller_client = Google::Cloud::Dataproc::ClusterController.new(version: :v1beta2)
256
+ #
257
+ # # TODO: Initialize `project_id`:
258
+ # project_id = ''
259
+ #
260
+ # # TODO: Initialize `region`:
261
+ # region = ''
262
+ #
263
+ # # TODO: Initialize `cluster`:
264
+ # cluster = {}
265
+ #
266
+ # # Register a callback during the method call.
267
+ # operation = cluster_controller_client.create_cluster(project_id, region, cluster) do |op|
268
+ # raise op.results.message if op.error?
269
+ # op_results = op.results
270
+ # # Process the results.
271
+ #
272
+ # metadata = op.metadata
273
+ # # Process the metadata.
274
+ # end
275
+ #
276
+ # # Or use the return value to register a callback.
277
+ # operation.on_done do |op|
278
+ # raise op.results.message if op.error?
279
+ # op_results = op.results
280
+ # # Process the results.
281
+ #
282
+ # metadata = op.metadata
283
+ # # Process the metadata.
284
+ # end
285
+ #
286
+ # # Manually reload the operation.
287
+ # operation.reload!
288
+ #
289
+ # # Or block until the operation completes, triggering callbacks on
290
+ # # completion.
291
+ # operation.wait_until_done!
292
+
293
+ def create_cluster \
294
+ project_id,
295
+ region,
296
+ cluster,
297
+ request_id: nil,
298
+ options: nil
299
+ req = {
300
+ project_id: project_id,
301
+ region: region,
302
+ cluster: cluster,
303
+ request_id: request_id
304
+ }.delete_if { |_, v| v.nil? }
305
+ req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1beta2::CreateClusterRequest)
306
+ operation = Google::Gax::Operation.new(
307
+ @create_cluster.call(req, options),
308
+ @operations_client,
309
+ Google::Cloud::Dataproc::V1beta2::Cluster,
310
+ Google::Cloud::Dataproc::V1beta2::ClusterOperationMetadata,
311
+ call_options: options
312
+ )
313
+ operation.on_done { |operation| yield(operation) } if block_given?
314
+ operation
315
+ end
316
+
317
+ # Updates a cluster in a project.
318
+ #
319
+ # @param project_id [String]
320
+ # Required. The ID of the Google Cloud Platform project the
321
+ # cluster belongs to.
322
+ # @param region [String]
323
+ # Required. The Cloud Dataproc region in which to handle the request.
324
+ # @param cluster_name [String]
325
+ # Required. The cluster name.
326
+ # @param cluster [Google::Cloud::Dataproc::V1beta2::Cluster | Hash]
327
+ # Required. The changes to the cluster.
328
+ # A hash of the same form as `Google::Cloud::Dataproc::V1beta2::Cluster`
329
+ # can also be provided.
330
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
331
+ # Required. Specifies the path, relative to `Cluster`, of
332
+ # the field to update. For example, to change the number of workers
333
+ # in a cluster to 5, the `update_mask` parameter would be
334
+ # specified as `config.worker_config.num_instances`,
335
+ # and the `PATCH` request body would specify the new value, as follows:
336
+ #
337
+ # {
338
+ # "config":{
339
+ # "workerConfig":{
340
+ # "numInstances":"5"
341
+ # }
342
+ # }
343
+ # }
344
+ #
345
+ # Similarly, to change the number of preemptible workers in a cluster to 5, the
346
+ # `update_mask` parameter would be `config.secondary_worker_config.num_instances`,
347
+ # and the `PATCH` request body would be set as follows:
348
+ #
349
+ # {
350
+ # "config":{
351
+ # "secondaryWorkerConfig":{
352
+ # "numInstances":"5"
353
+ # }
354
+ # }
355
+ # }
356
+ # <strong>Note:</strong> currently only the following fields can be updated:
357
+ #
358
+ # <table>
359
+ # <tr>
360
+ # <td><strong>Mask</strong></td><td><strong>Purpose</strong></td>
361
+ # </tr>
362
+ # <tr>
363
+ # <td>labels</td><td>Updates labels</td>
364
+ # </tr>
365
+ # <tr>
366
+ # <td>config.worker_config.num_instances</td><td>Resize primary worker group</td>
367
+ # </tr>
368
+ # <tr>
369
+ # <td>config.secondary_worker_config.num_instances</td><td>Resize secondary worker group</td>
370
+ # </tr>
371
+ # <tr>
372
+ # <td>config.lifecycle_config.auto_delete_ttl</td><td>Reset MAX TTL duration</td>
373
+ # </tr>
374
+ # <tr>
375
+ # <td>config.lifecycle_config.auto_delete_time</td><td>Update MAX TTL deletion timestamp</td>
376
+ # </tr>
377
+ # <tr>
378
+ # <td>config.lifecycle_config.idle_delete_ttl</td><td>Update Idle TTL duration</td>
379
+ # </tr>
380
+ # </table>
381
+ # A hash of the same form as `Google::Protobuf::FieldMask`
382
+ # can also be provided.
383
+ # @param graceful_decommission_timeout [Google::Protobuf::Duration | Hash]
384
+ # Optional. Timeout for graceful YARN decomissioning. Graceful
385
+ # decommissioning allows removing nodes from the cluster without
386
+ # interrupting jobs in progress. Timeout specifies how long to wait for jobs
387
+ # in progress to finish before forcefully removing nodes (and potentially
388
+ # interrupting jobs). Default timeout is 0 (for forceful decommission), and
389
+ # the maximum allowed timeout is 1 day.
390
+ #
391
+ # Only supported on Dataproc image versions 1.2 and higher.
392
+ # A hash of the same form as `Google::Protobuf::Duration`
393
+ # can also be provided.
394
+ # @param request_id [String]
395
+ # Optional. A unique id used to identify the request. If the server
396
+ # receives two {Google::Cloud::Dataproc::V1beta2::UpdateClusterRequest UpdateClusterRequest} requests with the same
397
+ # id, then the second request will be ignored and the
398
+ # first {Google::Longrunning::Operation} created and stored in the
399
+ # backend is returned.
400
+ #
401
+ # It is recommended to always set this value to a
402
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
403
+ #
404
+ # The id must contain only letters (a-z, A-Z), numbers (0-9),
405
+ # underscores (_), and hyphens (-). The maximum length is 40 characters.
406
+ # @param options [Google::Gax::CallOptions]
407
+ # Overrides the default settings for this call, e.g, timeout,
408
+ # retries, etc.
409
+ # @return [Google::Gax::Operation]
410
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
411
+ # @example
412
+ # require "google/cloud/dataproc"
413
+ #
414
+ # cluster_controller_client = Google::Cloud::Dataproc::ClusterController.new(version: :v1beta2)
415
+ #
416
+ # # TODO: Initialize `project_id`:
417
+ # project_id = ''
418
+ #
419
+ # # TODO: Initialize `region`:
420
+ # region = ''
421
+ #
422
+ # # TODO: Initialize `cluster_name`:
423
+ # cluster_name = ''
424
+ #
425
+ # # TODO: Initialize `cluster`:
426
+ # cluster = {}
427
+ #
428
+ # # TODO: Initialize `update_mask`:
429
+ # update_mask = {}
430
+ #
431
+ # # Register a callback during the method call.
432
+ # operation = cluster_controller_client.update_cluster(project_id, region, cluster_name, cluster, update_mask) do |op|
433
+ # raise op.results.message if op.error?
434
+ # op_results = op.results
435
+ # # Process the results.
436
+ #
437
+ # metadata = op.metadata
438
+ # # Process the metadata.
439
+ # end
440
+ #
441
+ # # Or use the return value to register a callback.
442
+ # operation.on_done do |op|
443
+ # raise op.results.message if op.error?
444
+ # op_results = op.results
445
+ # # Process the results.
446
+ #
447
+ # metadata = op.metadata
448
+ # # Process the metadata.
449
+ # end
450
+ #
451
+ # # Manually reload the operation.
452
+ # operation.reload!
453
+ #
454
+ # # Or block until the operation completes, triggering callbacks on
455
+ # # completion.
456
+ # operation.wait_until_done!
457
+
458
+ def update_cluster \
459
+ project_id,
460
+ region,
461
+ cluster_name,
462
+ cluster,
463
+ update_mask,
464
+ graceful_decommission_timeout: nil,
465
+ request_id: nil,
466
+ options: nil
467
+ req = {
468
+ project_id: project_id,
469
+ region: region,
470
+ cluster_name: cluster_name,
471
+ cluster: cluster,
472
+ update_mask: update_mask,
473
+ graceful_decommission_timeout: graceful_decommission_timeout,
474
+ request_id: request_id
475
+ }.delete_if { |_, v| v.nil? }
476
+ req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1beta2::UpdateClusterRequest)
477
+ operation = Google::Gax::Operation.new(
478
+ @update_cluster.call(req, options),
479
+ @operations_client,
480
+ Google::Cloud::Dataproc::V1beta2::Cluster,
481
+ Google::Cloud::Dataproc::V1beta2::ClusterOperationMetadata,
482
+ call_options: options
483
+ )
484
+ operation.on_done { |operation| yield(operation) } if block_given?
485
+ operation
486
+ end
487
+
488
+ # Deletes a cluster in a project.
489
+ #
490
+ # @param project_id [String]
491
+ # Required. The ID of the Google Cloud Platform project that the cluster
492
+ # belongs to.
493
+ # @param region [String]
494
+ # Required. The Cloud Dataproc region in which to handle the request.
495
+ # @param cluster_name [String]
496
+ # Required. The cluster name.
497
+ # @param cluster_uuid [String]
498
+ # Optional. Specifying the `cluster_uuid` means the RPC should fail
499
+ # (with error NOT_FOUND) if cluster with specified UUID does not exist.
500
+ # @param request_id [String]
501
+ # Optional. A unique id used to identify the request. If the server
502
+ # receives two {Google::Cloud::Dataproc::V1beta2::DeleteClusterRequest DeleteClusterRequest} requests with the same
503
+ # id, then the second request will be ignored and the
504
+ # first {Google::Longrunning::Operation} created and stored in the
505
+ # backend is returned.
506
+ #
507
+ # It is recommended to always set this value to a
508
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
509
+ #
510
+ # The id must contain only letters (a-z, A-Z), numbers (0-9),
511
+ # underscores (_), and hyphens (-). The maximum length is 40 characters.
512
+ # @param options [Google::Gax::CallOptions]
513
+ # Overrides the default settings for this call, e.g, timeout,
514
+ # retries, etc.
515
+ # @return [Google::Gax::Operation]
516
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
517
+ # @example
518
+ # require "google/cloud/dataproc"
519
+ #
520
+ # cluster_controller_client = Google::Cloud::Dataproc::ClusterController.new(version: :v1beta2)
521
+ #
522
+ # # TODO: Initialize `project_id`:
523
+ # project_id = ''
524
+ #
525
+ # # TODO: Initialize `region`:
526
+ # region = ''
527
+ #
528
+ # # TODO: Initialize `cluster_name`:
529
+ # cluster_name = ''
530
+ #
531
+ # # Register a callback during the method call.
532
+ # operation = cluster_controller_client.delete_cluster(project_id, region, cluster_name) do |op|
533
+ # raise op.results.message if op.error?
534
+ # op_results = op.results
535
+ # # Process the results.
536
+ #
537
+ # metadata = op.metadata
538
+ # # Process the metadata.
539
+ # end
540
+ #
541
+ # # Or use the return value to register a callback.
542
+ # operation.on_done do |op|
543
+ # raise op.results.message if op.error?
544
+ # op_results = op.results
545
+ # # Process the results.
546
+ #
547
+ # metadata = op.metadata
548
+ # # Process the metadata.
549
+ # end
550
+ #
551
+ # # Manually reload the operation.
552
+ # operation.reload!
553
+ #
554
+ # # Or block until the operation completes, triggering callbacks on
555
+ # # completion.
556
+ # operation.wait_until_done!
557
+
558
+ def delete_cluster \
559
+ project_id,
560
+ region,
561
+ cluster_name,
562
+ cluster_uuid: nil,
563
+ request_id: nil,
564
+ options: nil
565
+ req = {
566
+ project_id: project_id,
567
+ region: region,
568
+ cluster_name: cluster_name,
569
+ cluster_uuid: cluster_uuid,
570
+ request_id: request_id
571
+ }.delete_if { |_, v| v.nil? }
572
+ req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1beta2::DeleteClusterRequest)
573
+ operation = Google::Gax::Operation.new(
574
+ @delete_cluster.call(req, options),
575
+ @operations_client,
576
+ Google::Protobuf::Empty,
577
+ Google::Cloud::Dataproc::V1beta2::ClusterOperationMetadata,
578
+ call_options: options
579
+ )
580
+ operation.on_done { |operation| yield(operation) } if block_given?
581
+ operation
582
+ end
583
+
584
+ # Gets the resource representation for a cluster in a project.
585
+ #
586
+ # @param project_id [String]
587
+ # Required. The ID of the Google Cloud Platform project that the cluster
588
+ # belongs to.
589
+ # @param region [String]
590
+ # Required. The Cloud Dataproc region in which to handle the request.
591
+ # @param cluster_name [String]
592
+ # Required. The cluster name.
593
+ # @param options [Google::Gax::CallOptions]
594
+ # Overrides the default settings for this call, e.g, timeout,
595
+ # retries, etc.
596
+ # @yield [result, operation] Access the result along with the RPC operation
597
+ # @yieldparam result [Google::Cloud::Dataproc::V1beta2::Cluster]
598
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
599
+ # @return [Google::Cloud::Dataproc::V1beta2::Cluster]
600
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
601
+ # @example
602
+ # require "google/cloud/dataproc"
603
+ #
604
+ # cluster_controller_client = Google::Cloud::Dataproc::ClusterController.new(version: :v1beta2)
605
+ #
606
+ # # TODO: Initialize `project_id`:
607
+ # project_id = ''
608
+ #
609
+ # # TODO: Initialize `region`:
610
+ # region = ''
611
+ #
612
+ # # TODO: Initialize `cluster_name`:
613
+ # cluster_name = ''
614
+ # response = cluster_controller_client.get_cluster(project_id, region, cluster_name)
615
+
616
+ def get_cluster \
617
+ project_id,
618
+ region,
619
+ cluster_name,
620
+ options: nil,
621
+ &block
622
+ req = {
623
+ project_id: project_id,
624
+ region: region,
625
+ cluster_name: cluster_name
626
+ }.delete_if { |_, v| v.nil? }
627
+ req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1beta2::GetClusterRequest)
628
+ @get_cluster.call(req, options, &block)
629
+ end
630
+
631
+ # Lists all regions/\\{region}/clusters in a project.
632
+ #
633
+ # @param project_id [String]
634
+ # Required. The ID of the Google Cloud Platform project that the cluster
635
+ # belongs to.
636
+ # @param region [String]
637
+ # Required. The Cloud Dataproc region in which to handle the request.
638
+ # @param filter [String]
639
+ # Optional. A filter constraining the clusters to list. Filters are
640
+ # case-sensitive and have the following syntax:
641
+ #
642
+ # field = value [AND [field = value]] ...
643
+ #
644
+ # where **field** is one of `status.state`, `clusterName`, or `labels.[KEY]`,
645
+ # and `[KEY]` is a label key. **value** can be `*` to match all values.
646
+ # `status.state` can be one of the following: `ACTIVE`, `INACTIVE`,
647
+ # `CREATING`, `RUNNING`, `ERROR`, `DELETING`, or `UPDATING`. `ACTIVE`
648
+ # contains the `CREATING`, `UPDATING`, and `RUNNING` states. `INACTIVE`
649
+ # contains the `DELETING` and `ERROR` states.
650
+ # `clusterName` is the name of the cluster provided at creation time.
651
+ # Only the logical `AND` operator is supported; space-separated items are
652
+ # treated as having an implicit `AND` operator.
653
+ #
654
+ # Example filter:
655
+ #
656
+ # status.state = ACTIVE AND clusterName = mycluster
657
+ # AND labels.env = staging AND labels.starred = *
658
+ # @param page_size [Integer]
659
+ # The maximum number of resources contained in the underlying API
660
+ # response. If page streaming is performed per-resource, this
661
+ # parameter does not affect the return value. If page streaming is
662
+ # performed per-page, this determines the maximum number of
663
+ # resources in a page.
664
+ # @param options [Google::Gax::CallOptions]
665
+ # Overrides the default settings for this call, e.g, timeout,
666
+ # retries, etc.
667
+ # @yield [result, operation] Access the result along with the RPC operation
668
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dataproc::V1beta2::Cluster>]
669
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
670
+ # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dataproc::V1beta2::Cluster>]
671
+ # An enumerable of Google::Cloud::Dataproc::V1beta2::Cluster instances.
672
+ # See Google::Gax::PagedEnumerable documentation for other
673
+ # operations such as per-page iteration or access to the response
674
+ # object.
675
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
676
+ # @example
677
+ # require "google/cloud/dataproc"
678
+ #
679
+ # cluster_controller_client = Google::Cloud::Dataproc::ClusterController.new(version: :v1beta2)
680
+ #
681
+ # # TODO: Initialize `project_id`:
682
+ # project_id = ''
683
+ #
684
+ # # TODO: Initialize `region`:
685
+ # region = ''
686
+ #
687
+ # # Iterate over all results.
688
+ # cluster_controller_client.list_clusters(project_id, region).each do |element|
689
+ # # Process element.
690
+ # end
691
+ #
692
+ # # Or iterate over results one page at a time.
693
+ # cluster_controller_client.list_clusters(project_id, region).each_page do |page|
694
+ # # Process each page at a time.
695
+ # page.each do |element|
696
+ # # Process element.
697
+ # end
698
+ # end
699
+
700
+ def list_clusters \
701
+ project_id,
702
+ region,
703
+ filter: nil,
704
+ page_size: nil,
705
+ options: nil,
706
+ &block
707
+ req = {
708
+ project_id: project_id,
709
+ region: region,
710
+ filter: filter,
711
+ page_size: page_size
712
+ }.delete_if { |_, v| v.nil? }
713
+ req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1beta2::ListClustersRequest)
714
+ @list_clusters.call(req, options, &block)
715
+ end
716
+
717
+ # Gets cluster diagnostic information.
718
+ # After the operation completes, the Operation.response field
719
+ # contains `DiagnoseClusterOutputLocation`.
720
+ #
721
+ # @param project_id [String]
722
+ # Required. The ID of the Google Cloud Platform project that the cluster
723
+ # belongs to.
724
+ # @param region [String]
725
+ # Required. The Cloud Dataproc region in which to handle the request.
726
+ # @param cluster_name [String]
727
+ # Required. The cluster name.
728
+ # @param options [Google::Gax::CallOptions]
729
+ # Overrides the default settings for this call, e.g, timeout,
730
+ # retries, etc.
731
+ # @return [Google::Gax::Operation]
732
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
733
+ # @example
734
+ # require "google/cloud/dataproc"
735
+ #
736
+ # cluster_controller_client = Google::Cloud::Dataproc::ClusterController.new(version: :v1beta2)
737
+ #
738
+ # # TODO: Initialize `project_id`:
739
+ # project_id = ''
740
+ #
741
+ # # TODO: Initialize `region`:
742
+ # region = ''
743
+ #
744
+ # # TODO: Initialize `cluster_name`:
745
+ # cluster_name = ''
746
+ #
747
+ # # Register a callback during the method call.
748
+ # operation = cluster_controller_client.diagnose_cluster(project_id, region, cluster_name) do |op|
749
+ # raise op.results.message if op.error?
750
+ # op_results = op.results
751
+ # # Process the results.
752
+ #
753
+ # metadata = op.metadata
754
+ # # Process the metadata.
755
+ # end
756
+ #
757
+ # # Or use the return value to register a callback.
758
+ # operation.on_done do |op|
759
+ # raise op.results.message if op.error?
760
+ # op_results = op.results
761
+ # # Process the results.
762
+ #
763
+ # metadata = op.metadata
764
+ # # Process the metadata.
765
+ # end
766
+ #
767
+ # # Manually reload the operation.
768
+ # operation.reload!
769
+ #
770
+ # # Or block until the operation completes, triggering callbacks on
771
+ # # completion.
772
+ # operation.wait_until_done!
773
+
774
+ def diagnose_cluster \
775
+ project_id,
776
+ region,
777
+ cluster_name,
778
+ options: nil
779
+ req = {
780
+ project_id: project_id,
781
+ region: region,
782
+ cluster_name: cluster_name
783
+ }.delete_if { |_, v| v.nil? }
784
+ req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1beta2::DiagnoseClusterRequest)
785
+ operation = Google::Gax::Operation.new(
786
+ @diagnose_cluster.call(req, options),
787
+ @operations_client,
788
+ Google::Protobuf::Empty,
789
+ Google::Cloud::Dataproc::V1beta2::DiagnoseClusterResults,
790
+ call_options: options
791
+ )
792
+ operation.on_done { |operation| yield(operation) } if block_given?
793
+ operation
794
+ end
795
+ end
796
+ end
797
+ end
798
+ end
799
+ end