OLD | NEW |
1 // This is a generated file (see the discoveryapis_generator project). | 1 // This is a generated file (see the discoveryapis_generator project). |
2 | 2 |
3 library googleapis.translate.v2; | 3 library googleapis.translate.v2; |
4 | 4 |
5 import 'dart:core' as core; | 5 import 'dart:core' as core; |
6 import 'dart:collection' as collection; | 6 import 'dart:collection' as collection; |
7 import 'dart:async' as async; | 7 import 'dart:async' as async; |
8 import 'dart:convert' as convert; | 8 import 'dart:convert' as convert; |
9 | 9 |
10 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; | 10 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; |
11 import 'package:http/http.dart' as http; | 11 import 'package:http/http.dart' as http; |
12 | 12 |
13 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show | 13 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show |
14 ApiRequestError, DetailedApiRequestError; | 14 ApiRequestError, DetailedApiRequestError; |
15 | 15 |
16 const core.String USER_AGENT = 'dart-api-client translate/v2'; | 16 const core.String USER_AGENT = 'dart-api-client translate/v2'; |
17 | 17 |
18 /** Translates text from one language to another. */ | 18 /** |
| 19 * The Google Cloud Translation API lets websites and programs integrate with |
| 20 * Google Translate programmatically. |
| 21 */ |
19 class TranslateApi { | 22 class TranslateApi { |
| 23 /** View and manage your data across Google Cloud Platform services */ |
| 24 static const CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platf
orm"; |
| 25 |
| 26 /** Translate text from one language to another using Google Translate */ |
| 27 static const CloudTranslationScope = "https://www.googleapis.com/auth/cloud-tr
anslation"; |
| 28 |
20 | 29 |
21 final commons.ApiRequester _requester; | 30 final commons.ApiRequester _requester; |
22 | 31 |
23 DetectionsResourceApi get detections => new DetectionsResourceApi(_requester); | 32 DetectionsResourceApi get detections => new DetectionsResourceApi(_requester); |
24 LanguagesResourceApi get languages => new LanguagesResourceApi(_requester); | 33 LanguagesResourceApi get languages => new LanguagesResourceApi(_requester); |
25 TranslationsResourceApi get translations => new TranslationsResourceApi(_reque
ster); | 34 TranslationsResourceApi get translations => new TranslationsResourceApi(_reque
ster); |
26 | 35 |
27 TranslateApi(http.Client client, {core.String rootUrl: "https://www.googleapis
.com/", core.String servicePath: "language/translate/"}) : | 36 TranslateApi(http.Client client, {core.String rootUrl: "https://translation.go
ogleapis.com/", core.String servicePath: "language/translate/"}) : |
28 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); | 37 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); |
29 } | 38 } |
30 | 39 |
31 | 40 |
32 class DetectionsResourceApi { | 41 class DetectionsResourceApi { |
33 final commons.ApiRequester _requester; | 42 final commons.ApiRequester _requester; |
34 | 43 |
35 DetectionsResourceApi(commons.ApiRequester client) : | 44 DetectionsResourceApi(commons.ApiRequester client) : |
36 _requester = client; | 45 _requester = client; |
37 | 46 |
38 /** | 47 /** |
39 * Detect the language of text. | 48 * Detects the language of text within a request. |
| 49 * |
| 50 * [request] - The metadata request object. |
40 * | 51 * |
41 * Request parameters: | 52 * Request parameters: |
42 * | 53 * |
43 * [q] - The text to detect | 54 * Completes with a [DetectionsListResponse]. |
| 55 * |
| 56 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 57 * error. |
| 58 * |
| 59 * If the used [http.Client] completes with an error when making a REST call, |
| 60 * this method will complete with the same error. |
| 61 */ |
| 62 async.Future<DetectionsListResponse> detect(DetectLanguageRequest request) { |
| 63 var _url = null; |
| 64 var _queryParams = new core.Map(); |
| 65 var _uploadMedia = null; |
| 66 var _uploadOptions = null; |
| 67 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 68 var _body = null; |
| 69 |
| 70 if (request != null) { |
| 71 _body = convert.JSON.encode((request).toJson()); |
| 72 } |
| 73 |
| 74 _url = 'v2/detect'; |
| 75 |
| 76 var _response = _requester.request(_url, |
| 77 "POST", |
| 78 body: _body, |
| 79 queryParams: _queryParams, |
| 80 uploadOptions: _uploadOptions, |
| 81 uploadMedia: _uploadMedia, |
| 82 downloadOptions: _downloadOptions); |
| 83 return _response.then((data) => new DetectionsListResponse.fromJson(data)); |
| 84 } |
| 85 |
| 86 /** |
| 87 * Detects the language of text within a request. |
| 88 * |
| 89 * Request parameters: |
| 90 * |
| 91 * [q] - The input text upon which to perform language detection. Repeat this |
| 92 * parameter to perform language detection on multiple text inputs. |
44 * | 93 * |
45 * Completes with a [DetectionsListResponse]. | 94 * Completes with a [DetectionsListResponse]. |
46 * | 95 * |
47 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | 96 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
48 * error. | 97 * error. |
49 * | 98 * |
50 * If the used [http.Client] completes with an error when making a REST call, | 99 * If the used [http.Client] completes with an error when making a REST call, |
51 * this method will complete with the same error. | 100 * this method will complete with the same error. |
52 */ | 101 */ |
53 async.Future<DetectionsListResponse> list(core.List<core.String> q) { | 102 async.Future<DetectionsListResponse> list(core.List<core.String> q) { |
(...skipping 24 matching lines...) Expand all Loading... |
78 } | 127 } |
79 | 128 |
80 | 129 |
81 class LanguagesResourceApi { | 130 class LanguagesResourceApi { |
82 final commons.ApiRequester _requester; | 131 final commons.ApiRequester _requester; |
83 | 132 |
84 LanguagesResourceApi(commons.ApiRequester client) : | 133 LanguagesResourceApi(commons.ApiRequester client) : |
85 _requester = client; | 134 _requester = client; |
86 | 135 |
87 /** | 136 /** |
88 * List the source/target languages supported by the API | 137 * Returns a list of supported languages for translation. |
89 * | 138 * |
90 * Request parameters: | 139 * Request parameters: |
91 * | 140 * |
92 * [target] - the language and collation in which the localized results should | 141 * [target] - The language to use to return localized, human readable names of |
93 * be returned | 142 * supported |
| 143 * languages. |
| 144 * |
| 145 * [model] - The model type for which supported languages should be returned. |
94 * | 146 * |
95 * Completes with a [LanguagesListResponse]. | 147 * Completes with a [LanguagesListResponse]. |
96 * | 148 * |
97 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | 149 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
98 * error. | 150 * error. |
99 * | 151 * |
100 * If the used [http.Client] completes with an error when making a REST call, | 152 * If the used [http.Client] completes with an error when making a REST call, |
101 * this method will complete with the same error. | 153 * this method will complete with the same error. |
102 */ | 154 */ |
103 async.Future<LanguagesListResponse> list({core.String target}) { | 155 async.Future<LanguagesListResponse> list({core.String target, core.String mode
l}) { |
104 var _url = null; | 156 var _url = null; |
105 var _queryParams = new core.Map(); | 157 var _queryParams = new core.Map(); |
106 var _uploadMedia = null; | 158 var _uploadMedia = null; |
107 var _uploadOptions = null; | 159 var _uploadOptions = null; |
108 var _downloadOptions = commons.DownloadOptions.Metadata; | 160 var _downloadOptions = commons.DownloadOptions.Metadata; |
109 var _body = null; | 161 var _body = null; |
110 | 162 |
111 if (target != null) { | 163 if (target != null) { |
112 _queryParams["target"] = [target]; | 164 _queryParams["target"] = [target]; |
113 } | 165 } |
| 166 if (model != null) { |
| 167 _queryParams["model"] = [model]; |
| 168 } |
114 | 169 |
115 _url = 'v2/languages'; | 170 _url = 'v2/languages'; |
116 | 171 |
117 var _response = _requester.request(_url, | 172 var _response = _requester.request(_url, |
118 "GET", | 173 "GET", |
119 body: _body, | 174 body: _body, |
120 queryParams: _queryParams, | 175 queryParams: _queryParams, |
121 uploadOptions: _uploadOptions, | 176 uploadOptions: _uploadOptions, |
122 uploadMedia: _uploadMedia, | 177 uploadMedia: _uploadMedia, |
123 downloadOptions: _downloadOptions); | 178 downloadOptions: _downloadOptions); |
124 return _response.then((data) => new LanguagesListResponse.fromJson(data)); | 179 return _response.then((data) => new LanguagesListResponse.fromJson(data)); |
125 } | 180 } |
126 | 181 |
127 } | 182 } |
128 | 183 |
129 | 184 |
130 class TranslationsResourceApi { | 185 class TranslationsResourceApi { |
131 final commons.ApiRequester _requester; | 186 final commons.ApiRequester _requester; |
132 | 187 |
133 TranslationsResourceApi(commons.ApiRequester client) : | 188 TranslationsResourceApi(commons.ApiRequester client) : |
134 _requester = client; | 189 _requester = client; |
135 | 190 |
136 /** | 191 /** |
137 * Returns text translations from one language to another. | 192 * Translates input text, returning translated text. |
138 * | 193 * |
139 * Request parameters: | 194 * Request parameters: |
140 * | 195 * |
141 * [q] - The text to translate | 196 * [q] - The input text to translate. Repeat this parameter to perform |
| 197 * translation |
| 198 * operations on multiple text inputs. |
142 * | 199 * |
143 * [target] - The target language into which the text should be translated | 200 * [target] - The language to use for translation of the input text, set to |
| 201 * one of the |
| 202 * language codes listed in Language Support. |
| 203 * |
| 204 * [source] - The language of the source text, set to one of the language |
| 205 * codes listed in |
| 206 * Language Support. If the source language is not specified, the API will |
| 207 * attempt to identify the source language automatically and return it within |
| 208 * the response. |
144 * | 209 * |
145 * [cid] - The customization id for translate | 210 * [cid] - The customization id for translate |
146 * | 211 * |
147 * [format] - The format of the text | 212 * [format] - The format of the source text, in either HTML (default) or |
| 213 * plain-text. A |
| 214 * value of "html" indicates HTML and a value of "text" indicates plain-text. |
148 * Possible string values are: | 215 * Possible string values are: |
149 * - "html" : Specifies the input is in HTML | 216 * - "html" : Specifies the input is in HTML |
150 * - "text" : Specifies the input is in plain textual format | 217 * - "text" : Specifies the input is in plain textual format |
151 * | 218 * |
152 * [source] - The source language of the text | 219 * [model] - The `model` type requested for this translation. Valid values are |
| 220 * listed in public documentation. |
153 * | 221 * |
154 * Completes with a [TranslationsListResponse]. | 222 * Completes with a [TranslationsListResponse]. |
155 * | 223 * |
156 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | 224 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
157 * error. | 225 * error. |
158 * | 226 * |
159 * If the used [http.Client] completes with an error when making a REST call, | 227 * If the used [http.Client] completes with an error when making a REST call, |
160 * this method will complete with the same error. | 228 * this method will complete with the same error. |
161 */ | 229 */ |
162 async.Future<TranslationsListResponse> list(core.List<core.String> q, core.Str
ing target, {core.List<core.String> cid, core.String format, core.String source}
) { | 230 async.Future<TranslationsListResponse> list(core.List<core.String> q, core.Str
ing target, {core.String source, core.List<core.String> cid, core.String format,
core.String model}) { |
163 var _url = null; | 231 var _url = null; |
164 var _queryParams = new core.Map(); | 232 var _queryParams = new core.Map(); |
165 var _uploadMedia = null; | 233 var _uploadMedia = null; |
166 var _uploadOptions = null; | 234 var _uploadOptions = null; |
167 var _downloadOptions = commons.DownloadOptions.Metadata; | 235 var _downloadOptions = commons.DownloadOptions.Metadata; |
168 var _body = null; | 236 var _body = null; |
169 | 237 |
170 if (q == null || q.isEmpty) { | 238 if (q == null || q.isEmpty) { |
171 throw new core.ArgumentError("Parameter q is required."); | 239 throw new core.ArgumentError("Parameter q is required."); |
172 } | 240 } |
173 _queryParams["q"] = q; | 241 _queryParams["q"] = q; |
174 if (target == null) { | 242 if (target == null) { |
175 throw new core.ArgumentError("Parameter target is required."); | 243 throw new core.ArgumentError("Parameter target is required."); |
176 } | 244 } |
177 _queryParams["target"] = [target]; | 245 _queryParams["target"] = [target]; |
| 246 if (source != null) { |
| 247 _queryParams["source"] = [source]; |
| 248 } |
178 if (cid != null) { | 249 if (cid != null) { |
179 _queryParams["cid"] = cid; | 250 _queryParams["cid"] = cid; |
180 } | 251 } |
181 if (format != null) { | 252 if (format != null) { |
182 _queryParams["format"] = [format]; | 253 _queryParams["format"] = [format]; |
183 } | 254 } |
184 if (source != null) { | 255 if (model != null) { |
185 _queryParams["source"] = [source]; | 256 _queryParams["model"] = [model]; |
186 } | 257 } |
187 | 258 |
188 _url = 'v2'; | 259 _url = 'v2'; |
189 | 260 |
190 var _response = _requester.request(_url, | 261 var _response = _requester.request(_url, |
191 "GET", | 262 "GET", |
192 body: _body, | 263 body: _body, |
193 queryParams: _queryParams, | 264 queryParams: _queryParams, |
194 uploadOptions: _uploadOptions, | 265 uploadOptions: _uploadOptions, |
195 uploadMedia: _uploadMedia, | 266 uploadMedia: _uploadMedia, |
196 downloadOptions: _downloadOptions); | 267 downloadOptions: _downloadOptions); |
197 return _response.then((data) => new TranslationsListResponse.fromJson(data))
; | 268 return _response.then((data) => new TranslationsListResponse.fromJson(data))
; |
198 } | 269 } |
199 | 270 |
| 271 /** |
| 272 * Translates input text, returning translated text. |
| 273 * |
| 274 * [request] - The metadata request object. |
| 275 * |
| 276 * Request parameters: |
| 277 * |
| 278 * Completes with a [TranslationsListResponse]. |
| 279 * |
| 280 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 281 * error. |
| 282 * |
| 283 * If the used [http.Client] completes with an error when making a REST call, |
| 284 * this method will complete with the same error. |
| 285 */ |
| 286 async.Future<TranslationsListResponse> translate(TranslateTextRequest request)
{ |
| 287 var _url = null; |
| 288 var _queryParams = new core.Map(); |
| 289 var _uploadMedia = null; |
| 290 var _uploadOptions = null; |
| 291 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 292 var _body = null; |
| 293 |
| 294 if (request != null) { |
| 295 _body = convert.JSON.encode((request).toJson()); |
| 296 } |
| 297 |
| 298 _url = 'v2'; |
| 299 |
| 300 var _response = _requester.request(_url, |
| 301 "POST", |
| 302 body: _body, |
| 303 queryParams: _queryParams, |
| 304 uploadOptions: _uploadOptions, |
| 305 uploadMedia: _uploadMedia, |
| 306 downloadOptions: _downloadOptions); |
| 307 return _response.then((data) => new TranslationsListResponse.fromJson(data))
; |
| 308 } |
| 309 |
200 } | 310 } |
201 | 311 |
202 | 312 |
203 | 313 |
| 314 /** The request message for language detection. */ |
| 315 class DetectLanguageRequest { |
| 316 /** |
| 317 * The input text upon which to perform language detection. Repeat this |
| 318 * parameter to perform language detection on multiple text inputs. |
| 319 */ |
| 320 core.List<core.String> q; |
| 321 |
| 322 DetectLanguageRequest(); |
| 323 |
| 324 DetectLanguageRequest.fromJson(core.Map _json) { |
| 325 if (_json.containsKey("q")) { |
| 326 q = _json["q"]; |
| 327 } |
| 328 } |
| 329 |
| 330 core.Map<core.String, core.Object> toJson() { |
| 331 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
| 332 if (q != null) { |
| 333 _json["q"] = q; |
| 334 } |
| 335 return _json; |
| 336 } |
| 337 } |
| 338 |
204 class DetectionsListResponse { | 339 class DetectionsListResponse { |
205 /** A detections contains detection results of several text */ | 340 /** A detections contains detection results of several text */ |
206 core.List<DetectionsResource> detections; | 341 core.List<DetectionsResource> detections; |
207 | 342 |
208 DetectionsListResponse(); | 343 DetectionsListResponse(); |
209 | 344 |
210 DetectionsListResponse.fromJson(core.Map _json) { | 345 DetectionsListResponse.fromJson(core.Map _json) { |
211 if (_json.containsKey("detections")) { | 346 if (_json.containsKey("detections")) { |
212 detections = _json["detections"].map((value) => new DetectionsResource.fro
mJson(value)).toList(); | 347 detections = _json["detections"].map((value) => new DetectionsResource.fro
mJson(value)).toList(); |
213 } | 348 } |
214 } | 349 } |
215 | 350 |
216 core.Map toJson() { | 351 core.Map<core.String, core.Object> toJson() { |
217 var _json = new core.Map(); | 352 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
218 if (detections != null) { | 353 if (detections != null) { |
219 _json["detections"] = detections.map((value) => (value).toJson()).toList()
; | 354 _json["detections"] = detections.map((value) => (value).toJson()).toList()
; |
220 } | 355 } |
221 return _json; | 356 return _json; |
222 } | 357 } |
223 } | 358 } |
224 | 359 |
225 class DetectionsResourceElement { | 360 class DetectionsResourceElement { |
226 /** The confidence of the detection resul of this language. */ | 361 /** The confidence of the detection result of this language. */ |
227 core.double confidence; | 362 core.double confidence; |
228 /** A boolean to indicate is the language detection result reliable. */ | 363 /** A boolean to indicate is the language detection result reliable. */ |
229 core.bool isReliable; | 364 core.bool isReliable; |
230 /** The language we detect */ | 365 /** The language we detected. */ |
231 core.String language; | 366 core.String language; |
232 | 367 |
233 DetectionsResourceElement(); | 368 DetectionsResourceElement(); |
234 | 369 |
235 DetectionsResourceElement.fromJson(core.Map _json) { | 370 DetectionsResourceElement.fromJson(core.Map _json) { |
236 if (_json.containsKey("confidence")) { | 371 if (_json.containsKey("confidence")) { |
237 confidence = _json["confidence"]; | 372 confidence = _json["confidence"]; |
238 } | 373 } |
239 if (_json.containsKey("isReliable")) { | 374 if (_json.containsKey("isReliable")) { |
240 isReliable = _json["isReliable"]; | 375 isReliable = _json["isReliable"]; |
241 } | 376 } |
242 if (_json.containsKey("language")) { | 377 if (_json.containsKey("language")) { |
243 language = _json["language"]; | 378 language = _json["language"]; |
244 } | 379 } |
245 } | 380 } |
246 | 381 |
247 core.Map toJson() { | 382 core.Map<core.String, core.Object> toJson() { |
248 var _json = new core.Map(); | 383 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
249 if (confidence != null) { | 384 if (confidence != null) { |
250 _json["confidence"] = confidence; | 385 _json["confidence"] = confidence; |
251 } | 386 } |
252 if (isReliable != null) { | 387 if (isReliable != null) { |
253 _json["isReliable"] = isReliable; | 388 _json["isReliable"] = isReliable; |
254 } | 389 } |
255 if (language != null) { | 390 if (language != null) { |
256 _json["language"] = language; | 391 _json["language"] = language; |
257 } | 392 } |
258 return _json; | 393 return _json; |
259 } | 394 } |
260 } | 395 } |
261 | 396 |
262 /** | 397 /** |
263 * An array of languages which we detect for the given text The most likely | 398 * An array of languages which we detect for the given text The most likely |
264 * language list first. | 399 * language list first. |
265 */ | 400 */ |
266 class DetectionsResource | 401 class DetectionsResource |
267 extends collection.ListBase<DetectionsResourceElement> { | 402 extends collection.ListBase<DetectionsResourceElement> { |
268 final core.List<DetectionsResourceElement> _inner; | 403 final core.List<DetectionsResourceElement> _inner; |
269 | 404 |
270 DetectionsResource() : _inner = []; | 405 DetectionsResource() : _inner = []; |
271 | 406 |
272 DetectionsResource.fromJson(core.List json) | 407 DetectionsResource.fromJson(core.List json) |
273 : _inner = json.map((value) => new DetectionsResourceElement.fromJson(valu
e)).toList(); | 408 : _inner = json.map((value) => new DetectionsResourceElement.fromJson(valu
e)).toList(); |
274 | 409 |
275 core.List toJson() { | 410 core.List<core.Map<core.String, core.Object>> toJson() { |
276 return _inner.map((value) => (value).toJson()).toList(); | 411 return _inner.map((value) => (value).toJson()).toList(); |
277 } | 412 } |
278 | 413 |
279 DetectionsResourceElement operator [](core.int key) => _inner[key]; | 414 DetectionsResourceElement operator [](core.int key) => _inner[key]; |
280 | 415 |
281 void operator []=(core.int key, DetectionsResourceElement value) { | 416 void operator []=(core.int key, DetectionsResourceElement value) { |
282 _inner[key] = value; | 417 _inner[key] = value; |
283 } | 418 } |
284 | 419 |
285 core.int get length => _inner.length; | 420 core.int get length => _inner.length; |
286 | 421 |
287 void set length(core.int newLength) { | 422 void set length(core.int newLength) { |
288 _inner.length = newLength; | 423 _inner.length = newLength; |
289 } | 424 } |
290 } | 425 } |
291 | 426 |
| 427 /** The request message for discovering supported languages. */ |
| 428 class GetSupportedLanguagesRequest { |
| 429 /** |
| 430 * The language to use to return localized, human readable names of supported |
| 431 * languages. |
| 432 */ |
| 433 core.String target; |
| 434 |
| 435 GetSupportedLanguagesRequest(); |
| 436 |
| 437 GetSupportedLanguagesRequest.fromJson(core.Map _json) { |
| 438 if (_json.containsKey("target")) { |
| 439 target = _json["target"]; |
| 440 } |
| 441 } |
| 442 |
| 443 core.Map<core.String, core.Object> toJson() { |
| 444 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
| 445 if (target != null) { |
| 446 _json["target"] = target; |
| 447 } |
| 448 return _json; |
| 449 } |
| 450 } |
| 451 |
292 class LanguagesListResponse { | 452 class LanguagesListResponse { |
293 /** | 453 /** |
294 * List of source/target languages supported by the translation API. If target | 454 * List of source/target languages supported by the translation API. If target |
295 * parameter is unspecified, the list is sorted by the ASCII code point order | 455 * parameter is unspecified, the list is sorted by the ASCII code point order |
296 * of the language code. If target parameter is specified, the list is sorted | 456 * of the language code. If target parameter is specified, the list is sorted |
297 * by the collation order of the language name in the target language. | 457 * by the collation order of the language name in the target language. |
298 */ | 458 */ |
299 core.List<LanguagesResource> languages; | 459 core.List<LanguagesResource> languages; |
300 | 460 |
301 LanguagesListResponse(); | 461 LanguagesListResponse(); |
302 | 462 |
303 LanguagesListResponse.fromJson(core.Map _json) { | 463 LanguagesListResponse.fromJson(core.Map _json) { |
304 if (_json.containsKey("languages")) { | 464 if (_json.containsKey("languages")) { |
305 languages = _json["languages"].map((value) => new LanguagesResource.fromJs
on(value)).toList(); | 465 languages = _json["languages"].map((value) => new LanguagesResource.fromJs
on(value)).toList(); |
306 } | 466 } |
307 } | 467 } |
308 | 468 |
309 core.Map toJson() { | 469 core.Map<core.String, core.Object> toJson() { |
310 var _json = new core.Map(); | 470 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
311 if (languages != null) { | 471 if (languages != null) { |
312 _json["languages"] = languages.map((value) => (value).toJson()).toList(); | 472 _json["languages"] = languages.map((value) => (value).toJson()).toList(); |
313 } | 473 } |
314 return _json; | 474 return _json; |
315 } | 475 } |
316 } | 476 } |
317 | 477 |
318 class LanguagesResource { | 478 class LanguagesResource { |
319 /** The language code. */ | 479 /** |
| 480 * Supported language code, generally consisting of its ISO 639-1 |
| 481 * identifier. (E.g. 'en', 'ja'). In certain cases, BCP-47 codes including |
| 482 * language + region identifiers are returned (e.g. 'zh-TW' and 'zh-CH') |
| 483 */ |
320 core.String language; | 484 core.String language; |
321 /** The localized name of the language if target parameter is given. */ | 485 /** Human readable name of the language localized to the target language. */ |
322 core.String name; | 486 core.String name; |
323 | 487 |
324 LanguagesResource(); | 488 LanguagesResource(); |
325 | 489 |
326 LanguagesResource.fromJson(core.Map _json) { | 490 LanguagesResource.fromJson(core.Map _json) { |
327 if (_json.containsKey("language")) { | 491 if (_json.containsKey("language")) { |
328 language = _json["language"]; | 492 language = _json["language"]; |
329 } | 493 } |
330 if (_json.containsKey("name")) { | 494 if (_json.containsKey("name")) { |
331 name = _json["name"]; | 495 name = _json["name"]; |
332 } | 496 } |
333 } | 497 } |
334 | 498 |
335 core.Map toJson() { | 499 core.Map<core.String, core.Object> toJson() { |
336 var _json = new core.Map(); | 500 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
337 if (language != null) { | 501 if (language != null) { |
338 _json["language"] = language; | 502 _json["language"] = language; |
339 } | 503 } |
340 if (name != null) { | 504 if (name != null) { |
341 _json["name"] = name; | 505 _json["name"] = name; |
342 } | 506 } |
343 return _json; | 507 return _json; |
344 } | 508 } |
345 } | 509 } |
346 | 510 |
| 511 /** The main translation request message for the Cloud Translation API. */ |
| 512 class TranslateTextRequest { |
| 513 /** |
| 514 * The format of the source text, in either HTML (default) or plain-text. A |
| 515 * value of "html" indicates HTML and a value of "text" indicates plain-text. |
| 516 */ |
| 517 core.String format; |
| 518 /** |
| 519 * The `model` type requested for this translation. Valid values are |
| 520 * listed in public documentation. |
| 521 */ |
| 522 core.String model; |
| 523 /** |
| 524 * The input text to translate. Repeat this parameter to perform translation |
| 525 * operations on multiple text inputs. |
| 526 */ |
| 527 core.List<core.String> q; |
| 528 /** |
| 529 * The language of the source text, set to one of the language codes listed in |
| 530 * Language Support. If the source language is not specified, the API will |
| 531 * attempt to identify the source language automatically and return it within |
| 532 * the response. |
| 533 */ |
| 534 core.String source; |
| 535 /** |
| 536 * The language to use for translation of the input text, set to one of the |
| 537 * language codes listed in Language Support. |
| 538 */ |
| 539 core.String target; |
| 540 |
| 541 TranslateTextRequest(); |
| 542 |
| 543 TranslateTextRequest.fromJson(core.Map _json) { |
| 544 if (_json.containsKey("format")) { |
| 545 format = _json["format"]; |
| 546 } |
| 547 if (_json.containsKey("model")) { |
| 548 model = _json["model"]; |
| 549 } |
| 550 if (_json.containsKey("q")) { |
| 551 q = _json["q"]; |
| 552 } |
| 553 if (_json.containsKey("source")) { |
| 554 source = _json["source"]; |
| 555 } |
| 556 if (_json.containsKey("target")) { |
| 557 target = _json["target"]; |
| 558 } |
| 559 } |
| 560 |
| 561 core.Map<core.String, core.Object> toJson() { |
| 562 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
| 563 if (format != null) { |
| 564 _json["format"] = format; |
| 565 } |
| 566 if (model != null) { |
| 567 _json["model"] = model; |
| 568 } |
| 569 if (q != null) { |
| 570 _json["q"] = q; |
| 571 } |
| 572 if (source != null) { |
| 573 _json["source"] = source; |
| 574 } |
| 575 if (target != null) { |
| 576 _json["target"] = target; |
| 577 } |
| 578 return _json; |
| 579 } |
| 580 } |
| 581 |
| 582 /** The main language translation response message. */ |
347 class TranslationsListResponse { | 583 class TranslationsListResponse { |
348 /** Translations contains list of translation results of given text */ | 584 /** Translations contains list of translation results of given text */ |
349 core.List<TranslationsResource> translations; | 585 core.List<TranslationsResource> translations; |
350 | 586 |
351 TranslationsListResponse(); | 587 TranslationsListResponse(); |
352 | 588 |
353 TranslationsListResponse.fromJson(core.Map _json) { | 589 TranslationsListResponse.fromJson(core.Map _json) { |
354 if (_json.containsKey("translations")) { | 590 if (_json.containsKey("translations")) { |
355 translations = _json["translations"].map((value) => new TranslationsResour
ce.fromJson(value)).toList(); | 591 translations = _json["translations"].map((value) => new TranslationsResour
ce.fromJson(value)).toList(); |
356 } | 592 } |
357 } | 593 } |
358 | 594 |
359 core.Map toJson() { | 595 core.Map<core.String, core.Object> toJson() { |
360 var _json = new core.Map(); | 596 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
361 if (translations != null) { | 597 if (translations != null) { |
362 _json["translations"] = translations.map((value) => (value).toJson()).toLi
st(); | 598 _json["translations"] = translations.map((value) => (value).toJson()).toLi
st(); |
363 } | 599 } |
364 return _json; | 600 return _json; |
365 } | 601 } |
366 } | 602 } |
367 | 603 |
368 class TranslationsResource { | 604 class TranslationsResource { |
369 /** Detected source language if source parameter is unspecified. */ | 605 /** |
| 606 * The source language of the initial request, detected automatically, if |
| 607 * no source language was passed within the initial request. If the |
| 608 * source language was passed, auto-detection of the language will not |
| 609 * occur and this field will be empty. |
| 610 */ |
370 core.String detectedSourceLanguage; | 611 core.String detectedSourceLanguage; |
371 /** The translation. */ | 612 /** |
| 613 * The `model` type used for this translation. Valid values are |
| 614 * listed in public documentation. Can be different from requested `model`. |
| 615 * Present only if specific model type was explicitly requested. |
| 616 */ |
| 617 core.String model; |
| 618 /** Text translated into the target language. */ |
372 core.String translatedText; | 619 core.String translatedText; |
373 | 620 |
374 TranslationsResource(); | 621 TranslationsResource(); |
375 | 622 |
376 TranslationsResource.fromJson(core.Map _json) { | 623 TranslationsResource.fromJson(core.Map _json) { |
377 if (_json.containsKey("detectedSourceLanguage")) { | 624 if (_json.containsKey("detectedSourceLanguage")) { |
378 detectedSourceLanguage = _json["detectedSourceLanguage"]; | 625 detectedSourceLanguage = _json["detectedSourceLanguage"]; |
379 } | 626 } |
| 627 if (_json.containsKey("model")) { |
| 628 model = _json["model"]; |
| 629 } |
380 if (_json.containsKey("translatedText")) { | 630 if (_json.containsKey("translatedText")) { |
381 translatedText = _json["translatedText"]; | 631 translatedText = _json["translatedText"]; |
382 } | 632 } |
383 } | 633 } |
384 | 634 |
385 core.Map toJson() { | 635 core.Map<core.String, core.Object> toJson() { |
386 var _json = new core.Map(); | 636 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); |
387 if (detectedSourceLanguage != null) { | 637 if (detectedSourceLanguage != null) { |
388 _json["detectedSourceLanguage"] = detectedSourceLanguage; | 638 _json["detectedSourceLanguage"] = detectedSourceLanguage; |
389 } | 639 } |
| 640 if (model != null) { |
| 641 _json["model"] = model; |
| 642 } |
390 if (translatedText != null) { | 643 if (translatedText != null) { |
391 _json["translatedText"] = translatedText; | 644 _json["translatedText"] = translatedText; |
392 } | 645 } |
393 return _json; | 646 return _json; |
394 } | 647 } |
395 } | 648 } |
OLD | NEW |