google-cloud-dataproc-v1 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +188 -190
  3. data/README.md +66 -2
  4. data/lib/google/cloud/dataproc/v1.rb +3 -0
  5. data/lib/google/cloud/dataproc/v1/autoscaling_policies_services_pb.rb +5 -5
  6. data/lib/google/cloud/dataproc/v1/autoscaling_policy_service/client.rb +26 -20
  7. data/lib/google/cloud/dataproc/v1/autoscaling_policy_service/paths.rb +1 -1
  8. data/lib/google/cloud/dataproc/v1/cluster_controller.rb +1 -0
  9. data/lib/google/cloud/dataproc/v1/cluster_controller/client.rb +251 -47
  10. data/lib/google/cloud/dataproc/v1/cluster_controller/operations.rb +96 -11
  11. data/lib/google/cloud/dataproc/v1/cluster_controller/paths.rb +71 -0
  12. data/lib/google/cloud/dataproc/v1/clusters_pb.rb +60 -0
  13. data/lib/google/cloud/dataproc/v1/clusters_services_pb.rb +10 -6
  14. data/lib/google/cloud/dataproc/v1/job_controller/client.rb +57 -49
  15. data/lib/google/cloud/dataproc/v1/job_controller/operations.rb +96 -11
  16. data/lib/google/cloud/dataproc/v1/jobs_pb.rb +2 -0
  17. data/lib/google/cloud/dataproc/v1/jobs_services_pb.rb +7 -7
  18. data/lib/google/cloud/dataproc/v1/shared_pb.rb +7 -0
  19. data/lib/google/cloud/dataproc/v1/version.rb +1 -1
  20. data/lib/google/cloud/dataproc/v1/workflow_template_service/client.rb +43 -36
  21. data/lib/google/cloud/dataproc/v1/workflow_template_service/operations.rb +96 -11
  22. data/lib/google/cloud/dataproc/v1/workflow_template_service/paths.rb +39 -1
  23. data/lib/google/cloud/dataproc/v1/workflow_templates_pb.rb +5 -0
  24. data/lib/google/cloud/dataproc/v1/workflow_templates_services_pb.rb +9 -8
  25. data/proto_docs/google/api/field_behavior.rb +6 -0
  26. data/proto_docs/google/api/resource.rb +50 -14
  27. data/proto_docs/google/cloud/dataproc/v1/clusters.rb +240 -16
  28. data/proto_docs/google/cloud/dataproc/v1/jobs.rb +29 -10
  29. data/proto_docs/google/cloud/dataproc/v1/shared.rb +24 -1
  30. data/proto_docs/google/cloud/dataproc/v1/workflow_templates.rb +34 -7
  31. data/proto_docs/google/longrunning/operations.rb +17 -3
  32. data/proto_docs/google/protobuf/any.rb +5 -2
  33. data/proto_docs/google/protobuf/timestamp.rb +10 -1
  34. metadata +13 -9
@@ -36,3 +36,6 @@ module Google
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ helper_path = ::File.join __dir__, "v1", "_helpers.rb"
41
+ require "google/cloud/dataproc/v1/_helpers" if ::File.file? helper_path
@@ -35,19 +35,19 @@ module Google
35
35
  self.service_name = 'google.cloud.dataproc.v1.AutoscalingPolicyService'
36
36
 
37
37
  # Creates new autoscaling policy.
38
- rpc :CreateAutoscalingPolicy, Google::Cloud::Dataproc::V1::CreateAutoscalingPolicyRequest, Google::Cloud::Dataproc::V1::AutoscalingPolicy
38
+ rpc :CreateAutoscalingPolicy, ::Google::Cloud::Dataproc::V1::CreateAutoscalingPolicyRequest, ::Google::Cloud::Dataproc::V1::AutoscalingPolicy
39
39
  # Updates (replaces) autoscaling policy.
40
40
  #
41
41
  # Disabled check for update_mask, because all updates will be full
42
42
  # replacements.
43
- rpc :UpdateAutoscalingPolicy, Google::Cloud::Dataproc::V1::UpdateAutoscalingPolicyRequest, Google::Cloud::Dataproc::V1::AutoscalingPolicy
43
+ rpc :UpdateAutoscalingPolicy, ::Google::Cloud::Dataproc::V1::UpdateAutoscalingPolicyRequest, ::Google::Cloud::Dataproc::V1::AutoscalingPolicy
44
44
  # Retrieves autoscaling policy.
