Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: decode LRO metadata & response for users #420

Merged
merged 58 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
94f5950
add decode interface for all LROs
xiaozhenliu-gg5 Apr 10, 2020
fcf0141
test decodeLRO method
xiaozhenliu-gg5 Apr 13, 2020
7fd1651
add unit test for decodeLRO
xiaozhenliu-gg5 Apr 14, 2020
0469c48
merge
xiaozhenliu-gg5 Apr 14, 2020
20aa5d6
add decodeLRO interface & unit-test
xiaozhenliu-gg5 Apr 15, 2020
60283d6
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 15, 2020
1afa8c4
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 15, 2020
f7c4a30
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 15, 2020
a6c1a03
add tests in application for decodeLRO
xiaozhenliu-gg5 Apr 15, 2020
67fdfa9
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 15, 2020
e05b628
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 15, 2020
50edfba
comments for decode method
xiaozhenliu-gg5 Apr 17, 2020
f675fdb
use gax develop branch
xiaozhenliu-gg5 Apr 17, 2020
d281186
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 18, 2020
e5b86e2
add code samples
xiaozhenliu-gg5 Apr 18, 2020
c97ef6d
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 18, 2020
afcafa7
add decodeLRO unit test with error
xiaozhenliu-gg5 Apr 18, 2020
5a3946a
update return type for decode function
xiaozhenliu-gg5 Apr 20, 2020
3809aba
use latest gax
xiaozhenliu-gg5 Apr 21, 2020
d730298
update baseline dependency
xiaozhenliu-gg5 Apr 21, 2020
400565a
use next gax dependency
xiaozhenliu-gg5 Apr 21, 2020
c38c803
change function name to check*Progress
xiaozhenliu-gg5 Apr 21, 2020
723df6f
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 21, 2020
8073e6b
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 21, 2020
95583c3
typo
xiaozhenliu-gg5 Apr 21, 2020
fa3f2f9
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 21, 2020
7669ffb
update baseline tests
xiaozhenliu-gg5 Apr 21, 2020
29fbae6
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 21, 2020
a0f67e1
update baseline
xiaozhenliu-gg5 Apr 21, 2020
f2ad082
change function name to PascalCase
xiaozhenliu-gg5 Apr 21, 2020
ff8db0b
test application for ts/js
xiaozhenliu-gg5 Apr 21, 2020
dfbeda9
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 22, 2020
e8380cf
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 22, 2020
df09abe
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 22, 2020
41d7049
add timeout in js-test-application
xiaozhenliu-gg5 Apr 22, 2020
51ba4f1
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 22, 2020
9ec93d1
update comments
xiaozhenliu-gg5 Apr 22, 2020
ae1cef7
update baseline
xiaozhenliu-gg5 Apr 22, 2020
e8e7fd7
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 22, 2020
8a51256
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 22, 2020
2c865a3
feedback
xiaozhenliu-gg5 Apr 22, 2020
626082a
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 22, 2020
786ea1c
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 22, 2020
c99544c
@example
xiaozhenliu-gg5 Apr 22, 2020
4537031
shorten reject assertion in test
xiaozhenliu-gg5 Apr 22, 2020
f29bc8c
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 22, 2020
bfbdee3
tests all green
xiaozhenliu-gg5 Apr 22, 2020
55ee213
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 23, 2020
1723997
yes latest google-gax
xiaozhenliu-gg5 Apr 24, 2020
d04fbbd
update interface
xiaozhenliu-gg5 Apr 24, 2020
a4d86f8
update template and unit test
xiaozhenliu-gg5 Apr 24, 2020
cf02fda
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 24, 2020
266046f
reslove conflict with master
xiaozhenliu-gg5 Apr 24, 2020
d34dd54
update comment
xiaozhenliu-gg5 Apr 24, 2020
f4e5011
update dependency
xiaozhenliu-gg5 Apr 24, 2020
bde479c
Merge branch 'master' into decode_lro
xiaozhenliu-gg5 Apr 24, 2020
4a6799b
use gax ^2.3.1
xiaozhenliu-gg5 Apr 24, 2020
98941e8
Merge branch 'decode_lro' of github.com:googleapis/gapic-generator-ty…
xiaozhenliu-gg5 Apr 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baselines/bigquery-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^2.3.0"
"google-gax": "^2.3.1"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('v1beta1.BigQueryStorageClient', () => {
};
const expectedError = new Error('expected');
client.innerApiCalls.createReadSession = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.createReadSession(request); }, expectedError);
await assert.rejects(client.createReadSession(request), expectedError);
assert((client.innerApiCalls.createReadSession as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('v1beta1.BigQueryStorageClient', () => {
};
const expectedError = new Error('expected');
client.innerApiCalls.batchCreateReadSessionStreams = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.batchCreateReadSessionStreams(request); }, expectedError);
await assert.rejects(client.batchCreateReadSessionStreams(request), expectedError);
assert((client.innerApiCalls.batchCreateReadSessionStreams as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('v1beta1.BigQueryStorageClient', () => {
};
const expectedError = new Error('expected');
client.innerApiCalls.finalizeStream = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.finalizeStream(request); }, expectedError);
await assert.rejects(client.finalizeStream(request), expectedError);
assert((client.innerApiCalls.finalizeStream as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('v1beta1.BigQueryStorageClient', () => {
};
const expectedError = new Error('expected');
client.innerApiCalls.splitReadStream = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.splitReadStream(request); }, expectedError);
await assert.rejects(client.splitReadStream(request), expectedError);
assert((client.innerApiCalls.splitReadStream as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -551,7 +551,7 @@ describe('v1beta1.BigQueryStorageClient', () => {
reject(err);
});
});
await assert.rejects(async () => { await promise; }, expectedError);
await assert.rejects(promise, expectedError);
assert((client.innerApiCalls.readRows as SinonStub)
.getCall(0).calledWith(request, expectedOptions));
});
Expand Down
2 changes: 1 addition & 1 deletion baselines/disable-packing-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^2.3.0"
"google-gax": "^2.3.1"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import * as gapicConfig from './echo_client_config.json';

import { operationsProtos } from 'google-gax';
const version = require('../../../package.json').version;

/**
Expand Down Expand Up @@ -607,6 +607,26 @@ export class EchoClient {
this.initialize();
return this.innerApiCalls.wait(request, options, callback);
}
/**
* Check the status of the long running operation returned by the wait() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkWaitProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
async checkWaitProgress(name: string): Promise<LROperation<protos.google.showcase.v1beta1.WaitResponse, protos.google.showcase.v1beta1.WaitMetadata>>{
const request = new operationsProtos.google.longrunning.GetOperationRequest({name});
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.wait, gax.createDefaultBackoffSettings());
return decodeOperation as LROperation<protos.google.showcase.v1beta1.WaitResponse, protos.google.showcase.v1beta1.WaitMetadata>;
}
pagedExpand(
request: protos.google.showcase.v1beta1.IPagedExpandRequest,
options?: gax.CallOptions):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import * as gapicConfig from './messaging_client_config.json';

import { operationsProtos } from 'google-gax';
const version = require('../../../package.json').version;

/**
Expand Down Expand Up @@ -1042,6 +1042,26 @@ export class MessagingClient {
this.initialize();
return this.innerApiCalls.searchBlurbs(request, options, callback);
}
/**
* Check the status of the long running operation returned by the searchBlurbs() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkSearchBlurbsProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
async checkSearchBlurbsProgress(name: string): Promise<LROperation<protos.google.showcase.v1beta1.SearchBlurbsResponse, protos.google.showcase.v1beta1.SearchBlurbsMetadata>>{
const request = new operationsProtos.google.longrunning.GetOperationRequest({name});
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.searchBlurbs, gax.createDefaultBackoffSettings());
return decodeOperation as LROperation<protos.google.showcase.v1beta1.SearchBlurbsResponse, protos.google.showcase.v1beta1.SearchBlurbsMetadata>;
}
listRooms(
request: protos.google.showcase.v1beta1.IListRoomsRequest,
options?: gax.CallOptions):
Expand Down
52 changes: 42 additions & 10 deletions baselines/disable-packing-test/test/gapic_echo_v1beta1.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as echoModule from '../src';

import {PassThrough} from 'stream';

import {protobuf, LROperation} from 'google-gax';
import {protobuf, LROperation, operationsProtos} from 'google-gax';

function generateSampleMessage<T extends object>(instance: T) {
const filledObject = (instance.constructor as typeof protobuf.Message)
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('v1beta1.EchoClient', () => {
const expectedOptions = {};
const expectedError = new Error('expected');
client.innerApiCalls.echo = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.echo(request); }, expectedError);
await assert.rejects(client.echo(request), expectedError);
assert((client.innerApiCalls.echo as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('v1beta1.EchoClient', () => {
const expectedOptions = {};
const expectedError = new Error('expected');
client.innerApiCalls.block = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.block(request); }, expectedError);
await assert.rejects(client.block(request), expectedError);
assert((client.innerApiCalls.block as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -392,7 +392,7 @@ describe('v1beta1.EchoClient', () => {
const expectedOptions = {};
const expectedError = new Error('expected');
client.innerApiCalls.wait = stubLongRunningCall(undefined, expectedError);
await assert.rejects(async () => { await client.wait(request); }, expectedError);
await assert.rejects(client.wait(request), expectedError);
assert((client.innerApiCalls.wait as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand All @@ -408,10 +408,42 @@ describe('v1beta1.EchoClient', () => {
const expectedError = new Error('expected');
client.innerApiCalls.wait = stubLongRunningCall(undefined, undefined, expectedError);
const [operation] = await client.wait(request);
await assert.rejects(async () => { await operation.promise(); }, expectedError);
await assert.rejects(operation.promise(), expectedError);
assert((client.innerApiCalls.wait as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});

it('invokes checkWaitProgress without error', async () => {
const client = new echoModule.v1beta1.EchoClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
xiaozhenliu-gg5 marked this conversation as resolved.
Show resolved Hide resolved
const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation());
expectedResponse.name = 'test';
expectedResponse.response = {type_url: 'url', value: Buffer.from('')};
expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}

client.operationsClient.getOperation = stubSimpleCall(expectedResponse);
const decodedOperation = await client.checkWaitProgress(expectedResponse.name);
assert.deepStrictEqual(decodedOperation.name, expectedResponse.name);
assert(decodedOperation.metadata);
assert((client.operationsClient.getOperation as SinonStub).getCall(0));
});

it('invokes checkWaitProgress with error', async () => {
const client = new echoModule.v1beta1.EchoClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const expectedError = new Error('expected');

client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError);
await assert.rejects(client.checkWaitProgress(''), expectedError);
assert((client.operationsClient.getOperation as SinonStub)
.getCall(0));
});
});

describe('expand', () => {
Expand Down Expand Up @@ -459,7 +491,7 @@ describe('v1beta1.EchoClient', () => {
reject(err);
});
});
await assert.rejects(async () => { await promise; }, expectedError);
await assert.rejects(promise, expectedError);
assert((client.innerApiCalls.expand as SinonStub)
.getCall(0).calledWith(request, expectedOptions));
});
Expand Down Expand Up @@ -513,7 +545,7 @@ describe('v1beta1.EchoClient', () => {
stream.write(request);
stream.end();
});
await assert.rejects(async () => { await promise; }, expectedError);
await assert.rejects(promise, expectedError);
assert((client.innerApiCalls.chat as SinonStub)
.getCall(0).calledWithExactly(undefined));
assert.deepStrictEqual(((stream as unknown as PassThrough)
Expand Down Expand Up @@ -573,7 +605,7 @@ describe('v1beta1.EchoClient', () => {
stream.write(request);
stream.end();
});
await assert.rejects(async () => { await promise; }, expectedError);
await assert.rejects(promise, expectedError);
assert((client.innerApiCalls.collect as SinonStub)
.getCall(0).calledWith(null, {} /*, callback defined above */));
});
Expand Down Expand Up @@ -641,7 +673,7 @@ describe('v1beta1.EchoClient', () => {
const expectedOptions = {};
const expectedError = new Error('expected');
client.innerApiCalls.pagedExpand = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.pagedExpand(request); }, expectedError);
await assert.rejects(client.pagedExpand(request), expectedError);
assert((client.innerApiCalls.pagedExpand as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -700,7 +732,7 @@ describe('v1beta1.EchoClient', () => {
reject(err);
});
});
await assert.rejects(async () => { await promise; }, expectedError);
await assert.rejects(promise, expectedError);
assert((client.descriptors.page.pagedExpand.createStream as SinonStub)
.getCall(0).calledWith(client.innerApiCalls.pagedExpand, request));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('v1beta1.IdentityClient', () => {
const expectedOptions = {};
const expectedError = new Error('expected');
client.innerApiCalls.createUser = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.createUser(request); }, expectedError);
await assert.rejects(client.createUser(request), expectedError);
assert((client.innerApiCalls.createUser as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('v1beta1.IdentityClient', () => {
};
const expectedError = new Error('expected');
client.innerApiCalls.getUser = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.getUser(request); }, expectedError);
await assert.rejects(client.getUser(request), expectedError);
assert((client.innerApiCalls.getUser as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -390,7 +390,7 @@ describe('v1beta1.IdentityClient', () => {
};
const expectedError = new Error('expected');
client.innerApiCalls.updateUser = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.updateUser(request); }, expectedError);
await assert.rejects(client.updateUser(request), expectedError);
assert((client.innerApiCalls.updateUser as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -474,7 +474,7 @@ describe('v1beta1.IdentityClient', () => {
};
const expectedError = new Error('expected');
client.innerApiCalls.deleteUser = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.deleteUser(request); }, expectedError);
await assert.rejects(client.deleteUser(request), expectedError);
assert((client.innerApiCalls.deleteUser as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -542,7 +542,7 @@ describe('v1beta1.IdentityClient', () => {
const expectedOptions = {};
const expectedError = new Error('expected');
client.innerApiCalls.listUsers = stubSimpleCall(undefined, expectedError);
await assert.rejects(async () => { await client.listUsers(request); }, expectedError);
await assert.rejects(client.listUsers(request), expectedError);
assert((client.innerApiCalls.listUsers as SinonStub)
.getCall(0).calledWith(request, expectedOptions, undefined));
});
Expand Down Expand Up @@ -601,7 +601,7 @@ describe('v1beta1.IdentityClient', () => {
reject(err);
});
});
await assert.rejects(async () => { await promise; }, expectedError);
await assert.rejects(promise, expectedError);
assert((client.descriptors.page.listUsers.createStream as SinonStub)
.getCall(0).calledWith(client.innerApiCalls.listUsers, request));
});
Expand Down
Loading