google-cloud-dataproc-v1 0.2.3 → 0.5.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 (30) 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/client.rb +46 -40
  9. data/lib/google/cloud/dataproc/v1/cluster_controller/operations.rb +96 -11
  10. data/lib/google/cloud/dataproc/v1/clusters_pb.rb +14 -0
  11. data/lib/google/cloud/dataproc/v1/clusters_services_pb.rb +6 -6
  12. data/lib/google/cloud/dataproc/v1/job_controller/client.rb +51 -45
  13. data/lib/google/cloud/dataproc/v1/job_controller/operations.rb +96 -11
  14. data/lib/google/cloud/dataproc/v1/jobs_services_pb.rb +7 -7
  15. data/lib/google/cloud/dataproc/v1/version.rb +1 -1
  16. data/lib/google/cloud/dataproc/v1/workflow_template_service/client.rb +40 -34
  17. data/lib/google/cloud/dataproc/v1/workflow_template_service/operations.rb +96 -11
  18. data/lib/google/cloud/dataproc/v1/workflow_template_service/paths.rb +1 -1
  19. data/lib/google/cloud/dataproc/v1/workflow_templates_services_pb.rb +7 -7
  20. data/proto_docs/google/api/field_behavior.rb +6 -0
  21. data/proto_docs/google/api/resource.rb +50 -14
  22. data/proto_docs/google/cloud/dataproc/v1/autoscaling_policies.rb +8 -2
  23. data/proto_docs/google/cloud/dataproc/v1/clusters.rb +69 -2
  24. data/proto_docs/google/cloud/dataproc/v1/jobs.rb +14 -13
  25. data/proto_docs/google/cloud/dataproc/v1/shared.rb +1 -1
  26. data/proto_docs/google/cloud/dataproc/v1/workflow_templates.rb +9 -3
  27. data/proto_docs/google/longrunning/operations.rb +17 -3
  28. data/proto_docs/google/protobuf/any.rb +5 -2
  29. data/proto_docs/google/protobuf/timestamp.rb +10 -1
  30. metadata +12 -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, CreateAutoscalingPolicyRequest, 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, UpdateAutoscalingPolicyRequest, AutoscalingPolicy
43
+ rpc :UpdateAutoscalingPolicy, ::Google::Cloud::Dataproc::V1::UpdateAutoscalingPolicyRequest, ::Google::Cloud::Dataproc::V1::AutoscalingPolicy
44
44
  # Retrieves autoscaling policy.
45
- rpc :GetAutoscalingPolicy, GetAutoscalingPolicyRequest, 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, ListAutoscalingPoliciesRequest, 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, 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: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
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: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
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: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
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
 
@@ -59,7 +59,7 @@ module Google
59
59
  parent_config = while namespace.any?
60
60
  parent_name = namespace.join "::"
61
61
  parent_const = const_get parent_name
62
- break parent_const.configure if parent_const&.respond_to? :configure
62
+ break parent_const.configure if parent_const.respond_to? :configure
63
63
  namespace.pop
64
64
  end
65
65
  default_config = Client::Configuration.new parent_config
@@ -67,49 +67,49 @@ module Google
67
67
  default_config.rpcs.create_cluster.timeout = 300.0
68
68
  default_config.rpcs.create_cluster.retry_policy = {
69
69
  initial_delay: 0.1,
70
- max_delay: 60.0,
71
- multiplier: 1.3,
72
- retry_codes: ["UNAVAILABLE"]
70
+ max_delay: 60.0,
71
+ multiplier: 1.3,
72
+ retry_codes: [14]
73
73
  }
74
74
 
75
75
  default_config.rpcs.update_cluster.timeout = 300.0
76
76
  default_config.rpcs.update_cluster.retry_policy = {
77
77
  initial_delay: 0.1,
78
- max_delay: 60.0,
79
- multiplier: 1.3,
80
- retry_codes: ["UNAVAILABLE"]
78
+ max_delay: 60.0,
79
+ multiplier: 1.3,
80
+ retry_codes: [14]
81
81
  }
82
82
 
83
83
  default_config.rpcs.delete_cluster.timeout = 300.0
84
84
  default_config.rpcs.delete_cluster.retry_policy = {
85
85
  initial_delay: 0.1,
86
- max_delay: 60.0,
87
- multiplier: 1.3,
88
- retry_codes: ["UNAVAILABLE"]
86
+ max_delay: 60.0,
87
+ multiplier: 1.3,
88
+ retry_codes: [14]
89
89
  }
