google-cloud-dataproc 0.1.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.
- checksums.yaml +7 -0
- data/.yardopts +8 -0
- data/LICENSE +201 -0
- data/README.md +54 -0
- data/lib/google/cloud/dataproc.rb +177 -0
- data/lib/google/cloud/dataproc/credentials.rb +30 -0
- data/lib/google/cloud/dataproc/v1.rb +171 -0
- data/lib/google/cloud/dataproc/v1/cluster_controller_client.rb +670 -0
- data/lib/google/cloud/dataproc/v1/cluster_controller_client_config.json +56 -0
- data/lib/google/cloud/dataproc/v1/clusters_pb.rb +166 -0
- data/lib/google/cloud/dataproc/v1/clusters_services_pb.rb +58 -0
- data/lib/google/cloud/dataproc/v1/doc/google/cloud/dataproc/v1/clusters.rb +565 -0
- data/lib/google/cloud/dataproc/v1/doc/google/cloud/dataproc/v1/jobs.rb +682 -0
- data/lib/google/cloud/dataproc/v1/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/dataproc/v1/doc/google/protobuf/duration.rb +90 -0
- data/lib/google/cloud/dataproc/v1/doc/google/protobuf/field_mask.rb +223 -0
- data/lib/google/cloud/dataproc/v1/doc/google/protobuf/timestamp.rb +106 -0
- data/lib/google/cloud/dataproc/v1/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/dataproc/v1/doc/overview.rb +77 -0
- data/lib/google/cloud/dataproc/v1/job_controller_client.rb +487 -0
- data/lib/google/cloud/dataproc/v1/job_controller_client_config.json +56 -0
- data/lib/google/cloud/dataproc/v1/jobs_pb.rb +244 -0
- data/lib/google/cloud/dataproc/v1/jobs_services_pb.rb +59 -0
- data/lib/google/cloud/dataproc/v1/operations_pb.rb +45 -0
- metadata +123 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Rpc
|
17
|
+
# The +Status+ type defines a logical error model that is suitable for different
|
18
|
+
# programming environments, including REST APIs and RPC APIs. It is used by
|
19
|
+
# [gRPC](https://github.com/grpc). The error model is designed to be:
|
20
|
+
#
|
21
|
+
# * Simple to use and understand for most users
|
22
|
+
# * Flexible enough to meet unexpected needs
|
23
|
+
#
|
24
|
+
# = Overview
|
25
|
+
#
|
26
|
+
# The +Status+ message contains three pieces of data: error code, error message,
|
27
|
+
# and error details. The error code should be an enum value of
|
28
|
+
# {Google::Rpc::Code}, but it may accept additional error codes if needed. The
|
29
|
+
# error message should be a developer-facing English message that helps
|
30
|
+
# developers *understand* and *resolve* the error. If a localized user-facing
|
31
|
+
# error message is needed, put the localized message in the error details or
|
32
|
+
# localize it in the client. The optional error details may contain arbitrary
|
33
|
+
# information about the error. There is a predefined set of error detail types
|
34
|
+
# in the package +google.rpc+ that can be used for common error conditions.
|
35
|
+
#
|
36
|
+
# = Language mapping
|
37
|
+
#
|
38
|
+
# The +Status+ message is the logical representation of the error model, but it
|
39
|
+
# is not necessarily the actual wire format. When the +Status+ message is
|
40
|
+
# exposed in different client libraries and different wire protocols, it can be
|
41
|
+
# mapped differently. For example, it will likely be mapped to some exceptions
|
42
|
+
# in Java, but more likely mapped to some error codes in C.
|
43
|
+
#
|
44
|
+
# = Other uses
|
45
|
+
#
|
46
|
+
# The error model and the +Status+ message can be used in a variety of
|
47
|
+
# environments, either with or without APIs, to provide a
|
48
|
+
# consistent developer experience across different environments.
|
49
|
+
#
|
50
|
+
# Example uses of this error model include:
|
51
|
+
#
|
52
|
+
# * Partial errors. If a service needs to return partial errors to the client,
|
53
|
+
# it may embed the +Status+ in the normal response to indicate the partial
|
54
|
+
# errors.
|
55
|
+
#
|
56
|
+
# * Workflow errors. A typical workflow has multiple steps. Each step may
|
57
|
+
# have a +Status+ message for error reporting.
|
58
|
+
#
|
59
|
+
# * Batch operations. If a client uses batch request and batch response, the
|
60
|
+
# +Status+ message should be used directly inside batch response, one for
|
61
|
+
# each error sub-response.
|
62
|
+
#
|
63
|
+
# * Asynchronous operations. If an API call embeds asynchronous operation
|
64
|
+
# results in its response, the status of those operations should be
|
65
|
+
# represented directly using the +Status+ message.
|
66
|
+
#
|
67
|
+
# * Logging. If some API errors are stored in logs, the message +Status+ could
|
68
|
+
# be used directly after any stripping needed for security/privacy reasons.
|
69
|
+
# @!attribute [rw] code
|
70
|
+
# @return [Integer]
|
71
|
+
# The status code, which should be an enum value of {Google::Rpc::Code}.
|
72
|
+
# @!attribute [rw] message
|
73
|
+
# @return [String]
|
74
|
+
# A developer-facing error message, which should be in English. Any
|
75
|
+
# user-facing error message should be localized and sent in the
|
76
|
+
# {Google::Rpc::Status#details} field, or localized by the client.
|
77
|
+
# @!attribute [rw] details
|
78
|
+
# @return [Array<Google::Protobuf::Any>]
|
79
|
+
# A list of messages that carry the error details. There is a common set of
|
80
|
+
# message types for APIs to use.
|
81
|
+
class Status; end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Cloud
|
17
|
+
# rubocop:disable LineLength
|
18
|
+
|
19
|
+
##
|
20
|
+
# # Ruby Client for Google Cloud Dataproc API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
21
|
+
#
|
22
|
+
# [Google Cloud Dataproc API][Product Documentation]:
|
23
|
+
# Manages Hadoop-based clusters and jobs on Google Cloud Platform.
|
24
|
+
# - [Product Documentation][]
|
25
|
+
#
|
26
|
+
# ## Quick Start
|
27
|
+
# In order to use this library, you first need to go through the following
|
28
|
+
# steps:
|
29
|
+
#
|
30
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
31
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
32
|
+
# 3. [Enable the Google Cloud Dataproc API.](https://console.cloud.google.com/apis/api/dataproc)
|
33
|
+
# 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
34
|
+
#
|
35
|
+
# ### Installation
|
36
|
+
# ```
|
37
|
+
# $ gem install google-cloud-dataproc
|
38
|
+
# ```
|
39
|
+
#
|
40
|
+
# ### Preview
|
41
|
+
# #### ClusterControllerClient
|
42
|
+
# ```rb
|
43
|
+
# require "google/cloud/dataproc"
|
44
|
+
#
|
45
|
+
# cluster_controller_client = Google::Cloud::Dataproc::ClusterController.new
|
46
|
+
# project_id_2 = project_id
|
47
|
+
# region = "global"
|
48
|
+
#
|
49
|
+
# # Iterate over all results.
|
50
|
+
# cluster_controller_client.list_clusters(project_id_2, region).each do |element|
|
51
|
+
# # Process element.
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# # Or iterate over results one page at a time.
|
55
|
+
# cluster_controller_client.list_clusters(project_id_2, region).each_page do |page|
|
56
|
+
# # Process each page at a time.
|
57
|
+
# page.each do |element|
|
58
|
+
# # Process element.
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
# ```
|
62
|
+
#
|
63
|
+
# ### Next Steps
|
64
|
+
# - Read the [Google Cloud Dataproc API Product documentation][Product Documentation]
|
65
|
+
# to learn more about the product and see How-to Guides.
|
66
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
67
|
+
# to see the full list of Cloud APIs that we cover.
|
68
|
+
#
|
69
|
+
# [Product Documentation]: https://cloud.google.com/dataproc
|
70
|
+
#
|
71
|
+
#
|
72
|
+
module Dataproc
|
73
|
+
module V1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,487 @@
|
|
1
|
+
# Copyright 2017 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/v1/jobs.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
|
+
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
+
# merge preserves those additions if the generated source changes.
|
24
|
+
|
25
|
+
require "json"
|
26
|
+
require "pathname"
|
27
|
+
|
28
|
+
require "google/gax"
|
29
|
+
|
30
|
+
require "google/cloud/dataproc/v1/jobs_pb"
|
31
|
+
require "google/cloud/dataproc/credentials"
|
32
|
+
|
33
|
+
module Google
|
34
|
+
module Cloud
|
35
|
+
module Dataproc
|
36
|
+
module V1
|
37
|
+
# The JobController provides methods to manage jobs.
|
38
|
+
#
|
39
|
+
# @!attribute [r] job_controller_stub
|
40
|
+
# @return [Google::Cloud::Dataproc::V1::JobController::Stub]
|
41
|
+
class JobControllerClient
|
42
|
+
attr_reader :job_controller_stub
|
43
|
+
|
44
|
+
# The default address of the service.
|
45
|
+
SERVICE_ADDRESS = "dataproc.googleapis.com".freeze
|
46
|
+
|
47
|
+
# The default port of the service.
|
48
|
+
DEFAULT_SERVICE_PORT = 443
|
49
|
+
|
50
|
+
DEFAULT_TIMEOUT = 30
|
51
|
+
|
52
|
+
PAGE_DESCRIPTORS = {
|
53
|
+
"list_jobs" => Google::Gax::PageDescriptor.new(
|
54
|
+
"page_token",
|
55
|
+
"next_page_token",
|
56
|
+
"jobs")
|
57
|
+
}.freeze
|
58
|
+
|
59
|
+
private_constant :PAGE_DESCRIPTORS
|
60
|
+
|
61
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
62
|
+
# this service.
|
63
|
+
ALL_SCOPES = [
|
64
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
65
|
+
].freeze
|
66
|
+
|
67
|
+
|
68
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
69
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
70
|
+
# be many types.
|
71
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
72
|
+
# authenticating requests made by this client.
|
73
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
74
|
+
# credentials for this client.
|
75
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
76
|
+
# credentials for this client.
|
77
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
78
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
79
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
80
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
81
|
+
# metadata for requests, generally, to give OAuth credentials.
|
82
|
+
# @param scopes [Array<String>]
|
83
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
84
|
+
# an updater_proc is supplied.
|
85
|
+
# @param client_config [Hash]
|
86
|
+
# A Hash for call options for each method. See
|
87
|
+
# Google::Gax#construct_settings for the structure of
|
88
|
+
# this data. Falls back to the default config if not specified
|
89
|
+
# or the specified config is missing data points.
|
90
|
+
# @param timeout [Numeric]
|
91
|
+
# The default timeout, in seconds, for calls made through this client.
|
92
|
+
def initialize \
|
93
|
+
credentials: nil,
|
94
|
+
scopes: ALL_SCOPES,
|
95
|
+
client_config: {},
|
96
|
+
timeout: DEFAULT_TIMEOUT,
|
97
|
+
lib_name: nil,
|
98
|
+
lib_version: ""
|
99
|
+
# These require statements are intentionally placed here to initialize
|
100
|
+
# the gRPC module only when it's required.
|
101
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
102
|
+
require "google/gax/grpc"
|
103
|
+
require "google/cloud/dataproc/v1/jobs_services_pb"
|
104
|
+
|
105
|
+
credentials ||= Google::Cloud::Dataproc::Credentials.default
|
106
|
+
|
107
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
108
|
+
updater_proc = Google::Cloud::Dataproc::Credentials.new(credentials).updater_proc
|
109
|
+
end
|
110
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
111
|
+
channel = credentials
|
112
|
+
end
|
113
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
114
|
+
chan_creds = credentials
|
115
|
+
end
|
116
|
+
if credentials.is_a?(Proc)
|
117
|
+
updater_proc = credentials
|
118
|
+
end
|
119
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
120
|
+
updater_proc = credentials.updater_proc
|
121
|
+
end
|
122
|
+
|
123
|
+
package_version = Gem.loaded_specs['google-cloud-dataproc'].version.version
|
124
|
+
|
125
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
126
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
127
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
128
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
129
|
+
google_api_client.freeze
|
130
|
+
|
131
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
132
|
+
client_config_file = Pathname.new(__dir__).join(
|
133
|
+
"job_controller_client_config.json"
|
134
|
+
)
|
135
|
+
defaults = client_config_file.open do |f|
|
136
|
+
Google::Gax.construct_settings(
|
137
|
+
"google.cloud.dataproc.v1.JobController",
|
138
|
+
JSON.parse(f.read),
|
139
|
+
client_config,
|
140
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
141
|
+
timeout,
|
142
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
143
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
144
|
+
kwargs: headers
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Allow overriding the service path/port in subclasses.
|
149
|
+
service_path = self.class::SERVICE_ADDRESS
|
150
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
151
|
+
@job_controller_stub = Google::Gax::Grpc.create_stub(
|
152
|
+
service_path,
|
153
|
+
port,
|
154
|
+
chan_creds: chan_creds,
|
155
|
+
channel: channel,
|
156
|
+
updater_proc: updater_proc,
|
157
|
+
scopes: scopes,
|
158
|
+
&Google::Cloud::Dataproc::V1::JobController::Stub.method(:new)
|
159
|
+
)
|
160
|
+
|
161
|
+
@submit_job = Google::Gax.create_api_call(
|
162
|
+
@job_controller_stub.method(:submit_job),
|
163
|
+
defaults["submit_job"]
|
164
|
+
)
|
165
|
+
@get_job = Google::Gax.create_api_call(
|
166
|
+
@job_controller_stub.method(:get_job),
|
167
|
+
defaults["get_job"]
|
168
|
+
)
|
169
|
+
@list_jobs = Google::Gax.create_api_call(
|
170
|
+
@job_controller_stub.method(:list_jobs),
|
171
|
+
defaults["list_jobs"]
|
172
|
+
)
|
173
|
+
@update_job = Google::Gax.create_api_call(
|
174
|
+
@job_controller_stub.method(:update_job),
|
175
|
+
defaults["update_job"]
|
176
|
+
)
|
177
|
+
@cancel_job = Google::Gax.create_api_call(
|
178
|
+
@job_controller_stub.method(:cancel_job),
|
179
|
+
defaults["cancel_job"]
|
180
|
+
)
|
181
|
+
@delete_job = Google::Gax.create_api_call(
|
182
|
+
@job_controller_stub.method(:delete_job),
|
183
|
+
defaults["delete_job"]
|
184
|
+
)
|
185
|
+
end
|
186
|
+
|
187
|
+
# Service calls
|
188
|
+
|
189
|
+
# Submits a job to a cluster.
|
190
|
+
#
|
191
|
+
# @param project_id [String]
|
192
|
+
# Required. The ID of the Google Cloud Platform project that the job
|
193
|
+
# belongs to.
|
194
|
+
# @param region [String]
|
195
|
+
# Required. The Cloud Dataproc region in which to handle the request.
|
196
|
+
# @param job [Google::Cloud::Dataproc::V1::Job | Hash]
|
197
|
+
# Required. The job resource.
|
198
|
+
# A hash of the same form as `Google::Cloud::Dataproc::V1::Job`
|
199
|
+
# can also be provided.
|
200
|
+
# @param options [Google::Gax::CallOptions]
|
201
|
+
# Overrides the default settings for this call, e.g, timeout,
|
202
|
+
# retries, etc.
|
203
|
+
# @return [Google::Cloud::Dataproc::V1::Job]
|
204
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
205
|
+
# @example
|
206
|
+
# require "google/cloud/dataproc/v1"
|
207
|
+
#
|
208
|
+
# job_controller_client = Google::Cloud::Dataproc::V1::JobController.new
|
209
|
+
# project_id = ''
|
210
|
+
# region = ''
|
211
|
+
# job = {}
|
212
|
+
# response = job_controller_client.submit_job(project_id, region, job)
|
213
|
+
|
214
|
+
def submit_job \
|
215
|
+
project_id,
|
216
|
+
region,
|
217
|
+
job,
|
218
|
+
options: nil
|
219
|
+
req = {
|
220
|
+
project_id: project_id,
|
221
|
+
region: region,
|
222
|
+
job: job
|
223
|
+
}.delete_if { |_, v| v.nil? }
|
224
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1::SubmitJobRequest)
|
225
|
+
@submit_job.call(req, options)
|
226
|
+
end
|
227
|
+
|
228
|
+
# Gets the resource representation for a job in a project.
|
229
|
+
#
|
230
|
+
# @param project_id [String]
|
231
|
+
# Required. The ID of the Google Cloud Platform project that the job
|
232
|
+
# belongs to.
|
233
|
+
# @param region [String]
|
234
|
+
# Required. The Cloud Dataproc region in which to handle the request.
|
235
|
+
# @param job_id [String]
|
236
|
+
# Required. The job ID.
|
237
|
+
# @param options [Google::Gax::CallOptions]
|
238
|
+
# Overrides the default settings for this call, e.g, timeout,
|
239
|
+
# retries, etc.
|
240
|
+
# @return [Google::Cloud::Dataproc::V1::Job]
|
241
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
242
|
+
# @example
|
243
|
+
# require "google/cloud/dataproc/v1"
|
244
|
+
#
|
245
|
+
# job_controller_client = Google::Cloud::Dataproc::V1::JobController.new
|
246
|
+
# project_id = ''
|
247
|
+
# region = ''
|
248
|
+
# job_id = ''
|
249
|
+
# response = job_controller_client.get_job(project_id, region, job_id)
|
250
|
+
|
251
|
+
def get_job \
|
252
|
+
project_id,
|
253
|
+
region,
|
254
|
+
job_id,
|
255
|
+
options: nil
|
256
|
+
req = {
|
257
|
+
project_id: project_id,
|
258
|
+
region: region,
|
259
|
+
job_id: job_id
|
260
|
+
}.delete_if { |_, v| v.nil? }
|
261
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1::GetJobRequest)
|
262
|
+
@get_job.call(req, options)
|
263
|
+
end
|
264
|
+
|
265
|
+
# Lists regions/{region}/jobs in a project.
|
266
|
+
#
|
267
|
+
# @param project_id [String]
|
268
|
+
# Required. The ID of the Google Cloud Platform project that the job
|
269
|
+
# belongs to.
|
270
|
+
# @param region [String]
|
271
|
+
# Required. The Cloud Dataproc region in which to handle the request.
|
272
|
+
# @param page_size [Integer]
|
273
|
+
# The maximum number of resources contained in the underlying API
|
274
|
+
# response. If page streaming is performed per-resource, this
|
275
|
+
# parameter does not affect the return value. If page streaming is
|
276
|
+
# performed per-page, this determines the maximum number of
|
277
|
+
# resources in a page.
|
278
|
+
# @param cluster_name [String]
|
279
|
+
# Optional. If set, the returned jobs list includes only jobs that were
|
280
|
+
# submitted to the named cluster.
|
281
|
+
# @param job_state_matcher [Google::Cloud::Dataproc::V1::ListJobsRequest::JobStateMatcher]
|
282
|
+
# Optional. Specifies enumerated categories of jobs to list.
|
283
|
+
# (default = match ALL jobs).
|
284
|
+
#
|
285
|
+
# If +filter+ is provided, +jobStateMatcher+ will be ignored.
|
286
|
+
# @param filter [String]
|
287
|
+
# Optional. A filter constraining the jobs to list. Filters are
|
288
|
+
# case-sensitive and have the following syntax:
|
289
|
+
#
|
290
|
+
# [field = value] AND [field [= value]] ...
|
291
|
+
#
|
292
|
+
# where **field** is +status.state+ or +labels.[KEY]+, and +[KEY]+ is a label
|
293
|
+
# key. **value** can be +*+ to match all values.
|
294
|
+
# +status.state+ can be either +ACTIVE+ or +NON_ACTIVE+.
|
295
|
+
# Only the logical +AND+ operator is supported; space-separated items are
|
296
|
+
# treated as having an implicit +AND+ operator.
|
297
|
+
#
|
298
|
+
# Example filter:
|
299
|
+
#
|
300
|
+
# status.state = ACTIVE AND labels.env = staging AND labels.starred = *
|
301
|
+
# @param options [Google::Gax::CallOptions]
|
302
|
+
# Overrides the default settings for this call, e.g, timeout,
|
303
|
+
# retries, etc.
|
304
|
+
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Dataproc::V1::Job>]
|
305
|
+
# An enumerable of Google::Cloud::Dataproc::V1::Job instances.
|
306
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
307
|
+
# operations such as per-page iteration or access to the response
|
308
|
+
# object.
|
309
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
310
|
+
# @example
|
311
|
+
# require "google/cloud/dataproc/v1"
|
312
|
+
#
|
313
|
+
# job_controller_client = Google::Cloud::Dataproc::V1::JobController.new
|
314
|
+
# project_id = ''
|
315
|
+
# region = ''
|
316
|
+
#
|
317
|
+
# # Iterate over all results.
|
318
|
+
# job_controller_client.list_jobs(project_id, region).each do |element|
|
319
|
+
# # Process element.
|
320
|
+
# end
|
321
|
+
#
|
322
|
+
# # Or iterate over results one page at a time.
|
323
|
+
# job_controller_client.list_jobs(project_id, region).each_page do |page|
|
324
|
+
# # Process each page at a time.
|
325
|
+
# page.each do |element|
|
326
|
+
# # Process element.
|
327
|
+
# end
|
328
|
+
# end
|
329
|
+
|
330
|
+
def list_jobs \
|
331
|
+
project_id,
|
332
|
+
region,
|
333
|
+
page_size: nil,
|
334
|
+
cluster_name: nil,
|
335
|
+
job_state_matcher: nil,
|
336
|
+
filter: nil,
|
337
|
+
options: nil
|
338
|
+
req = {
|
339
|
+
project_id: project_id,
|
340
|
+
region: region,
|
341
|
+
page_size: page_size,
|
342
|
+
cluster_name: cluster_name,
|
343
|
+
job_state_matcher: job_state_matcher,
|
344
|
+
filter: filter
|
345
|
+
}.delete_if { |_, v| v.nil? }
|
346
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1::ListJobsRequest)
|
347
|
+
@list_jobs.call(req, options)
|
348
|
+
end
|
349
|
+
|
350
|
+
# Updates a job in a project.
|
351
|
+
#
|
352
|
+
# @param project_id [String]
|
353
|
+
# Required. The ID of the Google Cloud Platform project that the job
|
354
|
+
# belongs to.
|
355
|
+
# @param region [String]
|
356
|
+
# Required. The Cloud Dataproc region in which to handle the request.
|
357
|
+
# @param job_id [String]
|
358
|
+
# Required. The job ID.
|
359
|
+
# @param job [Google::Cloud::Dataproc::V1::Job | Hash]
|
360
|
+
# Required. The changes to the job.
|
361
|
+
# A hash of the same form as `Google::Cloud::Dataproc::V1::Job`
|
362
|
+
# can also be provided.
|
363
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
364
|
+
# Required. Specifies the path, relative to <code>Job</code>, of
|
365
|
+
# the field to update. For example, to update the labels of a Job the
|
366
|
+
# <code>update_mask</code> parameter would be specified as
|
367
|
+
# <code>labels</code>, and the +PATCH+ request body would specify the new
|
368
|
+
# value. <strong>Note:</strong> Currently, <code>labels</code> is the only
|
369
|
+
# field that can be updated.
|
370
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
371
|
+
# can also be provided.
|
372
|
+
# @param options [Google::Gax::CallOptions]
|
373
|
+
# Overrides the default settings for this call, e.g, timeout,
|
374
|
+
# retries, etc.
|
375
|
+
# @return [Google::Cloud::Dataproc::V1::Job]
|
376
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
377
|
+
# @example
|
378
|
+
# require "google/cloud/dataproc/v1"
|
379
|
+
#
|
380
|
+
# job_controller_client = Google::Cloud::Dataproc::V1::JobController.new
|
381
|
+
# project_id = ''
|
382
|
+
# region = ''
|
383
|
+
# job_id = ''
|
384
|
+
# job = {}
|
385
|
+
# update_mask = {}
|
386
|
+
# response = job_controller_client.update_job(project_id, region, job_id, job, update_mask)
|
387
|
+
|
388
|
+
def update_job \
|
389
|
+
project_id,
|
390
|
+
region,
|
391
|
+
job_id,
|
392
|
+
job,
|
393
|
+
update_mask,
|
394
|
+
options: nil
|
395
|
+
req = {
|
396
|
+
project_id: project_id,
|
397
|
+
region: region,
|
398
|
+
job_id: job_id,
|
399
|
+
job: job,
|
400
|
+
update_mask: update_mask
|
401
|
+
}.delete_if { |_, v| v.nil? }
|
402
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1::UpdateJobRequest)
|
403
|
+
@update_job.call(req, options)
|
404
|
+
end
|
405
|
+
|
406
|
+
# Starts a job cancellation request. To access the job resource
|
407
|
+
# after cancellation, call
|
408
|
+
# [regions/{region}/jobs.list](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/list) or
|
409
|
+
# [regions/{region}/jobs.get](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/get).
|
410
|
+
#
|
411
|
+
# @param project_id [String]
|
412
|
+
# Required. The ID of the Google Cloud Platform project that the job
|
413
|
+
# belongs to.
|
414
|
+
# @param region [String]
|
415
|
+
# Required. The Cloud Dataproc region in which to handle the request.
|
416
|
+
# @param job_id [String]
|
417
|
+
# Required. The job ID.
|
418
|
+
# @param options [Google::Gax::CallOptions]
|
419
|
+
# Overrides the default settings for this call, e.g, timeout,
|
420
|
+
# retries, etc.
|
421
|
+
# @return [Google::Cloud::Dataproc::V1::Job]
|
422
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
423
|
+
# @example
|
424
|
+
# require "google/cloud/dataproc/v1"
|
425
|
+
#
|
426
|
+
# job_controller_client = Google::Cloud::Dataproc::V1::JobController.new
|
427
|
+
# project_id = ''
|
428
|
+
# region = ''
|
429
|
+
# job_id = ''
|
430
|
+
# response = job_controller_client.cancel_job(project_id, region, job_id)
|
431
|
+
|
432
|
+
def cancel_job \
|
433
|
+
project_id,
|
434
|
+
region,
|
435
|
+
job_id,
|
436
|
+
options: nil
|
437
|
+
req = {
|
438
|
+
project_id: project_id,
|
439
|
+
region: region,
|
440
|
+
job_id: job_id
|
441
|
+
}.delete_if { |_, v| v.nil? }
|
442
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1::CancelJobRequest)
|
443
|
+
@cancel_job.call(req, options)
|
444
|
+
end
|
445
|
+
|
446
|
+
# Deletes the job from the project. If the job is active, the delete fails,
|
447
|
+
# and the response returns +FAILED_PRECONDITION+.
|
448
|
+
#
|
449
|
+
# @param project_id [String]
|
450
|
+
# Required. The ID of the Google Cloud Platform project that the job
|
451
|
+
# belongs to.
|
452
|
+
# @param region [String]
|
453
|
+
# Required. The Cloud Dataproc region in which to handle the request.
|
454
|
+
# @param job_id [String]
|
455
|
+
# Required. The job ID.
|
456
|
+
# @param options [Google::Gax::CallOptions]
|
457
|
+
# Overrides the default settings for this call, e.g, timeout,
|
458
|
+
# retries, etc.
|
459
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
460
|
+
# @example
|
461
|
+
# require "google/cloud/dataproc/v1"
|
462
|
+
#
|
463
|
+
# job_controller_client = Google::Cloud::Dataproc::V1::JobController.new
|
464
|
+
# project_id = ''
|
465
|
+
# region = ''
|
466
|
+
# job_id = ''
|
467
|
+
# job_controller_client.delete_job(project_id, region, job_id)
|
468
|
+
|
469
|
+
def delete_job \
|
470
|
+
project_id,
|
471
|
+
region,
|
472
|
+
job_id,
|
473
|
+
options: nil
|
474
|
+
req = {
|
475
|
+
project_id: project_id,
|
476
|
+
region: region,
|
477
|
+
job_id: job_id
|
478
|
+
}.delete_if { |_, v| v.nil? }
|
479
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Dataproc::V1::DeleteJobRequest)
|
480
|
+
@delete_job.call(req, options)
|
481
|
+
nil
|
482
|
+
end
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|