@googleapis/translate 1.0.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.
package/v2.ts ADDED
@@ -0,0 +1,798 @@
1
+ // Copyright 2020 Google LLC
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
15
+ /* eslint-disable @typescript-eslint/no-unused-vars */
16
+ /* eslint-disable @typescript-eslint/no-empty-interface */
17
+ /* eslint-disable @typescript-eslint/no-namespace */
18
+ /* eslint-disable no-irregular-whitespace */
19
+
20
+ import {
21
+ OAuth2Client,
22
+ JWT,
23
+ Compute,
24
+ UserRefreshClient,
25
+ BaseExternalAccountClient,
26
+ GaxiosPromise,
27
+ GoogleConfigurable,
28
+ createAPIRequest,
29
+ MethodOptions,
30
+ StreamMethodOptions,
31
+ GlobalOptions,
32
+ GoogleAuth,
33
+ BodyResponseCallback,
34
+ APIRequestContext,
35
+ } from 'googleapis-common';
36
+ import {Readable} from 'stream';
37
+
38
+ export namespace translate_v2 {
39
+ export interface Options extends GlobalOptions {
40
+ version: 'v2';
41
+ }
42
+
43
+ interface StandardParameters {
44
+ /**
45
+ * Auth client or API Key for the request
46
+ */
47
+ auth?:
48
+ | string
49
+ | OAuth2Client
50
+ | JWT
51
+ | Compute
52
+ | UserRefreshClient
53
+ | BaseExternalAccountClient
54
+ | GoogleAuth;
55
+
56
+ /**
57
+ * V1 error format.
58
+ */
59
+ '$.xgafv'?: string;
60
+ /**
61
+ * OAuth access token.
62
+ */
63
+ access_token?: string;
64
+ /**
65
+ * Data format for response.
66
+ */
67
+ alt?: string;
68
+ /**
69
+ * OAuth bearer token.
70
+ */
71
+ bearer_token?: string;
72
+ /**
73
+ * JSONP
74
+ */
75
+ callback?: string;
76
+ /**
77
+ * Selector specifying which fields to include in a partial response.
78
+ */
79
+ fields?: string;
80
+ /**
81
+ * API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
82
+ */
83
+ key?: string;
84
+ /**
85
+ * OAuth 2.0 token for the current user.
86
+ */
87
+ oauth_token?: string;
88
+ /**
89
+ * Pretty-print response.
90
+ */
91
+ pp?: boolean;
92
+ /**
93
+ * Returns response with indentations and line breaks.
94
+ */
95
+ prettyPrint?: boolean;
96
+ /**
97
+ * Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
98
+ */
99
+ quotaUser?: string;
100
+ /**
101
+ * Legacy upload protocol for media (e.g. "media", "multipart").
102
+ */
103
+ uploadType?: string;
104
+ /**
105
+ * Upload protocol for media (e.g. "raw", "multipart").
106
+ */
107
+ upload_protocol?: string;
108
+ }
109
+
110
+ /**
111
+ * Google Cloud Translation API
112
+ *
113
+ * The Google Cloud Translation API lets websites and programs integrate with
114
+ * Google Translate programmatically.
115
+ *
116
+ * @example
117
+ * ```js
118
+ * const {google} = require('googleapis');
119
+ * const translate = google.translate('v2');
120
+ * ```
121
+ */
122
+ export class Translate {
123
+ context: APIRequestContext;
124
+ detections: Resource$Detections;
125
+ languages: Resource$Languages;
126
+ translations: Resource$Translations;
127
+
128
+ constructor(options: GlobalOptions, google?: GoogleConfigurable) {
129
+ this.context = {
130
+ _options: options || {},
131
+ google,
132
+ };
133
+
134
+ this.detections = new Resource$Detections(this.context);
135
+ this.languages = new Resource$Languages(this.context);
136
+ this.translations = new Resource$Translations(this.context);
137
+ }
138
+ }
139
+
140
+ export interface Schema$DetectionsListResponse {
141
+ /**
142
+ * A detections contains detection results of several text
143
+ */
144
+ detections?: Schema$DetectionsResource[];
145
+ }
146
+ /**
147
+ * An array of languages which we detect for the given text The most likely language list first.
148
+ */
149
+ export interface Schema$DetectionsResource {}
150
+ /**
151
+ * The request message for language detection.
152
+ */
153
+ export interface Schema$DetectLanguageRequest {
154
+ /**
155
+ * The input text upon which to perform language detection. Repeat this
156
+ * parameter to perform language detection on multiple text inputs.
157
+ */
158
+ q?: string[] | null;
159
+ }
160
+ /**
161
+ * The request message for discovering supported languages.
162
+ */
163
+ export interface Schema$GetSupportedLanguagesRequest {
164
+ /**
165
+ * The language to use to return localized, human readable names of supported
166
+ * languages.
167
+ */
168
+ target?: string | null;
169
+ }
170
+ export interface Schema$LanguagesListResponse {
171
+ /**
172
+ * List of source/target languages supported by the translation API. If target parameter is unspecified, the list is sorted by the ASCII code point order of the language code. If target parameter is specified, the list is sorted by the collation order of the language name in the target language.
173
+ */
174
+ languages?: Schema$LanguagesResource[];
175
+ }
176
+ export interface Schema$LanguagesResource {
177
+ /**
178
+ * Supported language code, generally consisting of its ISO 639-1
179
+ * identifier. (E.g. 'en', 'ja'). In certain cases, BCP-47 codes including
180
+ * language + region identifiers are returned (e.g. 'zh-TW' and 'zh-CH')
181
+ */
182
+ language?: string | null;
183
+ /**
184
+ * Human readable name of the language localized to the target language.
185
+ */
186
+ name?: string | null;
187
+ }
188
+ /**
189
+ * The main translation request message for the Cloud Translation API.
190
+ */
191
+ export interface Schema$TranslateTextRequest {
192
+ /**
193
+ * The format of the source text, in either HTML (default) or plain-text. A
194
+ * value of "html" indicates HTML and a value of "text" indicates plain-text.
195
+ */
196
+ format?: string | null;
197
+ /**
198
+ * The `model` type requested for this translation. Valid values are
199
+ * listed in public documentation.
200
+ */
201
+ model?: string | null;
202
+ /**
203
+ * The input text to translate. Repeat this parameter to perform translation
204
+ * operations on multiple text inputs.
205
+ */
206
+ q?: string[] | null;
207
+ /**
208
+ * The language of the source text, set to one of the language codes listed in
209
+ * Language Support. If the source language is not specified, the API will
210
+ * attempt to identify the source language automatically and return it within
211
+ * the response.
212
+ */
213
+ source?: string | null;
214
+ /**
215
+ * The language to use for translation of the input text, set to one of the
216
+ * language codes listed in Language Support.
217
+ */
218
+ target?: string | null;
219
+ }
220
+ /**
221
+ * The main language translation response message.
222
+ */
223
+ export interface Schema$TranslationsListResponse {
224
+ /**
225
+ * Translations contains list of translation results of given text
226
+ */
227
+ translations?: Schema$TranslationsResource[];
228
+ }
229
+ export interface Schema$TranslationsResource {
230
+ /**
231
+ * The source language of the initial request, detected automatically, if
232
+ * no source language was passed within the initial request. If the
233
+ * source language was passed, auto-detection of the language will not
234
+ * occur and this field will be empty.
235
+ */
236
+ detectedSourceLanguage?: string | null;
237
+ /**
238
+ * The `model` type used for this translation. Valid values are
239
+ * listed in public documentation. Can be different from requested `model`.
240
+ * Present only if specific model type was explicitly requested.
241
+ */
242
+ model?: string | null;
243
+ /**
244
+ * Text translated into the target language.
245
+ */
246
+ translatedText?: string | null;
247
+ }
248
+
249
+ export class Resource$Detections {
250
+ context: APIRequestContext;
251
+ constructor(context: APIRequestContext) {
252
+ this.context = context;
253
+ }
254
+
255
+ /**
256
+ * Detects the language of text within a request.
257
+ *
258
+ * @param params - Parameters for request
259
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
260
+ * @param callback - Optional callback that handles the response.
261
+ * @returns A promise if used with async/await, or void if used with a callback.
262
+ */
263
+ detect(
264
+ params: Params$Resource$Detections$Detect,
265
+ options: StreamMethodOptions
266
+ ): GaxiosPromise<Readable>;
267
+ detect(
268
+ params?: Params$Resource$Detections$Detect,
269
+ options?: MethodOptions
270
+ ): GaxiosPromise<Schema$DetectionsListResponse>;
271
+ detect(
272
+ params: Params$Resource$Detections$Detect,
273
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
274
+ callback: BodyResponseCallback<Readable>
275
+ ): void;
276
+ detect(
277
+ params: Params$Resource$Detections$Detect,
278
+ options:
279
+ | MethodOptions
280
+ | BodyResponseCallback<Schema$DetectionsListResponse>,
281
+ callback: BodyResponseCallback<Schema$DetectionsListResponse>
282
+ ): void;
283
+ detect(
284
+ params: Params$Resource$Detections$Detect,
285
+ callback: BodyResponseCallback<Schema$DetectionsListResponse>
286
+ ): void;
287
+ detect(callback: BodyResponseCallback<Schema$DetectionsListResponse>): void;
288
+ detect(
289
+ paramsOrCallback?:
290
+ | Params$Resource$Detections$Detect
291
+ | BodyResponseCallback<Schema$DetectionsListResponse>
292
+ | BodyResponseCallback<Readable>,
293
+ optionsOrCallback?:
294
+ | MethodOptions
295
+ | StreamMethodOptions
296
+ | BodyResponseCallback<Schema$DetectionsListResponse>
297
+ | BodyResponseCallback<Readable>,
298
+ callback?:
299
+ | BodyResponseCallback<Schema$DetectionsListResponse>
300
+ | BodyResponseCallback<Readable>
301
+ ):
302
+ | void
303
+ | GaxiosPromise<Schema$DetectionsListResponse>
304
+ | GaxiosPromise<Readable> {
305
+ let params = (paramsOrCallback ||
306
+ {}) as Params$Resource$Detections$Detect;
307
+ let options = (optionsOrCallback || {}) as MethodOptions;
308
+
309
+ if (typeof paramsOrCallback === 'function') {
310
+ callback = paramsOrCallback;
311
+ params = {} as Params$Resource$Detections$Detect;
312
+ options = {};
313
+ }
314
+
315
+ if (typeof optionsOrCallback === 'function') {
316
+ callback = optionsOrCallback;
317
+ options = {};
318
+ }
319
+
320
+ const rootUrl = options.rootUrl || 'https://translation.googleapis.com/';
321
+ const parameters = {
322
+ options: Object.assign(
323
+ {
324
+ url: (rootUrl + '/language/translate/v2/detect').replace(
325
+ /([^:]\/)\/+/g,
326
+ '$1'
327
+ ),
328
+ method: 'POST',
329
+ },
330
+ options
331
+ ),
332
+ params,
333
+ requiredParams: [],
334
+ pathParams: [],
335
+ context: this.context,
336
+ };
337
+ if (callback) {
338
+ createAPIRequest<Schema$DetectionsListResponse>(
339
+ parameters,
340
+ callback as BodyResponseCallback<unknown>
341
+ );
342
+ } else {
343
+ return createAPIRequest<Schema$DetectionsListResponse>(parameters);
344
+ }
345
+ }
346
+
347
+ /**
348
+ * Detects the language of text within a request.
349
+ *
350
+ * @param params - Parameters for request
351
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
352
+ * @param callback - Optional callback that handles the response.
353
+ * @returns A promise if used with async/await, or void if used with a callback.
354
+ */
355
+ list(
356
+ params: Params$Resource$Detections$List,
357
+ options: StreamMethodOptions
358
+ ): GaxiosPromise<Readable>;
359
+ list(
360
+ params?: Params$Resource$Detections$List,
361
+ options?: MethodOptions
362
+ ): GaxiosPromise<Schema$DetectionsListResponse>;
363
+ list(
364
+ params: Params$Resource$Detections$List,
365
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
366
+ callback: BodyResponseCallback<Readable>
367
+ ): void;
368
+ list(
369
+ params: Params$Resource$Detections$List,
370
+ options:
371
+ | MethodOptions
372
+ | BodyResponseCallback<Schema$DetectionsListResponse>,
373
+ callback: BodyResponseCallback<Schema$DetectionsListResponse>
374
+ ): void;
375
+ list(
376
+ params: Params$Resource$Detections$List,
377
+ callback: BodyResponseCallback<Schema$DetectionsListResponse>
378
+ ): void;
379
+ list(callback: BodyResponseCallback<Schema$DetectionsListResponse>): void;
380
+ list(
381
+ paramsOrCallback?:
382
+ | Params$Resource$Detections$List
383
+ | BodyResponseCallback<Schema$DetectionsListResponse>
384
+ | BodyResponseCallback<Readable>,
385
+ optionsOrCallback?:
386
+ | MethodOptions
387
+ | StreamMethodOptions
388
+ | BodyResponseCallback<Schema$DetectionsListResponse>
389
+ | BodyResponseCallback<Readable>,
390
+ callback?:
391
+ | BodyResponseCallback<Schema$DetectionsListResponse>
392
+ | BodyResponseCallback<Readable>
393
+ ):
394
+ | void
395
+ | GaxiosPromise<Schema$DetectionsListResponse>
396
+ | GaxiosPromise<Readable> {
397
+ let params = (paramsOrCallback || {}) as Params$Resource$Detections$List;
398
+ let options = (optionsOrCallback || {}) as MethodOptions;
399
+
400
+ if (typeof paramsOrCallback === 'function') {
401
+ callback = paramsOrCallback;
402
+ params = {} as Params$Resource$Detections$List;
403
+ options = {};
404
+ }
405
+
406
+ if (typeof optionsOrCallback === 'function') {
407
+ callback = optionsOrCallback;
408
+ options = {};
409
+ }
410
+
411
+ const rootUrl = options.rootUrl || 'https://translation.googleapis.com/';
412
+ const parameters = {
413
+ options: Object.assign(
414
+ {
415
+ url: (rootUrl + '/language/translate/v2/detect').replace(
416
+ /([^:]\/)\/+/g,
417
+ '$1'
418
+ ),
419
+ method: 'GET',
420
+ },
421
+ options
422
+ ),
423
+ params,
424
+ requiredParams: ['q'],
425
+ pathParams: [],
426
+ context: this.context,
427
+ };
428
+ if (callback) {
429
+ createAPIRequest<Schema$DetectionsListResponse>(
430
+ parameters,
431
+ callback as BodyResponseCallback<unknown>
432
+ );
433
+ } else {
434
+ return createAPIRequest<Schema$DetectionsListResponse>(parameters);
435
+ }
436
+ }
437
+ }
438
+
439
+ export interface Params$Resource$Detections$Detect
440
+ extends StandardParameters {
441
+ /**
442
+ * Request body metadata
443
+ */
444
+ requestBody?: Schema$DetectLanguageRequest;
445
+ }
446
+ export interface Params$Resource$Detections$List extends StandardParameters {
447
+ /**
448
+ * The input text upon which to perform language detection. Repeat this
449
+ * parameter to perform language detection on multiple text inputs.
450
+ */
451
+ q?: string[];
452
+ }
453
+
454
+ export class Resource$Languages {
455
+ context: APIRequestContext;
456
+ constructor(context: APIRequestContext) {
457
+ this.context = context;
458
+ }
459
+
460
+ /**
461
+ * Returns a list of supported languages for translation.
462
+ *
463
+ * @param params - Parameters for request
464
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
465
+ * @param callback - Optional callback that handles the response.
466
+ * @returns A promise if used with async/await, or void if used with a callback.
467
+ */
468
+ list(
469
+ params: Params$Resource$Languages$List,
470
+ options: StreamMethodOptions
471
+ ): GaxiosPromise<Readable>;
472
+ list(
473
+ params?: Params$Resource$Languages$List,
474
+ options?: MethodOptions
475
+ ): GaxiosPromise<Schema$LanguagesListResponse>;
476
+ list(
477
+ params: Params$Resource$Languages$List,
478
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
479
+ callback: BodyResponseCallback<Readable>
480
+ ): void;
481
+ list(
482
+ params: Params$Resource$Languages$List,
483
+ options:
484
+ | MethodOptions
485
+ | BodyResponseCallback<Schema$LanguagesListResponse>,
486
+ callback: BodyResponseCallback<Schema$LanguagesListResponse>
487
+ ): void;
488
+ list(
489
+ params: Params$Resource$Languages$List,
490
+ callback: BodyResponseCallback<Schema$LanguagesListResponse>
491
+ ): void;
492
+ list(callback: BodyResponseCallback<Schema$LanguagesListResponse>): void;
493
+ list(
494
+ paramsOrCallback?:
495
+ | Params$Resource$Languages$List
496
+ | BodyResponseCallback<Schema$LanguagesListResponse>
497
+ | BodyResponseCallback<Readable>,
498
+ optionsOrCallback?:
499
+ | MethodOptions
500
+ | StreamMethodOptions
501
+ | BodyResponseCallback<Schema$LanguagesListResponse>
502
+ | BodyResponseCallback<Readable>,
503
+ callback?:
504
+ | BodyResponseCallback<Schema$LanguagesListResponse>
505
+ | BodyResponseCallback<Readable>
506
+ ):
507
+ | void
508
+ | GaxiosPromise<Schema$LanguagesListResponse>
509
+ | GaxiosPromise<Readable> {
510
+ let params = (paramsOrCallback || {}) as Params$Resource$Languages$List;
511
+ let options = (optionsOrCallback || {}) as MethodOptions;
512
+
513
+ if (typeof paramsOrCallback === 'function') {
514
+ callback = paramsOrCallback;
515
+ params = {} as Params$Resource$Languages$List;
516
+ options = {};
517
+ }
518
+
519
+ if (typeof optionsOrCallback === 'function') {
520
+ callback = optionsOrCallback;
521
+ options = {};
522
+ }
523
+
524
+ const rootUrl = options.rootUrl || 'https://translation.googleapis.com/';
525
+ const parameters = {
526
+ options: Object.assign(
527
+ {
528
+ url: (rootUrl + '/language/translate/v2/languages').replace(
529
+ /([^:]\/)\/+/g,
530
+ '$1'
531
+ ),
532
+ method: 'GET',
533
+ },
534
+ options
535
+ ),
536
+ params,
537
+ requiredParams: [],
538
+ pathParams: [],
539
+ context: this.context,
540
+ };
541
+ if (callback) {
542
+ createAPIRequest<Schema$LanguagesListResponse>(
543
+ parameters,
544
+ callback as BodyResponseCallback<unknown>
545
+ );
546
+ } else {
547
+ return createAPIRequest<Schema$LanguagesListResponse>(parameters);
548
+ }
549
+ }
550
+ }
551
+
552
+ export interface Params$Resource$Languages$List extends StandardParameters {
553
+ /**
554
+ * The model type for which supported languages should be returned.
555
+ */
556
+ model?: string;
557
+ /**
558
+ * The language to use to return localized, human readable names of supported
559
+ * languages.
560
+ */
561
+ target?: string;
562
+ }
563
+
564
+ export class Resource$Translations {
565
+ context: APIRequestContext;
566
+ constructor(context: APIRequestContext) {
567
+ this.context = context;
568
+ }
569
+
570
+ /**
571
+ * Translates input text, returning translated text.
572
+ *
573
+ * @param params - Parameters for request
574
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
575
+ * @param callback - Optional callback that handles the response.
576
+ * @returns A promise if used with async/await, or void if used with a callback.
577
+ */
578
+ list(
579
+ params: Params$Resource$Translations$List,
580
+ options: StreamMethodOptions
581
+ ): GaxiosPromise<Readable>;
582
+ list(
583
+ params?: Params$Resource$Translations$List,
584
+ options?: MethodOptions
585
+ ): GaxiosPromise<Schema$TranslationsListResponse>;
586
+ list(
587
+ params: Params$Resource$Translations$List,
588
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
589
+ callback: BodyResponseCallback<Readable>
590
+ ): void;
591
+ list(
592
+ params: Params$Resource$Translations$List,
593
+ options:
594
+ | MethodOptions
595
+ | BodyResponseCallback<Schema$TranslationsListResponse>,
596
+ callback: BodyResponseCallback<Schema$TranslationsListResponse>
597
+ ): void;
598
+ list(
599
+ params: Params$Resource$Translations$List,
600
+ callback: BodyResponseCallback<Schema$TranslationsListResponse>
601
+ ): void;
602
+ list(callback: BodyResponseCallback<Schema$TranslationsListResponse>): void;
603
+ list(
604
+ paramsOrCallback?:
605
+ | Params$Resource$Translations$List
606
+ | BodyResponseCallback<Schema$TranslationsListResponse>
607
+ | BodyResponseCallback<Readable>,
608
+ optionsOrCallback?:
609
+ | MethodOptions
610
+ | StreamMethodOptions
611
+ | BodyResponseCallback<Schema$TranslationsListResponse>
612
+ | BodyResponseCallback<Readable>,
613
+ callback?:
614
+ | BodyResponseCallback<Schema$TranslationsListResponse>
615
+ | BodyResponseCallback<Readable>
616
+ ):
617
+ | void
618
+ | GaxiosPromise<Schema$TranslationsListResponse>
619
+ | GaxiosPromise<Readable> {
620
+ let params = (paramsOrCallback ||
621
+ {}) as Params$Resource$Translations$List;
622
+ let options = (optionsOrCallback || {}) as MethodOptions;
623
+
624
+ if (typeof paramsOrCallback === 'function') {
625
+ callback = paramsOrCallback;
626
+ params = {} as Params$Resource$Translations$List;
627
+ options = {};
628
+ }
629
+
630
+ if (typeof optionsOrCallback === 'function') {
631
+ callback = optionsOrCallback;
632
+ options = {};
633
+ }
634
+
635
+ const rootUrl = options.rootUrl || 'https://translation.googleapis.com/';
636
+ const parameters = {
637
+ options: Object.assign(
638
+ {
639
+ url: (rootUrl + '/language/translate/v2').replace(
640
+ /([^:]\/)\/+/g,
641
+ '$1'
642
+ ),
643
+ method: 'GET',
644
+ },
645
+ options
646
+ ),
647
+ params,
648
+ requiredParams: ['q', 'target'],
649
+ pathParams: [],
650
+ context: this.context,
651
+ };
652
+ if (callback) {
653
+ createAPIRequest<Schema$TranslationsListResponse>(
654
+ parameters,
655
+ callback as BodyResponseCallback<unknown>
656
+ );
657
+ } else {
658
+ return createAPIRequest<Schema$TranslationsListResponse>(parameters);
659
+ }
660
+ }
661
+
662
+ /**
663
+ * Translates input text, returning translated text.
664
+ *
665
+ * @param params - Parameters for request
666
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
667
+ * @param callback - Optional callback that handles the response.
668
+ * @returns A promise if used with async/await, or void if used with a callback.
669
+ */
670
+ translate(
671
+ params: Params$Resource$Translations$Translate,
672
+ options: StreamMethodOptions
673
+ ): GaxiosPromise<Readable>;
674
+ translate(
675
+ params?: Params$Resource$Translations$Translate,
676
+ options?: MethodOptions
677
+ ): GaxiosPromise<Schema$TranslationsListResponse>;
678
+ translate(
679
+ params: Params$Resource$Translations$Translate,
680
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
681
+ callback: BodyResponseCallback<Readable>
682
+ ): void;
683
+ translate(
684
+ params: Params$Resource$Translations$Translate,
685
+ options:
686
+ | MethodOptions
687
+ | BodyResponseCallback<Schema$TranslationsListResponse>,
688
+ callback: BodyResponseCallback<Schema$TranslationsListResponse>
689
+ ): void;
690
+ translate(
691
+ params: Params$Resource$Translations$Translate,
692
+ callback: BodyResponseCallback<Schema$TranslationsListResponse>
693
+ ): void;
694
+ translate(
695
+ callback: BodyResponseCallback<Schema$TranslationsListResponse>
696
+ ): void;
697
+ translate(
698
+ paramsOrCallback?:
699
+ | Params$Resource$Translations$Translate
700
+ | BodyResponseCallback<Schema$TranslationsListResponse>
701
+ | BodyResponseCallback<Readable>,
702
+ optionsOrCallback?:
703
+ | MethodOptions
704
+ | StreamMethodOptions
705
+ | BodyResponseCallback<Schema$TranslationsListResponse>
706
+ | BodyResponseCallback<Readable>,
707
+ callback?:
708
+ | BodyResponseCallback<Schema$TranslationsListResponse>
709
+ | BodyResponseCallback<Readable>
710
+ ):
711
+ | void
712
+ | GaxiosPromise<Schema$TranslationsListResponse>
713
+ | GaxiosPromise<Readable> {
714
+ let params = (paramsOrCallback ||
715
+ {}) as Params$Resource$Translations$Translate;
716
+ let options = (optionsOrCallback || {}) as MethodOptions;
717
+
718
+ if (typeof paramsOrCallback === 'function') {
719
+ callback = paramsOrCallback;
720
+ params = {} as Params$Resource$Translations$Translate;
721
+ options = {};
722
+ }
723
+
724
+ if (typeof optionsOrCallback === 'function') {
725
+ callback = optionsOrCallback;
726
+ options = {};
727
+ }
728
+
729
+ const rootUrl = options.rootUrl || 'https://translation.googleapis.com/';
730
+ const parameters = {
731
+ options: Object.assign(
732
+ {
733
+ url: (rootUrl + '/language/translate/v2').replace(
734
+ /([^:]\/)\/+/g,
735
+ '$1'
736
+ ),
737
+ method: 'POST',
738
+ },
739
+ options
740
+ ),
741
+ params,
742
+ requiredParams: [],
743
+ pathParams: [],
744
+ context: this.context,
745
+ };
746
+ if (callback) {
747
+ createAPIRequest<Schema$TranslationsListResponse>(
748
+ parameters,
749
+ callback as BodyResponseCallback<unknown>
750
+ );
751
+ } else {
752
+ return createAPIRequest<Schema$TranslationsListResponse>(parameters);
753
+ }
754
+ }
755
+ }
756
+
757
+ export interface Params$Resource$Translations$List
758
+ extends StandardParameters {
759
+ /**
760
+ * The customization id for translate
761
+ */
762
+ cid?: string[];
763
+ /**
764
+ * The format of the source text, in either HTML (default) or plain-text. A
765
+ * value of "html" indicates HTML and a value of "text" indicates plain-text.
766
+ */
767
+ format?: string;
768
+ /**
769
+ * The `model` type requested for this translation. Valid values are
770
+ * listed in public documentation.
771
+ */
772
+ model?: string;
773
+ /**
774
+ * The input text to translate. Repeat this parameter to perform translation
775
+ * operations on multiple text inputs.
776
+ */
777
+ q?: string[];
778
+ /**
779
+ * The language of the source text, set to one of the language codes listed in
780
+ * Language Support. If the source language is not specified, the API will
781
+ * attempt to identify the source language automatically and return it within
782
+ * the response.
783
+ */
784
+ source?: string;
785
+ /**
786
+ * The language to use for translation of the input text, set to one of the
787
+ * language codes listed in Language Support.
788
+ */
789
+ target?: string;
790
+ }
791
+ export interface Params$Resource$Translations$Translate
792
+ extends StandardParameters {
793
+ /**
794
+ * Request body metadata
795
+ */
796
+ requestBody?: Schema$TranslateTextRequest;
797
+ }
798
+ }