45
- rpc :GetAutoscalingPolicy, Google::Cloud::Dataproc::V1::GetAutoscalingPolicyRequest, Google::Cloud::Dataproc::V1::AutoscalingPolicy
45
+ rpc :GetAutoscalingPolicy, ::Google::Cloud::Dataproc::V1::GetAutoscalingPolicyRequest, ::Google::Cloud::Dataproc::V1::AutoscalingPolicy
46
46
  # Lists autoscaling policies in the project.
47
- rpc :ListAutoscalingPolicies, Google::Cloud::Dataproc::V1::ListAutoscalingPoliciesRequest, Google::Cloud::Dataproc::V1::ListAutoscalingPoliciesResponse
47
+ rpc :ListAutoscalingPolicies, ::Google::Cloud::Dataproc::V1::ListAutoscalingPoliciesRequest, ::Google::Cloud::Dataproc::V1::ListAutoscalingPoliciesResponse
48
48
  # Deletes an autoscaling policy. It is an error to delete an autoscaling
49
49
  # policy that is in use by one or more clusters.
50
- rpc :DeleteAutoscalingPolicy, Google::Cloud::Dataproc::V1::DeleteAutoscalingPolicyRequest, Google::Protobuf::Empty
50
+ rpc :DeleteAutoscalingPolicy, ::Google::Cloud::Dataproc::V1::DeleteAutoscalingPolicyRequest, ::Google::Protobuf::Empty
51
51
  end
52
52
 
53
53
  Stub = Service.rpc_stub_class
@@ -61,7 +61,7 @@ module Google
61
61
  parent_config = while namespace.any?
62
62
  parent_name = namespace.join "::"
63
63
  parent_const = const_get parent_name
64
- break parent_const.configure if parent_const&.respond_to? :configure
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
65
  namespace.pop
66
66
  end
67
67
  default_config = Client::Configuration.new parent_config
@@ -71,25 +71,25 @@ module Google
71
71
  default_config.rpcs.update_autoscaling_policy.timeout = 600.0
72
72
  default_config.rpcs.update_autoscaling_policy.retry_policy = {
73
73
  initial_delay: 0.1,
74
- max_delay: 60.0,
75
- multiplier: 1.3,
76
- retry_codes: [4, 14]
74
+ max_delay: 60.0,
75
+ multiplier: 1.3,
76
+ retry_codes: [4, 14]
77
77
  }
78
78
 
79
79
  default_config.rpcs.get_autoscaling_policy.timeout = 600.0
80
80
  default_config.rpcs.get_autoscaling_policy.retry_policy = {
81
81
  initial_delay: 0.1,
82
- max_delay: 60.0,
83
- multiplier: 1.3,
84
- retry_codes: [4, 14]
82
+ max_delay: 60.0,
83
+ multiplier: 1.3,
84
+ retry_codes: [4, 14]
85
85
  }
86
86
 
87
87
  default_config.rpcs.list_autoscaling_policies.timeout = 600.0
88
88
  default_config.rpcs.list_autoscaling_policies.retry_policy = {
89
89
  initial_delay: 0.1,
90
- max_delay: 60.0,
91
- multiplier: 1.3,
92
- retry_codes: [4, 14]
90
+ max_delay: 60.0,
91
+ multiplier: 1.3,
92
+ retry_codes: [4, 14]
93
93
  }
94
94
 
95
95
  default_config.rpcs.delete_autoscaling_policy.timeout = 600.0
@@ -155,7 +155,13 @@ module Google
155
155
 
156
156
  # Create credentials
157
157
  credentials = @config.credentials
158
- credentials ||= Credentials.default scope: @config.scope
158
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
159
+ # but only if the default endpoint does not have a region prefix.
160
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
161
+ @config.endpoint == Client.configure.endpoint &&
162
+ !@config.endpoint.split(".").first.include?("-")
163
+ credentials ||= Credentials.default scope: @config.scope,
164
+ enable_self_signed_jwt: enable_self_signed_jwt
159
165
  if credentials.is_a?(String) || credentials.is_a?(Hash)
160
166
  credentials = Credentials.new credentials, scope: @config.scope
161
167
  end
