From 1a9064602582090468e9371ddfe830bd32dad566 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 23 Aug 2022 00:10:19 +0000 Subject: [PATCH] fix: better support for fallback mode (#809) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 468790263 Source-Link: https://github.com/googleapis/googleapis/commit/873ab456273d105245df0fb82a6c17a814553b80 Source-Link: https://github.com/googleapis/googleapis-gen/commit/cb6f37aeff2a3472e40a7bbace8c67d75e24bee5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2I2ZjM3YWVmZjJhMzQ3MmU0MGE3YmJhY2U4YzY3ZDc1ZTI0YmVlNSJ9 --- ..._metadata.google.cloud.translation.v3.json | 20 +- ...lation_service.batch_translate_document.js | 3 + ...ranslation_service.batch_translate_text.js | 3 + .../v3/translation_service.create_glossary.js | 3 + .../v3/translation_service.delete_glossary.js | 3 + .../v3/translation_service.detect_language.js | 3 + .../v3/translation_service.get_glossary.js | 3 + ...slation_service.get_supported_languages.js | 3 + .../v3/translation_service.list_glossaries.js | 3 + .../translation_service.translate_document.js | 3 + .../v3/translation_service.translate_text.js | 3 + ...data.google.cloud.translation.v3beta1.json | 20 +- ...lation_service.batch_translate_document.js | 3 + ...ranslation_service.batch_translate_text.js | 3 + .../translation_service.create_glossary.js | 3 + .../translation_service.delete_glossary.js | 3 + .../translation_service.detect_language.js | 3 + .../translation_service.get_glossary.js | 3 + ...slation_service.get_supported_languages.js | 3 + .../translation_service.list_glossaries.js | 3 + .../translation_service.translate_document.js | 3 + .../translation_service.translate_text.js | 3 + src/v3/translation_service_client.ts | 16 +- src/v3beta1/translation_service_client.ts | 16 +- test/gapic_translation_service_v3.ts | 160 ++++++++-------- test/gapic_translation_service_v3beta1.ts | 177 +++++++++--------- 26 files changed, 267 insertions(+), 202 deletions(-) diff --git a/samples/generated/v3/snippet_metadata.google.cloud.translation.v3.json b/samples/generated/v3/snippet_metadata.google.cloud.translation.v3.json index f157d735..6269b910 100644 --- a/samples/generated/v3/snippet_metadata.google.cloud.translation.v3.json +++ b/samples/generated/v3/snippet_metadata.google.cloud.translation.v3.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 115, + "end": 118, "type": "FULL" } ], @@ -90,7 +90,7 @@ "segments": [ { "start": 25, - "end": 85, + "end": 88, "type": "FULL" } ], @@ -146,7 +146,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 78, "type": "FULL" } ], @@ -194,7 +194,7 @@ "segments": [ { "start": 25, - "end": 112, + "end": 115, "type": "FULL" } ], @@ -262,7 +262,7 @@ "segments": [ { "start": 25, - "end": 109, + "end": 112, "type": "FULL" } ], @@ -330,7 +330,7 @@ "segments": [ { "start": 25, - "end": 112, + "end": 115, "type": "FULL" } ], @@ -398,7 +398,7 @@ "segments": [ { "start": 25, - "end": 56, + "end": 59, "type": "FULL" } ], @@ -442,7 +442,7 @@ "segments": [ { "start": 25, - "end": 83, + "end": 86, "type": "FULL" } ], @@ -494,7 +494,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -534,7 +534,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], diff --git a/samples/generated/v3/translation_service.batch_translate_document.js b/samples/generated/v3/translation_service.batch_translate_document.js index 337493ac..eb48f979 100644 --- a/samples/generated/v3/translation_service.batch_translate_document.js +++ b/samples/generated/v3/translation_service.batch_translate_document.js @@ -23,6 +23,9 @@ function main(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) { // [START translate_v3_generated_TranslationService_BatchTranslateDocument_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.batch_translate_text.js b/samples/generated/v3/translation_service.batch_translate_text.js index 71e72d34..6e6352ff 100644 --- a/samples/generated/v3/translation_service.batch_translate_text.js +++ b/samples/generated/v3/translation_service.batch_translate_text.js @@ -23,6 +23,9 @@ function main(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) { // [START translate_v3_generated_TranslationService_BatchTranslateText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.create_glossary.js b/samples/generated/v3/translation_service.create_glossary.js index 12f19003..6851f996 100644 --- a/samples/generated/v3/translation_service.create_glossary.js +++ b/samples/generated/v3/translation_service.create_glossary.js @@ -23,6 +23,9 @@ function main(parent, glossary) { // [START translate_v3_generated_TranslationService_CreateGlossary_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.delete_glossary.js b/samples/generated/v3/translation_service.delete_glossary.js index 10f634d3..3f73f2c4 100644 --- a/samples/generated/v3/translation_service.delete_glossary.js +++ b/samples/generated/v3/translation_service.delete_glossary.js @@ -23,6 +23,9 @@ function main(name) { // [START translate_v3_generated_TranslationService_DeleteGlossary_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.detect_language.js b/samples/generated/v3/translation_service.detect_language.js index 37287108..265776c2 100644 --- a/samples/generated/v3/translation_service.detect_language.js +++ b/samples/generated/v3/translation_service.detect_language.js @@ -23,6 +23,9 @@ function main(parent) { // [START translate_v3_generated_TranslationService_DetectLanguage_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.get_glossary.js b/samples/generated/v3/translation_service.get_glossary.js index ed5d7b43..3b715e01 100644 --- a/samples/generated/v3/translation_service.get_glossary.js +++ b/samples/generated/v3/translation_service.get_glossary.js @@ -23,6 +23,9 @@ function main(name) { // [START translate_v3_generated_TranslationService_GetGlossary_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.get_supported_languages.js b/samples/generated/v3/translation_service.get_supported_languages.js index 0a498bea..bcc8e78f 100644 --- a/samples/generated/v3/translation_service.get_supported_languages.js +++ b/samples/generated/v3/translation_service.get_supported_languages.js @@ -23,6 +23,9 @@ function main(parent) { // [START translate_v3_generated_TranslationService_GetSupportedLanguages_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.list_glossaries.js b/samples/generated/v3/translation_service.list_glossaries.js index 0d085bc5..2e5ed20b 100644 --- a/samples/generated/v3/translation_service.list_glossaries.js +++ b/samples/generated/v3/translation_service.list_glossaries.js @@ -23,6 +23,9 @@ function main(parent) { // [START translate_v3_generated_TranslationService_ListGlossaries_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.translate_document.js b/samples/generated/v3/translation_service.translate_document.js index 993c4129..069b2b60 100644 --- a/samples/generated/v3/translation_service.translate_document.js +++ b/samples/generated/v3/translation_service.translate_document.js @@ -23,6 +23,9 @@ function main(parent, targetLanguageCode, documentInputConfig) { // [START translate_v3_generated_TranslationService_TranslateDocument_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3/translation_service.translate_text.js b/samples/generated/v3/translation_service.translate_text.js index 6ec73656..0eb65ba0 100644 --- a/samples/generated/v3/translation_service.translate_text.js +++ b/samples/generated/v3/translation_service.translate_text.js @@ -23,6 +23,9 @@ function main(contents, targetLanguageCode, parent) { // [START translate_v3_generated_TranslationService_TranslateText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/snippet_metadata.google.cloud.translation.v3beta1.json b/samples/generated/v3beta1/snippet_metadata.google.cloud.translation.v3beta1.json index 62a724e1..319d303e 100644 --- a/samples/generated/v3beta1/snippet_metadata.google.cloud.translation.v3beta1.json +++ b/samples/generated/v3beta1/snippet_metadata.google.cloud.translation.v3beta1.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 114, + "end": 117, "type": "FULL" } ], @@ -90,7 +90,7 @@ "segments": [ { "start": 25, - "end": 84, + "end": 87, "type": "FULL" } ], @@ -146,7 +146,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 78, "type": "FULL" } ], @@ -194,7 +194,7 @@ "segments": [ { "start": 25, - "end": 111, + "end": 114, "type": "FULL" } ], @@ -262,7 +262,7 @@ "segments": [ { "start": 25, - "end": 108, + "end": 111, "type": "FULL" } ], @@ -330,7 +330,7 @@ "segments": [ { "start": 25, - "end": 112, + "end": 115, "type": "FULL" } ], @@ -398,7 +398,7 @@ "segments": [ { "start": 25, - "end": 56, + "end": 59, "type": "FULL" } ], @@ -442,7 +442,7 @@ "segments": [ { "start": 25, - "end": 83, + "end": 86, "type": "FULL" } ], @@ -494,7 +494,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -534,7 +534,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], diff --git a/samples/generated/v3beta1/translation_service.batch_translate_document.js b/samples/generated/v3beta1/translation_service.batch_translate_document.js index 9799f763..5cea9cd7 100644 --- a/samples/generated/v3beta1/translation_service.batch_translate_document.js +++ b/samples/generated/v3beta1/translation_service.batch_translate_document.js @@ -23,6 +23,9 @@ function main(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) { // [START translate_v3beta1_generated_TranslationService_BatchTranslateDocument_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.batch_translate_text.js b/samples/generated/v3beta1/translation_service.batch_translate_text.js index cd544b9f..050b66c6 100644 --- a/samples/generated/v3beta1/translation_service.batch_translate_text.js +++ b/samples/generated/v3beta1/translation_service.batch_translate_text.js @@ -23,6 +23,9 @@ function main(parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) { // [START translate_v3beta1_generated_TranslationService_BatchTranslateText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.create_glossary.js b/samples/generated/v3beta1/translation_service.create_glossary.js index 98d9ec5b..c0282423 100644 --- a/samples/generated/v3beta1/translation_service.create_glossary.js +++ b/samples/generated/v3beta1/translation_service.create_glossary.js @@ -23,6 +23,9 @@ function main(parent, glossary) { // [START translate_v3beta1_generated_TranslationService_CreateGlossary_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.delete_glossary.js b/samples/generated/v3beta1/translation_service.delete_glossary.js index 349ddd3c..a5f77fcf 100644 --- a/samples/generated/v3beta1/translation_service.delete_glossary.js +++ b/samples/generated/v3beta1/translation_service.delete_glossary.js @@ -23,6 +23,9 @@ function main(name) { // [START translate_v3beta1_generated_TranslationService_DeleteGlossary_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.detect_language.js b/samples/generated/v3beta1/translation_service.detect_language.js index 671d81e8..cfd74d46 100644 --- a/samples/generated/v3beta1/translation_service.detect_language.js +++ b/samples/generated/v3beta1/translation_service.detect_language.js @@ -23,6 +23,9 @@ function main(parent) { // [START translate_v3beta1_generated_TranslationService_DetectLanguage_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.get_glossary.js b/samples/generated/v3beta1/translation_service.get_glossary.js index bfc46986..8f031109 100644 --- a/samples/generated/v3beta1/translation_service.get_glossary.js +++ b/samples/generated/v3beta1/translation_service.get_glossary.js @@ -23,6 +23,9 @@ function main(name) { // [START translate_v3beta1_generated_TranslationService_GetGlossary_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.get_supported_languages.js b/samples/generated/v3beta1/translation_service.get_supported_languages.js index f587de0d..6d86e737 100644 --- a/samples/generated/v3beta1/translation_service.get_supported_languages.js +++ b/samples/generated/v3beta1/translation_service.get_supported_languages.js @@ -23,6 +23,9 @@ function main(parent) { // [START translate_v3beta1_generated_TranslationService_GetSupportedLanguages_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.list_glossaries.js b/samples/generated/v3beta1/translation_service.list_glossaries.js index d634c74e..b6749dd2 100644 --- a/samples/generated/v3beta1/translation_service.list_glossaries.js +++ b/samples/generated/v3beta1/translation_service.list_glossaries.js @@ -23,6 +23,9 @@ function main(parent) { // [START translate_v3beta1_generated_TranslationService_ListGlossaries_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.translate_document.js b/samples/generated/v3beta1/translation_service.translate_document.js index 5374904f..ba5432f9 100644 --- a/samples/generated/v3beta1/translation_service.translate_document.js +++ b/samples/generated/v3beta1/translation_service.translate_document.js @@ -23,6 +23,9 @@ function main(parent, targetLanguageCode, documentInputConfig) { // [START translate_v3beta1_generated_TranslationService_TranslateDocument_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/samples/generated/v3beta1/translation_service.translate_text.js b/samples/generated/v3beta1/translation_service.translate_text.js index 8dc72738..bb98ef28 100644 --- a/samples/generated/v3beta1/translation_service.translate_text.js +++ b/samples/generated/v3beta1/translation_service.translate_text.js @@ -23,6 +23,9 @@ function main(contents, targetLanguageCode, parent) { // [START translate_v3beta1_generated_TranslationService_TranslateText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/src/v3/translation_service_client.ts b/src/v3/translation_service_client.ts index f67e99c5..4922d27d 100644 --- a/src/v3/translation_service_client.ts +++ b/src/v3/translation_service_client.ts @@ -30,7 +30,6 @@ import { } from 'google-gax'; import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -366,7 +365,8 @@ export class TranslationServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -1257,7 +1257,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.batchTranslateText, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3.BatchTranslateResponse, @@ -1457,7 +1457,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.batchTranslateDocument, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3.BatchTranslateDocumentResponse, @@ -1597,7 +1597,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.createGlossary, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3.Glossary, @@ -1736,7 +1736,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.deleteGlossary, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3.DeleteGlossaryResponse, @@ -1923,7 +1923,7 @@ export class TranslationServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listGlossaries.createStream( - this.innerApiCalls.listGlossaries as gax.GaxCall, + this.innerApiCalls.listGlossaries as GaxCall, request, callSettings ); @@ -1992,7 +1992,7 @@ export class TranslationServiceClient { this.initialize(); return this.descriptors.page.listGlossaries.asyncIterate( this.innerApiCalls['listGlossaries'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v3beta1/translation_service_client.ts b/src/v3beta1/translation_service_client.ts index 765f4dfd..d16bfed3 100644 --- a/src/v3beta1/translation_service_client.ts +++ b/src/v3beta1/translation_service_client.ts @@ -30,7 +30,6 @@ import { } from 'google-gax'; import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -367,7 +366,8 @@ export class TranslationServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -1272,7 +1272,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.batchTranslateText, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3beta1.BatchTranslateResponse, @@ -1472,7 +1472,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.batchTranslateDocument, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3beta1.BatchTranslateDocumentResponse, @@ -1612,7 +1612,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.createGlossary, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3beta1.Glossary, @@ -1751,7 +1751,7 @@ export class TranslationServiceClient { const decodeOperation = new gax.Operation( operation, this.descriptors.longrunning.deleteGlossary, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.translation.v3beta1.DeleteGlossaryResponse, @@ -1938,7 +1938,7 @@ export class TranslationServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listGlossaries.createStream( - this.innerApiCalls.listGlossaries as gax.GaxCall, + this.innerApiCalls.listGlossaries as GaxCall, request, callSettings ); @@ -2007,7 +2007,7 @@ export class TranslationServiceClient { this.initialize(); return this.descriptors.page.listGlossaries.asyncIterate( this.innerApiCalls['listGlossaries'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/test/gapic_translation_service_v3.ts b/test/gapic_translation_service_v3.ts index 07fe1faf..bbb893d3 100644 --- a/test/gapic_translation_service_v3.ts +++ b/test/gapic_translation_service_v3.ts @@ -145,101 +145,103 @@ function stubAsyncIterationCall( } describe('v3.TranslationServiceClient', () => { - it('has servicePath', () => { - const servicePath = - translationserviceModule.v3.TranslationServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - translationserviceModule.v3.TranslationServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = translationserviceModule.v3.TranslationServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + translationserviceModule.v3.TranslationServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with no option', () => { - const client = new translationserviceModule.v3.TranslationServiceClient(); - assert(client); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + translationserviceModule.v3.TranslationServiceClient.apiEndpoint; + assert(apiEndpoint); + }); - it('should create a client with gRPC fallback', () => { - const client = new translationserviceModule.v3.TranslationServiceClient({ - fallback: true, + it('has port', () => { + const port = translationserviceModule.v3.TranslationServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new translationserviceModule.v3.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new translationserviceModule.v3.TranslationServiceClient(); + assert(client); }); - assert.strictEqual(client.translationServiceStub, undefined); - await client.initialize(); - assert(client.translationServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new translationserviceModule.v3.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with gRPC fallback', () => { + const client = new translationserviceModule.v3.TranslationServiceClient({ + fallback: true, + }); + assert(client); }); - client.initialize(); - assert(client.translationServiceStub); - client.close().then(() => { - done(); + + it('has initialize method and supports deferred initialization', async () => { + const client = new translationserviceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.translationServiceStub, undefined); + await client.initialize(); + assert(client.translationServiceStub); }); - }); - it('has close method for the non-initialized client', done => { - const client = new translationserviceModule.v3.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = new translationserviceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.translationServiceStub); + client.close().then(() => { + done(); + }); }); - assert.strictEqual(client.translationServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the non-initialized client', done => { + const client = new translationserviceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.translationServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new translationserviceModule.v3.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new translationserviceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new translationserviceModule.v3.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new translationserviceModule.v3.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('translateText', () => { diff --git a/test/gapic_translation_service_v3beta1.ts b/test/gapic_translation_service_v3beta1.ts index e5f74187..313d4c88 100644 --- a/test/gapic_translation_service_v3beta1.ts +++ b/test/gapic_translation_service_v3beta1.ts @@ -145,108 +145,111 @@ function stubAsyncIterationCall( } describe('v3beta1.TranslationServiceClient', () => { - it('has servicePath', () => { - const servicePath = - translationserviceModule.v3beta1.TranslationServiceClient.servicePath; - assert(servicePath); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + translationserviceModule.v3beta1.TranslationServiceClient.servicePath; + assert(servicePath); + }); - it('has apiEndpoint', () => { - const apiEndpoint = - translationserviceModule.v3beta1.TranslationServiceClient.apiEndpoint; - assert(apiEndpoint); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + translationserviceModule.v3beta1.TranslationServiceClient.apiEndpoint; + assert(apiEndpoint); + }); - it('has port', () => { - const port = translationserviceModule.v3beta1.TranslationServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = + translationserviceModule.v3beta1.TranslationServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = - new translationserviceModule.v3beta1.TranslationServiceClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = - new translationserviceModule.v3beta1.TranslationServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = - new translationserviceModule.v3beta1.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.translationServiceStub, undefined); - await client.initialize(); - assert(client.translationServiceStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.translationServiceStub, undefined); + await client.initialize(); + assert(client.translationServiceStub); + }); - it('has close method for the initialized client', done => { - const client = - new translationserviceModule.v3beta1.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.translationServiceStub); + client.close().then(() => { + done(); }); - client.initialize(); - assert(client.translationServiceStub); - client.close().then(() => { - done(); }); - }); - it('has close method for the non-initialized client', done => { - const client = - new translationserviceModule.v3beta1.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.translationServiceStub, undefined); + client.close().then(() => { + done(); }); - assert.strictEqual(client.translationServiceStub, undefined); - client.close().then(() => { - done(); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = - new translationserviceModule.v3beta1.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = - new translationserviceModule.v3beta1.TranslationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new translationserviceModule.v3beta1.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('translateText', () => {