From 5084f0280e9456bd944c4820ee7eb0f6a2c6cef6 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:04:20 +0000 Subject: [PATCH] fix: better support for fallback mode (#192) - [ ] 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 --- ...data.google.cloud.video.transcoder.v1.json | 16 +- .../v1/transcoder_service.create_job.js | 3 + .../transcoder_service.create_job_template.js | 3 + .../v1/transcoder_service.delete_job.js | 3 + .../transcoder_service.delete_job_template.js | 3 + .../v1/transcoder_service.get_job.js | 3 + .../v1/transcoder_service.get_job_template.js | 3 + .../transcoder_service.list_job_templates.js | 3 + .../v1/transcoder_service.list_jobs.js | 3 + .../src/v1/transcoder_service_client.ts | 12 +- .../test/gapic_transcoder_service_v1.ts | 160 +++++++++--------- 11 files changed, 119 insertions(+), 93 deletions(-) diff --git a/packages/google-cloud-video-transcoder/samples/generated/v1/snippet_metadata.google.cloud.video.transcoder.v1.json b/packages/google-cloud-video-transcoder/samples/generated/v1/snippet_metadata.google.cloud.video.transcoder.v1.json index 0ca9f45866e..93bd641ab69 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/snippet_metadata.google.cloud.video.transcoder.v1.json +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/snippet_metadata.google.cloud.video.transcoder.v1.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 56, + "end": 59, "type": "FULL" } ], @@ -66,7 +66,7 @@ "segments": [ { "start": 25, - "end": 71, + "end": 74, "type": "FULL" } ], @@ -122,7 +122,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], @@ -162,7 +162,7 @@ "segments": [ { "start": 25, - "end": 56, + "end": 59, "type": "FULL" } ], @@ -206,7 +206,7 @@ "segments": [ { "start": 25, - "end": 64, + "end": 67, "type": "FULL" } ], @@ -254,7 +254,7 @@ "segments": [ { "start": 25, - "end": 72, + "end": 75, "type": "FULL" } ], @@ -310,7 +310,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -350,7 +350,7 @@ "segments": [ { "start": 25, - "end": 56, + "end": 59, "type": "FULL" } ], diff --git a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job.js index 47a3d4dc006..d82dfe261ac 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job.js @@ -23,6 +23,9 @@ function main(parent, job) { // [START transcoder_v1_generated_TranscoderService_CreateJob_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/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job_template.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job_template.js index d1deee0897e..2e2e80f2111 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job_template.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.create_job_template.js @@ -23,6 +23,9 @@ function main(parent, jobTemplate, jobTemplateId) { // [START transcoder_v1_generated_TranscoderService_CreateJobTemplate_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/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job.js index 46fd9e352bc..409f20f16db 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job.js @@ -23,6 +23,9 @@ function main(name) { // [START transcoder_v1_generated_TranscoderService_DeleteJob_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/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job_template.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job_template.js index a1ebefe8f94..54659c7134a 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job_template.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.delete_job_template.js @@ -23,6 +23,9 @@ function main(name) { // [START transcoder_v1_generated_TranscoderService_DeleteJobTemplate_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/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job.js index 8f8eb07f9f2..f350faa246d 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job.js @@ -23,6 +23,9 @@ function main(name) { // [START transcoder_v1_generated_TranscoderService_GetJob_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/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job_template.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job_template.js index 4a3baa4dc5a..5e5f5d344d5 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job_template.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.get_job_template.js @@ -23,6 +23,9 @@ function main(name) { // [START transcoder_v1_generated_TranscoderService_GetJobTemplate_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/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_job_templates.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_job_templates.js index d6891c5a6b6..51356b1063a 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_job_templates.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_job_templates.js @@ -23,6 +23,9 @@ function main(parent) { // [START transcoder_v1_generated_TranscoderService_ListJobTemplates_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/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_jobs.js b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_jobs.js index 0c0755b2c95..4f7dd7599ca 100644 --- a/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_jobs.js +++ b/packages/google-cloud-video-transcoder/samples/generated/v1/transcoder_service.list_jobs.js @@ -23,6 +23,9 @@ function main(parent) { // [START transcoder_v1_generated_TranscoderService_ListJobs_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/packages/google-cloud-video-transcoder/src/v1/transcoder_service_client.ts b/packages/google-cloud-video-transcoder/src/v1/transcoder_service_client.ts index 448c06f2626..721b0e2f58e 100644 --- a/packages/google-cloud-video-transcoder/src/v1/transcoder_service_client.ts +++ b/packages/google-cloud-video-transcoder/src/v1/transcoder_service_client.ts @@ -28,7 +28,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'); /** @@ -274,7 +273,8 @@ export class TranscoderServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -1069,7 +1069,7 @@ export class TranscoderServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listJobs.createStream( - this.innerApiCalls.listJobs as gax.GaxCall, + this.innerApiCalls.listJobs as GaxCall, request, callSettings ); @@ -1124,7 +1124,7 @@ export class TranscoderServiceClient { this.initialize(); return this.descriptors.page.listJobs.asyncIterate( this.innerApiCalls['listJobs'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -1281,7 +1281,7 @@ export class TranscoderServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listJobTemplates.createStream( - this.innerApiCalls.listJobTemplates as gax.GaxCall, + this.innerApiCalls.listJobTemplates as GaxCall, request, callSettings ); @@ -1337,7 +1337,7 @@ export class TranscoderServiceClient { this.initialize(); return this.descriptors.page.listJobTemplates.asyncIterate( this.innerApiCalls['listJobTemplates'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/packages/google-cloud-video-transcoder/test/gapic_transcoder_service_v1.ts b/packages/google-cloud-video-transcoder/test/gapic_transcoder_service_v1.ts index 26f95eb9841..0b991f5a12a 100644 --- a/packages/google-cloud-video-transcoder/test/gapic_transcoder_service_v1.ts +++ b/packages/google-cloud-video-transcoder/test/gapic_transcoder_service_v1.ts @@ -113,101 +113,103 @@ function stubAsyncIterationCall( } describe('v1.TranscoderServiceClient', () => { - it('has servicePath', () => { - const servicePath = - transcoderserviceModule.v1.TranscoderServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - transcoderserviceModule.v1.TranscoderServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = transcoderserviceModule.v1.TranscoderServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new transcoderserviceModule.v1.TranscoderServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + transcoderserviceModule.v1.TranscoderServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new transcoderserviceModule.v1.TranscoderServiceClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + transcoderserviceModule.v1.TranscoderServiceClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new transcoderserviceModule.v1.TranscoderServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = transcoderserviceModule.v1.TranscoderServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.transcoderServiceStub, undefined); - await client.initialize(); - assert(client.transcoderServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new transcoderserviceModule.v1.TranscoderServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new transcoderserviceModule.v1.TranscoderServiceClient(); + assert(client); }); - client.initialize(); - assert(client.transcoderServiceStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new transcoderserviceModule.v1.TranscoderServiceClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new transcoderserviceModule.v1.TranscoderServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new transcoderserviceModule.v1.TranscoderServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.transcoderServiceStub, undefined); + await client.initialize(); + assert(client.transcoderServiceStub); }); - assert.strictEqual(client.transcoderServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new transcoderserviceModule.v1.TranscoderServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.transcoderServiceStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new transcoderserviceModule.v1.TranscoderServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new transcoderserviceModule.v1.TranscoderServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.transcoderServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - 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 transcoderserviceModule.v1.TranscoderServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new transcoderserviceModule.v1.TranscoderServiceClient({ + 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() - .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 transcoderserviceModule.v1.TranscoderServiceClient({ + 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('createJob', () => {