@@ -637,14 +643,14 @@ module Google
637
643
 
638
644
  config_attr :endpoint, "dataproc.googleapis.com", ::String
639
645
  config_attr :credentials, nil do |value|
640
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
646
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
641
647
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
642
648
  allowed.any? { |klass| klass === value }
643
649
  end
644
650
  config_attr :scope, nil, ::String, ::Array, nil
645
651
  config_attr :lib_name, nil, ::String, nil
646
652
  config_attr :lib_version, nil, ::String, nil
647
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
653
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
648
654
  config_attr :interceptors, nil, ::Array, nil
649
655
  config_attr :timeout, nil, ::Numeric, nil
650
656
  config_attr :metadata, nil, ::Hash, nil
@@ -665,7 +671,7 @@ module Google
665
671
  def rpcs
666
672
  @rpcs ||= begin
667
673
  parent_rpcs = nil
668
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
674
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
669
675
  Rpcs.new parent_rpcs
670
676
  end
671
677
  end
@@ -677,7 +683,7 @@ module Google
677
683
  # Each configuration object is of type `Gapic::Config::Method` and includes
678
684
  # the following configuration fields:
679
685
  #
680
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
686
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
681
687
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
682
688
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
683
689
  # include the following keys:
@@ -716,15 +722,15 @@ module Google
716
722
 
717
723
  # @private
718
724
  def initialize parent_rpcs = nil
719
- create_autoscaling_policy_config = parent_rpcs&.create_autoscaling_policy if parent_rpcs&.respond_to? :create_autoscaling_policy
725
+ create_autoscaling_policy_config = parent_rpcs.create_autoscaling_policy if parent_rpcs.respond_to? :create_autoscaling_policy
720
726
  @create_autoscaling_policy = ::Gapic::Config::Method.new create_autoscaling_policy_config
721
- update_autoscaling_policy_config = parent_rpcs&.update_autoscaling_policy if parent_rpcs&.respond_to? :update_autoscaling_policy
727
+ update_autoscaling_policy_config = parent_rpcs.update_autoscaling_policy if parent_rpcs.respond_to? :update_autoscaling_policy
722
728
  @update_autoscaling_policy = ::Gapic::Config::Method.new update_autoscaling_policy_config
723
- get_autoscaling_policy_config = parent_rpcs&.get_autoscaling_policy if parent_rpcs&.respond_to? :get_autoscaling_policy
729
+ get_autoscaling_policy_config = parent_rpcs.get_autoscaling_policy if parent_rpcs.respond_to? :get_autoscaling_policy
724
730
  @get_autoscaling_policy = ::Gapic::Config::Method.new get_autoscaling_policy_config
725
- list_autoscaling_policies_config = parent_rpcs&.list_autoscaling_policies if parent_rpcs&.respond_to? :list_autoscaling_policies
731
+ list_autoscaling_policies_config = parent_rpcs.list_autoscaling_policies if parent_rpcs.respond_to? :list_autoscaling_policies
726
732
  @list_autoscaling_policies = ::Gapic::Config::Method.new list_autoscaling_policies_config
727
- delete_autoscaling_policy_config = parent_rpcs&.delete_autoscaling_policy if parent_rpcs&.respond_to? :delete_autoscaling_policy
733
+ delete_autoscaling_policy_config = parent_rpcs.delete_autoscaling_policy if parent_rpcs.respond_to? :delete_autoscaling_policy
728
734
  @delete_autoscaling_policy = ::Gapic::Config::Method.new delete_autoscaling_policy_config
729
735
 
730
736
  yield self if block_given?
@@ -54,7 +54,7 @@ module Google
54
54
 
55
55
  "projects/#{project}/locations/#{location}/autoscalingPolicies/#{autoscaling_policy}"
56
56
  end),