90
90
 
91
91
  default_config.rpcs.get_cluster.timeout = 300.0
92
92
  default_config.rpcs.get_cluster.retry_policy = {
93
93
  initial_delay: 0.1,
94
- max_delay: 60.0,
95
- multiplier: 1.3,
96
- retry_codes: ["INTERNAL", "DEADLINE_EXCEEDED", "UNAVAILABLE"]
94
+ max_delay: 60.0,
95
+ multiplier: 1.3,
96
+ retry_codes: [13, 4, 14]
97
97
  }
98
98
 
99
99
  default_config.rpcs.list_clusters.timeout = 300.0
100
100
  default_config.rpcs.list_clusters.retry_policy = {
101
101
  initial_delay: 0.1,
102
- max_delay: 60.0,
103
- multiplier: 1.3,
104
- retry_codes: ["INTERNAL", "DEADLINE_EXCEEDED", "UNAVAILABLE"]
102
+ max_delay: 60.0,
103
+ multiplier: 1.3,
104
+ retry_codes: [13, 4, 14]
105
105
  }
106
106
 
107
107
  default_config.rpcs.diagnose_cluster.timeout = 300.0
108
108
  default_config.rpcs.diagnose_cluster.retry_policy = {
109
109
  initial_delay: 0.1,
110
- max_delay: 60.0,
111
- multiplier: 1.3,
112
- retry_codes: ["UNAVAILABLE"]
110
+ max_delay: 60.0,
111
+ multiplier: 1.3,
112
+ retry_codes: [14]
113
113
  }
114
114
 
115
115
  default_config
@@ -173,7 +173,13 @@ module Google
173
173
 
174
174
  # Create credentials
175
175
  credentials = @config.credentials
176
- credentials ||= Credentials.default scope: @config.scope
176
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
177
+ # but only if the default endpoint does not have a region prefix.
178
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
179
+ @config.endpoint == Client.configure.endpoint &&
180
+ !@config.endpoint.split(".").first.include?("-")
181
+ credentials ||= Credentials.default scope: @config.scope,
182
+ enable_self_signed_jwt: enable_self_signed_jwt
177
183
  if credentials.is_a?(String) || credentials.is_a?(Hash)
178
184
  credentials = Credentials.new credentials, scope: @config.scope
179
185
  end
@@ -270,7 +276,7 @@ module Google
270
276
 
271
277
  header_params = {
272
278
  "project_id" => request.project_id,
273
- "region" => request.region
279
+ "region" => request.region
274
280
  }
275
281
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
276
282
  metadata[:"x-goog-request-params"] ||= request_params_header
@@ -420,8 +426,8 @@ module Google
420
426
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
421
427
 
422
428
  header_params = {
423
- "project_id" => request.project_id,
424
- "region" => request.region,
429
+ "project_id" => request.project_id,
430
+ "region" => request.region,
425
431
  "cluster_name" => request.cluster_name
426
432
  }
427
433
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -511,8 +517,8 @@ module Google
511
517
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
512
518
 
513
519
  header_params = {
514
- "project_id" => request.project_id,
515
- "region" => request.region,
520
+ "project_id" => request.project_id,
521
+ "region" => request.region,
516
522
  "cluster_name" => request.cluster_name
517
523
  }
518
524
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -585,8 +591,8 @@ module Google
585
591
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
586
592
 
587
593
  header_params = {
588
- "project_id" => request.project_id,
589
- "region" => request.region,
594
+ "project_id" => request.project_id,
595
+ "region" => request.region,
590
596
  "cluster_name" => request.cluster_name
591
597
  }
592
598
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -681,7 +687,7 @@ module Google
681
687
 
682
688
  header_params = {
683
689
  "project_id" => request.project_id,
684
- "region" => request.region
690
+ "region" => request.region
685
691
  }
686
692
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
687
693
  metadata[:"x-goog-request-params"] ||= request_params_header
@@ -759,8 +765,8 @@ module Google
759
765
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
760
766
 
761
767
  header_params = {
762
- "project_id" => request.project_id,
763
- "region" => request.region,
768
+ "project_id" => request.project_id,
769
+ "region" => request.region,
764
770
  "cluster_name" => request.cluster_name
765
771
  }
766
772
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
@@ -866,14 +872,14 @@ module Google
866
872
 
867
873
  config_attr :endpoint, "dataproc.googleapis.com", ::String
868
874
  config_attr :credentials, nil do |value|
869
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
875
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
870
876
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
871
877
  allowed.any? { |klass| klass === value }
