google-apis-translate_v3 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.
@@ -0,0 +1,767 @@
1
+ # Copyright 2020 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
+ # http://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
+ require 'google/apis/core/base_service'
16
+ require 'google/apis/core/json_representation'
17
+ require 'google/apis/core/hashable'
18
+ require 'google/apis/errors'
19
+
20
+ module Google
21
+ module Apis
22
+ module TranslateV3
23
+ # Cloud Translation API
24
+ #
25
+ # Integrates text translation into your website or application.
26
+ #
27
+ # @example
28
+ # require 'google/apis/translate_v3'
29
+ #
30
+ # Translate = Google::Apis::TranslateV3 # Alias the module
31
+ # service = Translate::TranslateService.new
32
+ #
33
+ # @see https://cloud.google.com/translate/docs/quickstarts
34
+ class TranslateService < Google::Apis::Core::BaseService
35
+ # @return [String]
36
+ # API key. Your API key identifies your project and provides you with API access,
37
+ # quota, and reports. Required unless you provide an OAuth 2.0 token.
38
+ attr_accessor :key
39
+
40
+ # @return [String]
41
+ # Available to use for quota purposes for server-side applications. Can be any
42
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
43
+ attr_accessor :quota_user
44
+
45
+ def initialize
46
+ super('https://translation.googleapis.com/', '',
47
+ client_name: 'google-apis-translate_v3',
48
+ client_version: Google::Apis::TranslateV3::GEM_VERSION)
49
+ @batch_path = 'batch'
50
+ end
51
+
52
+ # Detects the language of text within a request.
53
+ # @param [String] parent
54
+ # Required. Project or location to make a call. Must refer to a caller's project.
55
+ # Format: `projects/`project-number-or-id`/locations/`location-id`` or `
56
+ # projects/`project-number-or-id``. For global calls, use `projects/`project-
57
+ # number-or-id`/locations/global` or `projects/`project-number-or-id``. Only
58
+ # models within the same region (has same location-id) can be used. Otherwise an
59
+ # INVALID_ARGUMENT (400) error is returned.
60
+ # @param [Google::Apis::TranslateV3::DetectLanguageRequest] detect_language_request_object
61
+ # @param [String] fields
62
+ # Selector specifying which fields to include in a partial response.
63
+ # @param [String] quota_user
64
+ # Available to use for quota purposes for server-side applications. Can be any
65
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
66
+ # @param [Google::Apis::RequestOptions] options
67
+ # Request-specific options
68
+ #
69
+ # @yield [result, err] Result & error if block supplied
70
+ # @yieldparam result [Google::Apis::TranslateV3::DetectLanguageResponse] parsed result object
71
+ # @yieldparam err [StandardError] error object if request failed
72
+ #
73
+ # @return [Google::Apis::TranslateV3::DetectLanguageResponse]
74
+ #
75
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
76
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
77
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
78
+ def detect_project_language(parent, detect_language_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
79
+ command = make_simple_command(:post, 'v3/{+parent}:detectLanguage', options)
80
+ command.request_representation = Google::Apis::TranslateV3::DetectLanguageRequest::Representation
81
+ command.request_object = detect_language_request_object
82
+ command.response_representation = Google::Apis::TranslateV3::DetectLanguageResponse::Representation
83
+ command.response_class = Google::Apis::TranslateV3::DetectLanguageResponse
84
+ command.params['parent'] = parent unless parent.nil?
85
+ command.query['fields'] = fields unless fields.nil?
86
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
87
+ execute_or_queue_command(command, &block)
88
+ end
89
+
90
+ # Returns a list of supported languages for translation.
91
+ # @param [String] parent
92
+ # Required. Project or location to make a call. Must refer to a caller's project.
93
+ # Format: `projects/`project-number-or-id`` or `projects/`project-number-or-id`/
94
+ # locations/`location-id``. For global calls, use `projects/`project-number-or-
95
+ # id`/locations/global` or `projects/`project-number-or-id``. Non-global
96
+ # location is required for AutoML models. Only models within the same region (
97
+ # have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error
98
+ # is returned.
99
+ # @param [String] display_language_code
100
+ # Optional. The language to use to return localized, human readable names of
101
+ # supported languages. If missing, then display names are not returned in a
102
+ # response.
103
+ # @param [String] model
104
+ # Optional. Get supported languages of this model. The format depends on model
105
+ # type: - AutoML Translation models: `projects/`project-number-or-id`/locations/`
106
+ # location-id`/models/`model-id`` - General (built-in) models: `projects/`
107
+ # project-number-or-id`/locations/`location-id`/models/general/nmt`, `projects/`
108
+ # project-number-or-id`/locations/`location-id`/models/general/base` Returns
109
+ # languages supported by the specified model. If missing, we get supported
110
+ # languages of Google general base (PBMT) model.
111
+ # @param [String] fields
112
+ # Selector specifying which fields to include in a partial response.
113
+ # @param [String] quota_user
114
+ # Available to use for quota purposes for server-side applications. Can be any
115
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
116
+ # @param [Google::Apis::RequestOptions] options
117
+ # Request-specific options
118
+ #
119
+ # @yield [result, err] Result & error if block supplied
120
+ # @yieldparam result [Google::Apis::TranslateV3::SupportedLanguages] parsed result object
121
+ # @yieldparam err [StandardError] error object if request failed
122
+ #
123
+ # @return [Google::Apis::TranslateV3::SupportedLanguages]
124
+ #
125
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
126
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
127
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
128
+ def get_project_supported_languages(parent, display_language_code: nil, model: nil, fields: nil, quota_user: nil, options: nil, &block)
129
+ command = make_simple_command(:get, 'v3/{+parent}/supportedLanguages', options)
130
+ command.response_representation = Google::Apis::TranslateV3::SupportedLanguages::Representation
131
+ command.response_class = Google::Apis::TranslateV3::SupportedLanguages
132
+ command.params['parent'] = parent unless parent.nil?
133
+ command.query['displayLanguageCode'] = display_language_code unless display_language_code.nil?
134
+ command.query['model'] = model unless model.nil?
135
+ command.query['fields'] = fields unless fields.nil?
136
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
137
+ execute_or_queue_command(command, &block)
138
+ end
139
+
140
+ # Translates input text and returns translated text.
141
+ # @param [String] parent
142
+ # Required. Project or location to make a call. Must refer to a caller's project.
143
+ # Format: `projects/`project-number-or-id`` or `projects/`project-number-or-id`/
144
+ # locations/`location-id``. For global calls, use `projects/`project-number-or-
145
+ # id`/locations/global` or `projects/`project-number-or-id``. Non-global
146
+ # location is required for requests using AutoML models or custom glossaries.
147
+ # Models and glossaries must be within the same region (have same location-id),
148
+ # otherwise an INVALID_ARGUMENT (400) error is returned.
149
+ # @param [Google::Apis::TranslateV3::TranslateTextRequest] translate_text_request_object
150
+ # @param [String] fields
151
+ # Selector specifying which fields to include in a partial response.
152
+ # @param [String] quota_user
153
+ # Available to use for quota purposes for server-side applications. Can be any
154
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
155
+ # @param [Google::Apis::RequestOptions] options
156
+ # Request-specific options
157
+ #
158
+ # @yield [result, err] Result & error if block supplied
159
+ # @yieldparam result [Google::Apis::TranslateV3::TranslateTextResponse] parsed result object
160
+ # @yieldparam err [StandardError] error object if request failed
161
+ #
162
+ # @return [Google::Apis::TranslateV3::TranslateTextResponse]
163
+ #
164
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
165
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
166
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
167
+ def translate_project_text(parent, translate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
168
+ command = make_simple_command(:post, 'v3/{+parent}:translateText', options)
169
+ command.request_representation = Google::Apis::TranslateV3::TranslateTextRequest::Representation
170
+ command.request_object = translate_text_request_object
171
+ command.response_representation = Google::Apis::TranslateV3::TranslateTextResponse::Representation
172
+ command.response_class = Google::Apis::TranslateV3::TranslateTextResponse
173
+ command.params['parent'] = parent unless parent.nil?
174
+ command.query['fields'] = fields unless fields.nil?
175
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
176
+ execute_or_queue_command(command, &block)
177
+ end
178
+
179
+ # Translates a large volume of text in asynchronous batch mode. This function
180
+ # provides real-time output as the inputs are being processed. If caller cancels
181
+ # a request, the partial results (for an input file, it's all or nothing) may
182
+ # still be available on the specified output location. This call returns
183
+ # immediately and you can use google.longrunning.Operation.name to poll the
184
+ # status of the call.
185
+ # @param [String] parent
186
+ # Required. Location to make a call. Must refer to a caller's project. Format: `
187
+ # projects/`project-number-or-id`/locations/`location-id``. The `global`
188
+ # location is not supported for batch translation. Only AutoML Translation
189
+ # models or glossaries within the same region (have the same location-id) can be
190
+ # used, otherwise an INVALID_ARGUMENT (400) error is returned.
191
+ # @param [Google::Apis::TranslateV3::BatchTranslateTextRequest] batch_translate_text_request_object
192
+ # @param [String] fields
193
+ # Selector specifying which fields to include in a partial response.
194
+ # @param [String] quota_user
195
+ # Available to use for quota purposes for server-side applications. Can be any
196
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
197
+ # @param [Google::Apis::RequestOptions] options
198
+ # Request-specific options
199
+ #
200
+ # @yield [result, err] Result & error if block supplied
201
+ # @yieldparam result [Google::Apis::TranslateV3::Operation] parsed result object
202
+ # @yieldparam err [StandardError] error object if request failed
203
+ #
204
+ # @return [Google::Apis::TranslateV3::Operation]
205
+ #
206
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
207
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
208
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
209
+ def batch_location_translate_text(parent, batch_translate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
210
+ command = make_simple_command(:post, 'v3/{+parent}:batchTranslateText', options)
211
+ command.request_representation = Google::Apis::TranslateV3::BatchTranslateTextRequest::Representation
212
+ command.request_object = batch_translate_text_request_object
213
+ command.response_representation = Google::Apis::TranslateV3::Operation::Representation
214
+ command.response_class = Google::Apis::TranslateV3::Operation
215
+ command.params['parent'] = parent unless parent.nil?
216
+ command.query['fields'] = fields unless fields.nil?
217
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
218
+ execute_or_queue_command(command, &block)
219
+ end
220
+
221
+ # Detects the language of text within a request.
222
+ # @param [String] parent
223
+ # Required. Project or location to make a call. Must refer to a caller's project.
224
+ # Format: `projects/`project-number-or-id`/locations/`location-id`` or `
225
+ # projects/`project-number-or-id``. For global calls, use `projects/`project-
226
+ # number-or-id`/locations/global` or `projects/`project-number-or-id``. Only
227
+ # models within the same region (has same location-id) can be used. Otherwise an
228
+ # INVALID_ARGUMENT (400) error is returned.
229
+ # @param [Google::Apis::TranslateV3::DetectLanguageRequest] detect_language_request_object
230
+ # @param [String] fields
231
+ # Selector specifying which fields to include in a partial response.
232
+ # @param [String] quota_user
233
+ # Available to use for quota purposes for server-side applications. Can be any
234
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
235
+ # @param [Google::Apis::RequestOptions] options
236
+ # Request-specific options
237
+ #
238
+ # @yield [result, err] Result & error if block supplied
239
+ # @yieldparam result [Google::Apis::TranslateV3::DetectLanguageResponse] parsed result object
240
+ # @yieldparam err [StandardError] error object if request failed
241
+ #
242
+ # @return [Google::Apis::TranslateV3::DetectLanguageResponse]
243
+ #
244
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
245
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
246
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
247
+ def detect_location_language(parent, detect_language_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
248
+ command = make_simple_command(:post, 'v3/{+parent}:detectLanguage', options)
249
+ command.request_representation = Google::Apis::TranslateV3::DetectLanguageRequest::Representation
250
+ command.request_object = detect_language_request_object
251
+ command.response_representation = Google::Apis::TranslateV3::DetectLanguageResponse::Representation
252
+ command.response_class = Google::Apis::TranslateV3::DetectLanguageResponse
253
+ command.params['parent'] = parent unless parent.nil?
254
+ command.query['fields'] = fields unless fields.nil?
255
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
256
+ execute_or_queue_command(command, &block)
257
+ end
258
+
259
+ # Gets information about a location.
260
+ # @param [String] name
261
+ # Resource name for the location.
262
+ # @param [String] fields
263
+ # Selector specifying which fields to include in a partial response.
264
+ # @param [String] quota_user
265
+ # Available to use for quota purposes for server-side applications. Can be any
266
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
267
+ # @param [Google::Apis::RequestOptions] options
268
+ # Request-specific options
269
+ #
270
+ # @yield [result, err] Result & error if block supplied
271
+ # @yieldparam result [Google::Apis::TranslateV3::Location] parsed result object
272
+ # @yieldparam err [StandardError] error object if request failed
273
+ #
274
+ # @return [Google::Apis::TranslateV3::Location]
275
+ #
276
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
277
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
278
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
279
+ def get_project_location(name, fields: nil, quota_user: nil, options: nil, &block)
280
+ command = make_simple_command(:get, 'v3/{+name}', options)
281
+ command.response_representation = Google::Apis::TranslateV3::Location::Representation
282
+ command.response_class = Google::Apis::TranslateV3::Location
283
+ command.params['name'] = name unless name.nil?
284
+ command.query['fields'] = fields unless fields.nil?
285
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
286
+ execute_or_queue_command(command, &block)
287
+ end
288
+
289
+ # Returns a list of supported languages for translation.
290
+ # @param [String] parent
291
+ # Required. Project or location to make a call. Must refer to a caller's project.
292
+ # Format: `projects/`project-number-or-id`` or `projects/`project-number-or-id`/
293
+ # locations/`location-id``. For global calls, use `projects/`project-number-or-
294
+ # id`/locations/global` or `projects/`project-number-or-id``. Non-global
295
+ # location is required for AutoML models. Only models within the same region (
296
+ # have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error
297
+ # is returned.
298
+ # @param [String] display_language_code
299
+ # Optional. The language to use to return localized, human readable names of
300
+ # supported languages. If missing, then display names are not returned in a
301
+ # response.
302
+ # @param [String] model
303
+ # Optional. Get supported languages of this model. The format depends on model
304
+ # type: - AutoML Translation models: `projects/`project-number-or-id`/locations/`
305
+ # location-id`/models/`model-id`` - General (built-in) models: `projects/`
306
+ # project-number-or-id`/locations/`location-id`/models/general/nmt`, `projects/`
307
+ # project-number-or-id`/locations/`location-id`/models/general/base` Returns
308
+ # languages supported by the specified model. If missing, we get supported
309
+ # languages of Google general base (PBMT) model.
310
+ # @param [String] fields
311
+ # Selector specifying which fields to include in a partial response.
312
+ # @param [String] quota_user
313
+ # Available to use for quota purposes for server-side applications. Can be any
314
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
315
+ # @param [Google::Apis::RequestOptions] options
316
+ # Request-specific options
317
+ #
318
+ # @yield [result, err] Result & error if block supplied
319
+ # @yieldparam result [Google::Apis::TranslateV3::SupportedLanguages] parsed result object
320
+ # @yieldparam err [StandardError] error object if request failed
321
+ #
322
+ # @return [Google::Apis::TranslateV3::SupportedLanguages]
323
+ #
324
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
325
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
326
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
327
+ def get_project_location_supported_languages(parent, display_language_code: nil, model: nil, fields: nil, quota_user: nil, options: nil, &block)
328
+ command = make_simple_command(:get, 'v3/{+parent}/supportedLanguages', options)
329
+ command.response_representation = Google::Apis::TranslateV3::SupportedLanguages::Representation
330
+ command.response_class = Google::Apis::TranslateV3::SupportedLanguages
331
+ command.params['parent'] = parent unless parent.nil?
332
+ command.query['displayLanguageCode'] = display_language_code unless display_language_code.nil?
333
+ command.query['model'] = model unless model.nil?
334
+ command.query['fields'] = fields unless fields.nil?
335
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
336
+ execute_or_queue_command(command, &block)
337
+ end
338
+
339
+ # Lists information about the supported locations for this service.
340
+ # @param [String] name
341
+ # The resource that owns the locations collection, if applicable.
342
+ # @param [String] filter
343
+ # The standard list filter.
344
+ # @param [Fixnum] page_size
345
+ # The standard list page size.
346
+ # @param [String] page_token
347
+ # The standard list page token.
348
+ # @param [String] fields
349
+ # Selector specifying which fields to include in a partial response.
350
+ # @param [String] quota_user
351
+ # Available to use for quota purposes for server-side applications. Can be any
352
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
353
+ # @param [Google::Apis::RequestOptions] options
354
+ # Request-specific options
355
+ #
356
+ # @yield [result, err] Result & error if block supplied
357
+ # @yieldparam result [Google::Apis::TranslateV3::ListLocationsResponse] parsed result object
358
+ # @yieldparam err [StandardError] error object if request failed
359
+ #
360
+ # @return [Google::Apis::TranslateV3::ListLocationsResponse]
361
+ #
362
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
363
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
364
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
365
+ def list_project_locations(name, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
366
+ command = make_simple_command(:get, 'v3/{+name}/locations', options)
367
+ command.response_representation = Google::Apis::TranslateV3::ListLocationsResponse::Representation
368
+ command.response_class = Google::Apis::TranslateV3::ListLocationsResponse
369
+ command.params['name'] = name unless name.nil?
370
+ command.query['filter'] = filter unless filter.nil?
371
+ command.query['pageSize'] = page_size unless page_size.nil?
372
+ command.query['pageToken'] = page_token unless page_token.nil?
373
+ command.query['fields'] = fields unless fields.nil?
374
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
375
+ execute_or_queue_command(command, &block)
376
+ end
377
+
378
+ # Translates input text and returns translated text.
379
+ # @param [String] parent
380
+ # Required. Project or location to make a call. Must refer to a caller's project.
381
+ # Format: `projects/`project-number-or-id`` or `projects/`project-number-or-id`/
382
+ # locations/`location-id``. For global calls, use `projects/`project-number-or-
383
+ # id`/locations/global` or `projects/`project-number-or-id``. Non-global
384
+ # location is required for requests using AutoML models or custom glossaries.
385
+ # Models and glossaries must be within the same region (have same location-id),
386
+ # otherwise an INVALID_ARGUMENT (400) error is returned.
387
+ # @param [Google::Apis::TranslateV3::TranslateTextRequest] translate_text_request_object
388
+ # @param [String] fields
389
+ # Selector specifying which fields to include in a partial response.
390
+ # @param [String] quota_user
391
+ # Available to use for quota purposes for server-side applications. Can be any
392
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
393
+ # @param [Google::Apis::RequestOptions] options
394
+ # Request-specific options
395
+ #
396
+ # @yield [result, err] Result & error if block supplied
397
+ # @yieldparam result [Google::Apis::TranslateV3::TranslateTextResponse] parsed result object
398
+ # @yieldparam err [StandardError] error object if request failed
399
+ #
400
+ # @return [Google::Apis::TranslateV3::TranslateTextResponse]
401
+ #
402
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
403
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
404
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
405
+ def translate_location_text(parent, translate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
406
+ command = make_simple_command(:post, 'v3/{+parent}:translateText', options)
407
+ command.request_representation = Google::Apis::TranslateV3::TranslateTextRequest::Representation
408
+ command.request_object = translate_text_request_object
409
+ command.response_representation = Google::Apis::TranslateV3::TranslateTextResponse::Representation
410
+ command.response_class = Google::Apis::TranslateV3::TranslateTextResponse
411
+ command.params['parent'] = parent unless parent.nil?
412
+ command.query['fields'] = fields unless fields.nil?
413
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
414
+ execute_or_queue_command(command, &block)
415
+ end
416
+
417
+ # Creates a glossary and returns the long-running operation. Returns NOT_FOUND,
418
+ # if the project doesn't exist.
419
+ # @param [String] parent
420
+ # Required. The project name.
421
+ # @param [Google::Apis::TranslateV3::Glossary] glossary_object
422
+ # @param [String] fields
423
+ # Selector specifying which fields to include in a partial response.
424
+ # @param [String] quota_user
425
+ # Available to use for quota purposes for server-side applications. Can be any
426
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
427
+ # @param [Google::Apis::RequestOptions] options
428
+ # Request-specific options
429
+ #
430
+ # @yield [result, err] Result & error if block supplied
431
+ # @yieldparam result [Google::Apis::TranslateV3::Operation] parsed result object
432
+ # @yieldparam err [StandardError] error object if request failed
433
+ #
434
+ # @return [Google::Apis::TranslateV3::Operation]
435
+ #
436
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
437
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
438
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
439
+ def create_project_location_glossary(parent, glossary_object = nil, fields: nil, quota_user: nil, options: nil, &block)
440
+ command = make_simple_command(:post, 'v3/{+parent}/glossaries', options)
441
+ command.request_representation = Google::Apis::TranslateV3::Glossary::Representation
442
+ command.request_object = glossary_object
443
+ command.response_representation = Google::Apis::TranslateV3::Operation::Representation
444
+ command.response_class = Google::Apis::TranslateV3::Operation
445
+ command.params['parent'] = parent unless parent.nil?
446
+ command.query['fields'] = fields unless fields.nil?
447
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
448
+ execute_or_queue_command(command, &block)
449
+ end
450
+
451
+ # Deletes a glossary, or cancels glossary construction if the glossary isn't
452
+ # created yet. Returns NOT_FOUND, if the glossary doesn't exist.
453
+ # @param [String] name
454
+ # Required. The name of the glossary to delete.
455
+ # @param [String] fields
456
+ # Selector specifying which fields to include in a partial response.
457
+ # @param [String] quota_user
458
+ # Available to use for quota purposes for server-side applications. Can be any
459
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
460
+ # @param [Google::Apis::RequestOptions] options
461
+ # Request-specific options
462
+ #
463
+ # @yield [result, err] Result & error if block supplied
464
+ # @yieldparam result [Google::Apis::TranslateV3::Operation] parsed result object
465
+ # @yieldparam err [StandardError] error object if request failed
466
+ #
467
+ # @return [Google::Apis::TranslateV3::Operation]
468
+ #
469
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
470
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
471
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
472
+ def delete_project_location_glossary(name, fields: nil, quota_user: nil, options: nil, &block)
473
+ command = make_simple_command(:delete, 'v3/{+name}', options)
474
+ command.response_representation = Google::Apis::TranslateV3::Operation::Representation
475
+ command.response_class = Google::Apis::TranslateV3::Operation
476
+ command.params['name'] = name unless name.nil?
477
+ command.query['fields'] = fields unless fields.nil?
478
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
479
+ execute_or_queue_command(command, &block)
480
+ end
481
+
482
+ # Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
483
+ # @param [String] name
484
+ # Required. The name of the glossary to retrieve.
485
+ # @param [String] fields
486
+ # Selector specifying which fields to include in a partial response.
487
+ # @param [String] quota_user
488
+ # Available to use for quota purposes for server-side applications. Can be any
489
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
490
+ # @param [Google::Apis::RequestOptions] options
491
+ # Request-specific options
492
+ #
493
+ # @yield [result, err] Result & error if block supplied
494
+ # @yieldparam result [Google::Apis::TranslateV3::Glossary] parsed result object
495
+ # @yieldparam err [StandardError] error object if request failed
496
+ #
497
+ # @return [Google::Apis::TranslateV3::Glossary]
498
+ #
499
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
500
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
501
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
502
+ def get_project_location_glossary(name, fields: nil, quota_user: nil, options: nil, &block)
503
+ command = make_simple_command(:get, 'v3/{+name}', options)
504
+ command.response_representation = Google::Apis::TranslateV3::Glossary::Representation
505
+ command.response_class = Google::Apis::TranslateV3::Glossary
506
+ command.params['name'] = name unless name.nil?
507
+ command.query['fields'] = fields unless fields.nil?
508
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
509
+ execute_or_queue_command(command, &block)
510
+ end
511
+
512
+ # Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
513
+ # @param [String] parent
514
+ # Required. The name of the project from which to list all of the glossaries.
515
+ # @param [String] filter
516
+ # Optional. Filter specifying constraints of a list operation. Specify the
517
+ # constraint by the format of "key=value", where key must be "src" or "tgt", and
518
+ # the value must be a valid language code. For multiple restrictions,
519
+ # concatenate them by "AND" (uppercase only), such as: "src=en-US AND tgt=zh-CN".
520
+ # Notice that the exact match is used here, which means using 'en-US' and 'en'
521
+ # can lead to different results, which depends on the language code you used
522
+ # when you create the glossary. For the unidirectional glossaries, the "src" and
523
+ # "tgt" add restrictions on the source and target language code separately. For
524
+ # the equivalent term set glossaries, the "src" and/or "tgt" add restrictions on
525
+ # the term set. For example: "src=en-US AND tgt=zh-CN" will only pick the
526
+ # unidirectional glossaries which exactly match the source language code as "en-
527
+ # US" and the target language code "zh-CN", but all equivalent term set
528
+ # glossaries which contain "en-US" and "zh-CN" in their language set will be
529
+ # picked. If missing, no filtering is performed.
530
+ # @param [Fixnum] page_size
531
+ # Optional. Requested page size. The server may return fewer glossaries than
532
+ # requested. If unspecified, the server picks an appropriate default.
533
+ # @param [String] page_token
534
+ # Optional. A token identifying a page of results the server should return.
535
+ # Typically, this is the value of [ListGlossariesResponse.next_page_token]
536
+ # returned from the previous call to `ListGlossaries` method. The first page is
537
+ # returned if `page_token`is empty or missing.
538
+ # @param [String] fields
539
+ # Selector specifying which fields to include in a partial response.
540
+ # @param [String] quota_user
541
+ # Available to use for quota purposes for server-side applications. Can be any
542
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
543
+ # @param [Google::Apis::RequestOptions] options
544
+ # Request-specific options
545
+ #
546
+ # @yield [result, err] Result & error if block supplied
547
+ # @yieldparam result [Google::Apis::TranslateV3::ListGlossariesResponse] parsed result object
548
+ # @yieldparam err [StandardError] error object if request failed
549
+ #
550
+ # @return [Google::Apis::TranslateV3::ListGlossariesResponse]
551
+ #
552
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
553
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
554
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
555
+ def list_project_location_glossaries(parent, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
556
+ command = make_simple_command(:get, 'v3/{+parent}/glossaries', options)
557
+ command.response_representation = Google::Apis::TranslateV3::ListGlossariesResponse::Representation
558
+ command.response_class = Google::Apis::TranslateV3::ListGlossariesResponse
559
+ command.params['parent'] = parent unless parent.nil?
560
+ command.query['filter'] = filter unless filter.nil?
561
+ command.query['pageSize'] = page_size unless page_size.nil?
562
+ command.query['pageToken'] = page_token unless page_token.nil?
563
+ command.query['fields'] = fields unless fields.nil?
564
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
565
+ execute_or_queue_command(command, &block)
566
+ end
567
+
568
+ # Starts asynchronous cancellation on a long-running operation. The server makes
569
+ # a best effort to cancel the operation, but success is not guaranteed. If the
570
+ # server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
571
+ # Clients can use Operations.GetOperation or other methods to check whether the
572
+ # cancellation succeeded or whether the operation completed despite cancellation.
573
+ # On successful cancellation, the operation is not deleted; instead, it becomes
574
+ # an operation with an Operation.error value with a google.rpc.Status.code of 1,
575
+ # corresponding to `Code.CANCELLED`.
576
+ # @param [String] name
577
+ # The name of the operation resource to be cancelled.
578
+ # @param [Google::Apis::TranslateV3::CancelOperationRequest] cancel_operation_request_object
579
+ # @param [String] fields
580
+ # Selector specifying which fields to include in a partial response.
581
+ # @param [String] quota_user
582
+ # Available to use for quota purposes for server-side applications. Can be any
583
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
584
+ # @param [Google::Apis::RequestOptions] options
585
+ # Request-specific options
586
+ #
587
+ # @yield [result, err] Result & error if block supplied
588
+ # @yieldparam result [Google::Apis::TranslateV3::Empty] parsed result object
589
+ # @yieldparam err [StandardError] error object if request failed
590
+ #
591
+ # @return [Google::Apis::TranslateV3::Empty]
592
+ #
593
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
594
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
595
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
596
+ def cancel_operation(name, cancel_operation_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
597
+ command = make_simple_command(:post, 'v3/{+name}:cancel', options)
598
+ command.request_representation = Google::Apis::TranslateV3::CancelOperationRequest::Representation
599
+ command.request_object = cancel_operation_request_object
600
+ command.response_representation = Google::Apis::TranslateV3::Empty::Representation
601
+ command.response_class = Google::Apis::TranslateV3::Empty
602
+ command.params['name'] = name unless name.nil?
603
+ command.query['fields'] = fields unless fields.nil?
604
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
605
+ execute_or_queue_command(command, &block)
606
+ end
607
+
608
+ # Deletes a long-running operation. This method indicates that the client is no
609
+ # longer interested in the operation result. It does not cancel the operation.
610
+ # If the server doesn't support this method, it returns `google.rpc.Code.
611
+ # UNIMPLEMENTED`.
612
+ # @param [String] name
613
+ # The name of the operation resource to be deleted.
614
+ # @param [String] fields
615
+ # Selector specifying which fields to include in a partial response.
616
+ # @param [String] quota_user
617
+ # Available to use for quota purposes for server-side applications. Can be any
618
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
619
+ # @param [Google::Apis::RequestOptions] options
620
+ # Request-specific options
621
+ #
622
+ # @yield [result, err] Result & error if block supplied
623
+ # @yieldparam result [Google::Apis::TranslateV3::Empty] parsed result object
624
+ # @yieldparam err [StandardError] error object if request failed
625
+ #
626
+ # @return [Google::Apis::TranslateV3::Empty]
627
+ #
628
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
629
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
630
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
631
+ def delete_project_location_operation(name, fields: nil, quota_user: nil, options: nil, &block)
632
+ command = make_simple_command(:delete, 'v3/{+name}', options)
633
+ command.response_representation = Google::Apis::TranslateV3::Empty::Representation
634
+ command.response_class = Google::Apis::TranslateV3::Empty
635
+ command.params['name'] = name unless name.nil?
636
+ command.query['fields'] = fields unless fields.nil?
637
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
638
+ execute_or_queue_command(command, &block)
639
+ end
640
+
641
+ # Gets the latest state of a long-running operation. Clients can use this method
642
+ # to poll the operation result at intervals as recommended by the API service.
643
+ # @param [String] name
644
+ # The name of the operation resource.
645
+ # @param [String] fields
646
+ # Selector specifying which fields to include in a partial response.
647
+ # @param [String] quota_user
648
+ # Available to use for quota purposes for server-side applications. Can be any
649
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
650
+ # @param [Google::Apis::RequestOptions] options
651
+ # Request-specific options
652
+ #
653
+ # @yield [result, err] Result & error if block supplied
654
+ # @yieldparam result [Google::Apis::TranslateV3::Operation] parsed result object
655
+ # @yieldparam err [StandardError] error object if request failed
656
+ #
657
+ # @return [Google::Apis::TranslateV3::Operation]
658
+ #
659
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
660
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
661
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
662
+ def get_project_location_operation(name, fields: nil, quota_user: nil, options: nil, &block)
663
+ command = make_simple_command(:get, 'v3/{+name}', options)
664
+ command.response_representation = Google::Apis::TranslateV3::Operation::Representation
665
+ command.response_class = Google::Apis::TranslateV3::Operation
666
+ command.params['name'] = name unless name.nil?
667
+ command.query['fields'] = fields unless fields.nil?
668
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
669
+ execute_or_queue_command(command, &block)
670
+ end
671
+
672
+ # Lists operations that match the specified filter in the request. If the server
673
+ # doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name`
674
+ # binding allows API services to override the binding to use different resource
675
+ # name schemes, such as `users/*/operations`. To override the binding, API
676
+ # services can add a binding such as `"/v1/`name=users/*`/operations"` to their
677
+ # service configuration. For backwards compatibility, the default name includes
678
+ # the operations collection id, however overriding users must ensure the name
679
+ # binding is the parent resource, without the operations collection id.
680
+ # @param [String] name
681
+ # The name of the operation's parent resource.
682
+ # @param [String] filter
683
+ # The standard list filter.
684
+ # @param [Fixnum] page_size
685
+ # The standard list page size.
686
+ # @param [String] page_token
687
+ # The standard list page token.
688
+ # @param [String] fields
689
+ # Selector specifying which fields to include in a partial response.
690
+ # @param [String] quota_user
691
+ # Available to use for quota purposes for server-side applications. Can be any
692
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
693
+ # @param [Google::Apis::RequestOptions] options
694
+ # Request-specific options
695
+ #
696
+ # @yield [result, err] Result & error if block supplied
697
+ # @yieldparam result [Google::Apis::TranslateV3::ListOperationsResponse] parsed result object
698
+ # @yieldparam err [StandardError] error object if request failed
699
+ #
700
+ # @return [Google::Apis::TranslateV3::ListOperationsResponse]
701
+ #
702
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
703
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
704
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
705
+ def list_project_location_operations(name, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
706
+ command = make_simple_command(:get, 'v3/{+name}/operations', options)
707
+ command.response_representation = Google::Apis::TranslateV3::ListOperationsResponse::Representation
708
+ command.response_class = Google::Apis::TranslateV3::ListOperationsResponse
709
+ command.params['name'] = name unless name.nil?
710
+ command.query['filter'] = filter unless filter.nil?
711
+ command.query['pageSize'] = page_size unless page_size.nil?
712
+ command.query['pageToken'] = page_token unless page_token.nil?
713
+ command.query['fields'] = fields unless fields.nil?
714
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
715
+ execute_or_queue_command(command, &block)
716
+ end
717
+
718
+ # Waits for the specified long-running operation until it is done or reaches at
719
+ # most a specified timeout, returning the latest state. If the operation is
720
+ # already done, the latest state is immediately returned. If the timeout
721
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC timeout
722
+ # is used. If the server does not support this method, it returns `google.rpc.
723
+ # Code.UNIMPLEMENTED`. Note that this method is on a best-effort basis. It may
724
+ # return the latest state before the specified timeout (including immediately),
725
+ # meaning even an immediate response is no guarantee that the operation is done.
726
+ # @param [String] name
727
+ # The name of the operation resource to wait on.
728
+ # @param [Google::Apis::TranslateV3::WaitOperationRequest] wait_operation_request_object
729
+ # @param [String] fields
730
+ # Selector specifying which fields to include in a partial response.
731
+ # @param [String] quota_user
732
+ # Available to use for quota purposes for server-side applications. Can be any
733
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
734
+ # @param [Google::Apis::RequestOptions] options
735
+ # Request-specific options
736
+ #
737
+ # @yield [result, err] Result & error if block supplied
738
+ # @yieldparam result [Google::Apis::TranslateV3::Operation] parsed result object
739
+ # @yieldparam err [StandardError] error object if request failed
740
+ #
741
+ # @return [Google::Apis::TranslateV3::Operation]
742
+ #
743
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
744
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
745
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
746
+ def wait_operation(name, wait_operation_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
747
+ command = make_simple_command(:post, 'v3/{+name}:wait', options)
748
+ command.request_representation = Google::Apis::TranslateV3::WaitOperationRequest::Representation
749
+ command.request_object = wait_operation_request_object
750
+ command.response_representation = Google::Apis::TranslateV3::Operation::Representation
751
+ command.response_class = Google::Apis::TranslateV3::Operation
752
+ command.params['name'] = name unless name.nil?
753
+ command.query['fields'] = fields unless fields.nil?
754
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
755
+ execute_or_queue_command(command, &block)
756
+ end
757
+
758
+ protected
759
+
760
+ def apply_command_defaults(command)
761
+ command.query['key'] = key unless key.nil?
762
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
763
+ end
764
+ end
765
+ end
766
+ end
767
+ end