57
- "autoscaling_policy:project:region" => (proc do |project:, region:, autoscaling_policy:|
57
+ "autoscaling_policy:project:region" => (proc do |project:, region:, autoscaling_policy:|
58
58
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
59
59
  raise ::ArgumentError, "region cannot contain /" if region.to_s.include? "/"
60
60
 
@@ -23,6 +23,7 @@ require "gapic/config/method"
23
23
  require "google/cloud/dataproc/v1/version"
24
24
 
25
25
  require "google/cloud/dataproc/v1/cluster_controller/credentials"
26
+ require "google/cloud/dataproc/v1/cluster_controller/paths"
26
27
  require "google/cloud/dataproc/v1/cluster_controller/operations"
27
28
  require "google/cloud/dataproc/v1/cluster_controller/client"
28
29
 
@@ -31,6 +31,8 @@ module Google
31
31
  # of Compute Engine instances.
32
32
  #
33
33
  class Client
34
+ include Paths
35
+
34
36
  # @private
35
37
  attr_reader :cluster_controller_stub
36
38
 
@@ -59,7 +61,7 @@ module Google
59
61
  parent_config = while namespace.any?
60
62
  parent_name = namespace.join "::"
61
63
  parent_const = const_get parent_name
62
- break parent_const.configure if parent_const&.respond_to? :configure
64
+ break parent_const.configure if parent_const.respond_to? :configure
63
65
  namespace.pop
64
66
  end
65
67
  default_config = Client::Configuration.new parent_config
@@ -67,49 +69,49 @@ module Google
67
69
  default_config.rpcs.create_cluster.timeout = 300.0
68
70
  default_config.rpcs.create_cluster.retry_policy = {
69
71
  initial_delay: 0.1,
70
- max_delay: 60.0,
71
- multiplier: 1.3,
72
- retry_codes: [14]
72
+ max_delay: 60.0,
73
+ multiplier: 1.3,
74
+ retry_codes: [14]
73
75
  }
74
76
 
75
77
  default_config.rpcs.update_cluster.timeout = 300.0
76
78
  default_config.rpcs.update_cluster.retry_policy = {
77
79
  initial_delay: 0.1,
78
- max_delay: 60.0,
79
- multiplier: 1.3,
80
- retry_codes: [14]
80
+ max_delay: 60.0,
81
+ multiplier: 1.3,
82
+ retry_codes: [14]
81
83
  }
82
84
 
83
85
  default_config.rpcs.delete_cluster.timeout = 300.0
84
86
  default_config.rpcs.delete_cluster.retry_policy = {
85
87
  initial_delay: 0.1,
86
- max_delay: 60.0,
87
- multiplier: 1.3,
88
- retry_codes: [14]
88
+ max_delay: 60.0,
89
+ multiplier: 1.3,
90
+ retry_codes: [14]
89
91
  }
90
92
 
91
93
  default_config.rpcs.get_cluster.timeout = 300.0
92
94
  default_config.rpcs.get_cluster.retry_policy = {
93
95
  initial_delay: 0.1,
94
- max_delay: 60.0,
95
- multiplier: 1.3,
96
- retry_codes: [13, 4, 14]
96
+ max_delay: 60.0,
97
+ multiplier: 1.3,
98
+ retry_codes: [13, 4, 14]
97
99
  }
98
100
 
99
101
  default_config.rpcs.list_clusters.timeout = 300.0
100
102
  default_config.rpcs.list_clusters.retry_policy = {
101
103
  initial_delay: 0.1,
102
- max_delay: 60.0,
103
- multiplier: 1.3,
104
- retry_codes: [13, 4, 14]
104
+ max_delay: 60.0,
105
+ multiplier: 1.3,
106
+ retry_codes: [13, 4, 14]
105
107
  }
106
108
 
107
109
  default_config.rpcs.diagnose_cluster.timeout = 300.0
108
110
  default_config.rpcs.diagnose_cluster.retry_policy = {
109
111
  initial_delay: 0.1,
110
- max_delay: 60.0,
111
- multiplier: 1.3,
112
- retry_codes: [14]
112
+ max_delay: 60.0,
113
+ multiplier: 1.3,
114
+ retry_codes: [14]
113
115
  }
114
116
 
115
117
  default_config
@@ -173,7 +175,13 @@ module Google
173
175
 
174
176
  # Create credentials
175
177
  credentials = @config.credentials
176
- credentials ||= Credentials.default scope: @config.scope
178
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
179
+ # but only if the default endpoint does not have a region prefix.
180
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
181
+ @config.endpoint == Client.configure.endpoint &&
182
+ !@config.endpoint.split(".").first.include?("-")
183
+ credentials ||= Credentials.default scope: @config.scope,
184
+ enable_self_signed_jwt: enable_self_signed_jwt
177
185
  if credentials.is_a?(String) || credentials.is_a?(Hash)
178
186
  credentials = Credentials.new credentials, scope: @config.scope
179
187
  end
@@ -231,9 +239,9 @@ module Google
231
239
  # @param cluster [::Google::Cloud::Dataproc::V1::Cluster, ::Hash]
232
240
  # Required. The cluster to create.
233
241
  # @param request_id [::String]
234
- # Optional. A unique id used to identify the request. If the server
235
- # receives two {::Google::Cloud::Dataproc::V1::CreateClusterRequest CreateClusterRequest} requests with the same
236
- # id, then the second request will be ignored and the
242
+ # Optional. A unique id used to identify the request. If the server receives two
243
+ # [CreateClusterRequest](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.dataproc.v1.CreateClusterRequest)s
244
+ # with the same id, then the second request will be ignored and the
237
245
  # first {::Google::Longrunning::Operation google.longrunning.Operation} created and stored in the backend
238
246
  # is returned.
239
247
  #
@@ -270,7 +278,7 @@ module Google
270
278
 
271
279
  header_params = {
272
280
  "project_id" => request.project_id,
273
- "region" => request.region
281
+ "region" => request.region
274
282
  }
275
283
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
276
284
  metadata[:"x-goog-request-params"] ||= request_params_header
@@ -383,8 +391,9 @@ module Google
383
391
  # </table>
384
392
  # @param request_id [::String]
385
393
  # Optional. A unique id used to identify the request. If the server
386
- # receives two {::Google::Cloud::Dataproc::V1::UpdateClusterRequest UpdateClusterRequest} requests with the same
387
- # id, then the second request will be ignored and the
394
+ # receives two
395
+ # [UpdateClusterRequest](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.dataproc.v1.UpdateClusterRequest)s
396
+ # with the same id, then the second request will be ignored and the
388
397
  # first {::Google::Longrunning::Operation google.longrunning.Operation} created and stored in the
389
398
  # backend is returned.
390
399
  #
@@ -420,8 +429,8 @@ module Google
420
429
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
421
430
 
422
431
  header_params = {
423
- "project_id" => request.project_id,
424
- "region" => request.region,
432
+ "project_id" => request.project_id,
433
+ "region" => request.region,
425
434
  "cluster_name" => request.cluster_name
426
435
  }
427
436
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -442,6 +451,186 @@ module Google
442
451
  raise ::Google::Cloud::Error.from_error(e)
443
452
  end
444
453
 
454
+ ##
455
+ # Stops a cluster in a project.
456
+ #
457
+ # @overload stop_cluster(request, options = nil)
458
+ # Pass arguments to `stop_cluster` via a request object, either of type
459
+ # {::Google::Cloud::Dataproc::V1::StopClusterRequest} or an equivalent Hash.
460
+ #
461
+ # @param request [::Google::Cloud::Dataproc::V1::StopClusterRequest, ::Hash]
462
+ # A request object representing the call parameters. Required. To specify no
463
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
464
+ # @param options [::Gapic::CallOptions, ::Hash]
465
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
466
+ #
467
+ # @overload stop_cluster(project_id: nil, region: nil, cluster_name: nil, cluster_uuid: nil, request_id: nil)
468
+ # Pass arguments to `stop_cluster` via keyword arguments. Note that at
469
+ # least one keyword argument is required. To specify no parameters, or to keep all
470
+ # the default parameter values, pass an empty Hash as a request object (see above).
471
+ #
472
+ # @param project_id [::String]
473
+ # Required. The ID of the Google Cloud Platform project the
474
+ # cluster belongs to.
475
+ # @param region [::String]
476
+ # Required. The Dataproc region in which to handle the request.
477
+ # @param cluster_name [::String]
478
+ # Required. The cluster name.
479
+ # @param cluster_uuid [::String]
480
+ # Optional. Specifying the `cluster_uuid` means the RPC will fail
481
+ # (with error NOT_FOUND) if a cluster with the specified UUID does not exist.
482
+ # @param request_id [::String]
483
+ # Optional. A unique id used to identify the request. If the server
484
+ # receives two
485
+ # [StopClusterRequest](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.dataproc.v1.StopClusterRequest)s
486
+ # with the same id, then the second request will be ignored and the
487
+ # first {::Google::Longrunning::Operation google.longrunning.Operation} created and stored in the
488
+ # backend is returned.
489
+ #
490
+ # Recommendation: Set this value to a
491
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
492
+ #
493
+ # The id must contain only letters (a-z, A-Z), numbers (0-9),
494
+ # underscores (_), and hyphens (-). The maximum length is 40 characters.
495
+ #
496
+ # @yield [response, operation] Access the result along with the RPC operation
497
+ # @yieldparam response [::Gapic::Operation]
498
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
499
+ #
500
+ # @return [::Gapic::Operation]
501
+ #
502
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
503
+ #
504
+ def stop_cluster request, options = nil
505
+ raise ::ArgumentError, "request must be provided" if request.nil?
506
+
507
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dataproc::V1::StopClusterRequest
508
+
509
+ # Converts hash and nil to an options object
510
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
511
+
512
+ # Customize the options with defaults
513
+ metadata = @config.rpcs.stop_cluster.metadata.to_h
514
+
515
+ # Set x-goog-api-client and x-goog-user-project headers
516
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
517
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
518
+ gapic_version: ::Google::Cloud::Dataproc::V1::VERSION
519
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
520
+
521
+ header_params = {
522
+ "project_id" => request.project_id,
523
+ "region" => request.region,
524
+ "cluster_name" => request.cluster_name
525
+ }
526
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
527
+ metadata[:"x-goog-request-params"] ||= request_params_header
528
+
529
+ options.apply_defaults timeout: @config.rpcs.stop_cluster.timeout,
530
+ metadata: metadata,
531
+ retry_policy: @config.rpcs.stop_cluster.retry_policy
532
+ options.apply_defaults metadata: @config.metadata,
533
+ retry_policy: @config.retry_policy
534
+
535
+ @cluster_controller_stub.call_rpc :stop_cluster, request, options: options do |response, operation|
536
+ response = ::Gapic::Operation.new response, @operations_client, options: options
537
+ yield response, operation if block_given?
538
+ return response
539
+ end
540
+ rescue ::GRPC::BadStatus => e
541
+ raise ::Google::Cloud::Error.from_error(e)
542
+ end
543
+
544
+ ##
545
+ # Starts a cluster in a project.
546
+ #
547
+ # @overload start_cluster(request, options = nil)
548
+ # Pass arguments to `start_cluster` via a request object, either of type
549
+ # {::Google::Cloud::Dataproc::V1::StartClusterRequest} or an equivalent Hash.
550
+ #
551
+ # @param request [::Google::Cloud::Dataproc::V1::StartClusterRequest, ::Hash]
552
+ # A request object representing the call parameters. Required. To specify no
553
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
554
+ # @param options [::Gapic::CallOptions, ::Hash]
555
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
556
+ #
557
+ # @overload start_cluster(project_id: nil, region: nil, cluster_name: nil, cluster_uuid: nil, request_id: nil)
558
+ # Pass arguments to `start_cluster` via keyword arguments. Note that at
559
+ # least one keyword argument is required. To specify no parameters, or to keep all
560
+ # the default parameter values, pass an empty Hash as a request object (see above).
561
+ #
562
+ # @param project_id [::String]
563
+ # Required. The ID of the Google Cloud Platform project the
564
+ # cluster belongs to.
565
+ # @param region [::String]
566
+ # Required. The Dataproc region in which to handle the request.
567
+ # @param cluster_name [::String]
568
+ # Required. The cluster name.
569
+ # @param cluster_uuid [::String]
570
+ # Optional. Specifying the `cluster_uuid` means the RPC will fail
571
+ # (with error NOT_FOUND) if a cluster with the specified UUID does not exist.
572
+ # @param request_id [::String]
573
+ # Optional. A unique id used to identify the request. If the server
574
+ # receives two
575
+ # [StartClusterRequest](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.dataproc.v1.StartClusterRequest)s
576
+ # with the same id, then the second request will be ignored and the
577
+ # first {::Google::Longrunning::Operation google.longrunning.Operation} created and stored in the
578
+ # backend is returned.
579
+ #
580
+ # Recommendation: Set this value to a
581
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
582
+ #
583
+ # The id must contain only letters (a-z, A-Z), numbers (0-9),
584
+ # underscores (_), and hyphens (-). The maximum length is 40 characters.
585
+ #
586
+ # @yield [response, operation] Access the result along with the RPC operation
587
+ # @yieldparam response [::Gapic::Operation]
588
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
589
+ #
590
+ # @return [::Gapic::Operation]
591
+ #
592
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
593
+ #
594
+ def start_cluster request, options = nil
595
+ raise ::ArgumentError, "request must be provided" if request.nil?
596
+
597
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dataproc::V1::StartClusterRequest
598
+
599
+ # Converts hash and nil to an options object
600
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
601
+
602
+ # Customize the options with defaults
603
+ metadata = @config.rpcs.start_cluster.metadata.to_h
604
+
605
+ # Set x-goog-api-client and x-goog-user-project headers
606
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
607
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
608
+ gapic_version: ::Google::Cloud::Dataproc::V1::VERSION
609
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
610
+
611
+ header_params = {
612
+ "project_id" => request.project_id,
613
+ "region" => request.region,
614
+ "cluster_name" => request.cluster_name
615
+ }
616
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
617
+ metadata[:"x-goog-request-params"] ||= request_params_header
618
+
619
+ options.apply_defaults timeout: @config.rpcs.start_cluster.timeout,
620
+ metadata: metadata,
621
+ retry_policy: @config.rpcs.start_cluster.retry_policy
622
+ options.apply_defaults metadata: @config.metadata,
623
+ retry_policy: @config.retry_policy
624
+
625
+ @cluster_controller_stub.call_rpc :start_cluster, request, options: options do |response, operation|
626
+ response = ::Gapic::Operation.new response, @operations_client, options: options
627
+ yield response, operation if block_given?
628
+ return response
629
+ end
630
+ rescue ::GRPC::BadStatus => e
631
+ raise ::Google::Cloud::Error.from_error(e)
632
+ end
633
+
445
634
  ##
446
635
  # Deletes a cluster in a project. The returned
447
636
  # {::Google::Longrunning::Operation#metadata Operation.metadata} will be
@@ -474,8 +663,9 @@ module Google
474
663
  # (with error NOT_FOUND) if cluster with specified UUID does not exist.
475
664
  # @param request_id [::String]
476
665
  # Optional. A unique id used to identify the request. If the server
477
- # receives two {::Google::Cloud::Dataproc::V1::DeleteClusterRequest DeleteClusterRequest} requests with the same
478
- # id, then the second request will be ignored and the
666
+ # receives two
667
+ # [DeleteClusterRequest](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.dataproc.v1.DeleteClusterRequest)s
668
+ # with the same id, then the second request will be ignored and the
479
669
  # first {::Google::Longrunning::Operation google.longrunning.Operation} created and stored in the
480
670
  # backend is returned.
481
671
  #
@@ -511,8 +701,8 @@ module Google
511
701
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
512
702
 
513
703
  header_params = {
514
- "project_id" => request.project_id,
515
- "region" => request.region,
704
+ "project_id" => request.project_id,
705
+ "region" => request.region,
516
706
  "cluster_name" => request.cluster_name
517
707
  }
518
708
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -585,8 +775,8 @@ module Google
585
775
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
586
776
 
587
777
  header_params = {
588
- "project_id" => request.project_id,
589
- "region" => request.region,
778
+ "project_id" => request.project_id,
779
+ "region" => request.region,
590
780
  "cluster_name" => request.cluster_name
591
781
  }
592
782
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -681,7 +871,7 @@ module Google
681
871
 
682
872
  header_params = {
683
873
  "project_id" => request.project_id,
684
- "region" => request.region
874
+ "region" => request.region
685
875
  }
686
876
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
687
877
  metadata[:"x-goog-request-params"] ||= request_params_header
@@ -759,8 +949,8 @@ module Google
759
949
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
760
950
 
761
951
  header_params = {
762
- "project_id" => request.project_id,
763
- "region" => request.region,
952
+ "project_id" => request.project_id,
953
+ "region" => request.region,
764
954
  "cluster_name" => request.cluster_name
765
955
  }
766
956
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -866,14 +1056,14 @@ module Google
866
1056
 
867
1057
  config_attr :endpoint, "dataproc.googleapis.com", ::String
868
1058
  config_attr :credentials, nil do |value|
869
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1059
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
870
1060
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
871
1061
  allowed.any? { |klass| klass === value }
872
1062
  end
873
1063
  config_attr :scope, nil, ::String, ::Array, nil
874
1064
  config_attr :lib_name, nil, ::String, nil
875
1065
  config_attr :lib_version, nil, ::String, nil
876
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1066
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
877
1067
  config_attr :interceptors, nil, ::Array, nil
878
1068
  config_attr :timeout, nil, ::Numeric, nil
879
1069
  config_attr :metadata, nil, ::Hash, nil
@@ -894,7 +1084,7 @@ module Google
894
1084
  def rpcs
895
1085
  @rpcs ||= begin
896
1086
  parent_rpcs = nil
897
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1087
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
898
1088
  Rpcs.new parent_rpcs
899
1089
  end
900
1090
  end
@@ -906,7 +1096,7 @@ module Google
906
1096
  # Each configuration object is of type `Gapic::Config::Method` and includes
907
1097
  # the following configuration fields:
908
1098
  #
909
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1099
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
910
1100
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
911
1101
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
912
1102
  # include the following keys:
@@ -928,6 +1118,16 @@ module Google
928
1118
  #
929
1119
  attr_reader :update_cluster
930
1120
  ##
1121
+ # RPC-specific configuration for `stop_cluster`
1122
+ # @return [::Gapic::Config::Method]
1123
+ #
1124
+ attr_reader :stop_cluster
1125
+ ##
1126
+ # RPC-specific configuration for `start_cluster`
1127
+ # @return [::Gapic::Config::Method]
1128
+ #
1129
+ attr_reader :start_cluster
1130
+ ##
931
1131
  # RPC-specific configuration for `delete_cluster`
932
1132
  # @return [::Gapic::Config::Method]
933
1133
  #
@@ -950,17 +1150,21 @@ module Google
950
1150
 
951
1151
  # @private
952
1152
  def initialize parent_rpcs = nil
953
- create_cluster_config = parent_rpcs&.create_cluster if parent_rpcs&.respond_to? :create_cluster
1153
+ create_cluster_config = parent_rpcs.create_cluster if parent_rpcs.respond_to? :create_cluster
954
1154
  @create_cluster = ::Gapic::Config::Method.new create_cluster_config
955
- update_cluster_config = parent_rpcs&.update_cluster if parent_rpcs&.respond_to? :update_cluster
1155
+ update_cluster_config = parent_rpcs.update_cluster if parent_rpcs.respond_to? :update_cluster
956
1156
  @update_cluster = ::Gapic::Config::Method.new update_cluster_config
957
- delete_cluster_config = parent_rpcs&.delete_cluster if parent_rpcs&.respond_to? :delete_cluster
1157
+ stop_cluster_config = parent_rpcs.stop_cluster if parent_rpcs.respond_to? :stop_cluster
1158
+ @stop_cluster = ::Gapic::Config::Method.new stop_cluster_config
1159
+ start_cluster_config = parent_rpcs.start_cluster if parent_rpcs.respond_to? :start_cluster
1160
+ @start_cluster = ::Gapic::Config::Method.new start_cluster_config
1161
+ delete_cluster_config = parent_rpcs.delete_cluster if parent_rpcs.respond_to? :delete_cluster
958
1162
  @delete_cluster = ::Gapic::Config::Method.new delete_cluster_config
959
- get_cluster_config = parent_rpcs&.get_cluster if parent_rpcs&.respond_to? :get_cluster
1163
+ get_cluster_config = parent_rpcs.get_cluster if parent_rpcs.respond_to? :get_cluster
960
1164
  @get_cluster = ::Gapic::Config::Method.new get_cluster_config
961
- list_clusters_config = parent_rpcs&.list_clusters if parent_rpcs&.respond_to? :list_clusters
1165
+ list_clusters_config = parent_rpcs.list_clusters if parent_rpcs.respond_to? :list_clusters
962
1166
  @list_clusters = ::Gapic::Config::Method.new list_clusters_config
963
- diagnose_cluster_config = parent_rpcs&.diagnose_cluster if parent_rpcs&.respond_to? :diagnose_cluster
1167
+ diagnose_cluster_config = parent_rpcs.diagnose_cluster if parent_rpcs.respond_to? :diagnose_cluster
964
1168
  @diagnose_cluster = ::Gapic::Config::Method.new diagnose_cluster_config
965
1169
 
966
1170
  yield self if block_given?