872
878
  end
873
879
  config_attr :scope, nil, ::String, ::Array, nil
874
880
  config_attr :lib_name, nil, ::String, nil
875
881
  config_attr :lib_version, nil, ::String, nil
876
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
882
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
877
883
  config_attr :interceptors, nil, ::Array, nil
878
884
  config_attr :timeout, nil, ::Numeric, nil
879
885
  config_attr :metadata, nil, ::Hash, nil
@@ -894,7 +900,7 @@ module Google
894
900
  def rpcs
895
901
  @rpcs ||= begin
896
902
  parent_rpcs = nil
897
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
903
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
898
904
  Rpcs.new parent_rpcs
899
905
  end
900
906
  end
@@ -906,7 +912,7 @@ module Google
906
912
  # Each configuration object is of type `Gapic::Config::Method` and includes
907
913
  # the following configuration fields:
908
914
  #
909
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
915
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
910
916
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
911
917
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
912
918
  # include the following keys:
@@ -950,17 +956,17 @@ module Google
950
956
 
951
957
  # @private
952
958
  def initialize parent_rpcs = nil
953
- create_cluster_config = parent_rpcs&.create_cluster if parent_rpcs&.respond_to? :create_cluster
959
+ create_cluster_config = parent_rpcs.create_cluster if parent_rpcs.respond_to? :create_cluster
954
960
  @create_cluster = ::Gapic::Config::Method.new create_cluster_config
955
- update_cluster_config = parent_rpcs&.update_cluster if parent_rpcs&.respond_to? :update_cluster
961
+ update_cluster_config = parent_rpcs.update_cluster if parent_rpcs.respond_to? :update_cluster
956
962
  @update_cluster = ::Gapic::Config::Method.new update_cluster_config
957
- delete_cluster_config = parent_rpcs&.delete_cluster if parent_rpcs&.respond_to? :delete_cluster
963
+ delete_cluster_config = parent_rpcs.delete_cluster if parent_rpcs.respond_to? :delete_cluster
958
964
  @delete_cluster = ::Gapic::Config::Method.new delete_cluster_config
959
- get_cluster_config = parent_rpcs&.get_cluster if parent_rpcs&.respond_to? :get_cluster
965
+ get_cluster_config = parent_rpcs.get_cluster if parent_rpcs.respond_to? :get_cluster
960
966
  @get_cluster = ::Gapic::Config::Method.new get_cluster_config
961
- list_clusters_config = parent_rpcs&.list_clusters if parent_rpcs&.respond_to? :list_clusters
967
+ list_clusters_config = parent_rpcs.list_clusters if parent_rpcs.respond_to? :list_clusters
962
968
  @list_clusters = ::Gapic::Config::Method.new list_clusters_config
963
- diagnose_cluster_config = parent_rpcs&.diagnose_cluster if parent_rpcs&.respond_to? :diagnose_cluster
969
+ diagnose_cluster_config = parent_rpcs.diagnose_cluster if parent_rpcs.respond_to? :diagnose_cluster
964
970
  @diagnose_cluster = ::Gapic::Config::Method.new diagnose_cluster_config
965
971
 
966
972
  yield self if block_given?
@@ -103,8 +103,13 @@ module Google
103
103
  # Lists operations that match the specified filter in the request. If the
104
104
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
105
105
  #
106
- # NOTE: the `name` binding below allows API services to override the binding
107
- # to use different resource name schemes, such as `users/*/operations`.
106
+ # NOTE: the `name` binding allows API services to override the binding
107
+ # to use different resource name schemes, such as `users/*/operations`. To
108
+ # override the binding, API services can add a binding such as
109
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
110
+ # For backwards compatibility, the default name includes the operations
111
+ # collection id, however overriding users must ensure the name binding
112
+ # is the parent resource, without the operations collection id.
108
113
  #
109
114
  # @overload list_operations(request, options = nil)
110
115
  # Pass arguments to `list_operations` via a request object, either of type
@@ -122,7 +127,7 @@ module Google
122
127
  # the default parameter values, pass an empty Hash as a request object (see above).
123
128
  #
124
129
  # @param name [::String]
125
- # The name of the operation collection.
130
+ # The name of the operation's parent resource.
126
131
  # @param filter [::String]
127
132
  # The standard list filter.
128
133
  # @param page_size [::Integer]
@@ -390,6 +395,79 @@ module Google
390
395
  raise ::Google::Cloud::Error.from_error(e)
391
396
  end
392
397
 
398
+ ##
399
+ # Waits for the specified long-running operation until it is done or reaches
400
+ # at most a specified timeout, returning the latest state. If the operation
401
+ # is already done, the latest state is immediately returned. If the timeout
402
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
+ # timeout is used. If the server does not support this method, it returns
404
+ # `google.rpc.Code.UNIMPLEMENTED`.
405
+ # Note that this method is on a best-effort basis. It may return the latest
406
+ # state before the specified timeout (including immediately), meaning even an
407
+ # immediate response is no guarantee that the operation is done.
408
+ #
409
+ # @overload wait_operation(request, options = nil)
410
+ # Pass arguments to `wait_operation` via a request object, either of type
411
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
418
+ #
419
+ # @overload wait_operation(name: nil, timeout: nil)
420
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param name [::String]
425
+ # The name of the operation resource to wait on.
426
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
427
+ # The maximum duration to wait before timing out. If left blank, the wait
428
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
429
+ # If RPC context deadline is also specified, the shorter one will be used.
430
+ #
431
+ # @yield [response, operation] Access the result along with the RPC operation
432
+ # @yieldparam response [::Gapic::Operation]
433
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
434
+ #
435
+ # @return [::Gapic::Operation]
436
+ #
437
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
+ #
439
+ def wait_operation request, options = nil
440
+ raise ::ArgumentError, "request must be provided" if request.nil?
441
+
442
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
443
+
444
+ # Converts hash and nil to an options object
445
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
446
+
447
+ # Customize the options with defaults
448
+ metadata = @config.rpcs.wait_operation.metadata.to_h
449
+
450
+ # Set x-goog-api-client and x-goog-user-project headers
451
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
452
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
453
+ gapic_version: ::Google::Cloud::Dataproc::V1::VERSION
454
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
455
+
456
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
+ metadata: metadata,
458
+ retry_policy: @config.rpcs.wait_operation.retry_policy
459
+ options.apply_defaults metadata: @config.metadata,
460
+ retry_policy: @config.retry_policy
461
+
462
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
463
+ response = ::Gapic::Operation.new response, @operations_client, options: options
464
+ yield response, operation if block_given?
465
+ return response
466
+ end
467
+ rescue ::GRPC::BadStatus => e
468
+ raise ::Google::Cloud::Error.from_error(e)
469
+ end
470
+
393
471
  ##
394
472
  # Configuration class for the Operations API.
395
473
  #
@@ -475,14 +553,14 @@ module Google
475
553
 
476
554
  config_attr :endpoint, "dataproc.googleapis.com", ::String
477
555
  config_attr :credentials, nil do |value|
478
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
556
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
479
557
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
480
558
  allowed.any? { |klass| klass === value }
481
559
  end
482
560
  config_attr :scope, nil, ::String, ::Array, nil
483
561
  config_attr :lib_name, nil, ::String, nil
484
562
  config_attr :lib_version, nil, ::String, nil
485
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
563
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
486
564
  config_attr :interceptors, nil, ::Array, nil
487
565
  config_attr :timeout, nil, ::Numeric, nil
488
566
  config_attr :metadata, nil, ::Hash, nil
@@ -503,7 +581,7 @@ module Google
503
581
  def rpcs
504
582
  @rpcs ||= begin
505
583
  parent_rpcs = nil
506
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
584
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
507
585
  Rpcs.new parent_rpcs
508
586
  end
509
587
  end
@@ -515,7 +593,7 @@ module Google
515
593
  # Each configuration object is of type `Gapic::Config::Method` and includes
516
594
  # the following configuration fields:
517
595
  #
518
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
596
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
519
597
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
520
598
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
521
599
  # include the following keys:
@@ -546,17 +624,24 @@ module Google
546
624
  # @return [::Gapic::Config::Method]
547
625
  #
548
626
  attr_reader :cancel_operation
627
+ ##
628
+ # RPC-specific configuration for `wait_operation`
629
+ # @return [::Gapic::Config::Method]
630
+ #
631
+ attr_reader :wait_operation
549
632
 
550
633
  # @private
551
634
  def initialize parent_rpcs = nil
552
- list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
635
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
553
636
  @list_operations = ::Gapic::Config::Method.new list_operations_config
554
- get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
637
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
555
638
  @get_operation = ::Gapic::Config::Method.new get_operation_config
556
- delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
639
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
557
640
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
558
- cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
641
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
559
642
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
643
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
644
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
560
645
 
561
646
  yield self if block_given?
562
647
  end