Skip to content

Commit

Permalink
fix: export this.operationsClient (#166)
Browse files Browse the repository at this point in the history
* fix: export this.operationsClient

* fix: do not expose operationsClient if no LRO
  • Loading branch information
alexander-fenster authored Dec 10, 2019
1 parent f926473 commit 17963fb
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion templates/typescript_gapic/package.json.njk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ limitations under the License.
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^1.11.0"
"google-gax": "^1.12.0"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export class {{ service.name }}Client {
{%- endif %}
private _terminated = false;
auth: gax.GoogleAuth;
{%- if (service.longRunning.length > 0) %}
operationsClient: gax.OperationsClient;
{%- endif %}
{{ service.name.toCamelCase() }}Stub: Promise<{[name: string]: Function}>;

/**
Expand Down Expand Up @@ -185,7 +188,7 @@ export class {{ service.name }}Client {
gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
gaxModule.protobuf.loadSync(nodejsProtoPath);

const operationsClient = gaxModule.lro({
this.operationsClient = gaxModule.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined
}).operationsClient(opts);
Expand All @@ -202,7 +205,7 @@ export class {{ service.name }}Client {
{%- for method in service.longRunning %}
{{- longRunningJoiner() }}
{{ method.name.toCamelCase() }}: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
{{ method.name.toCamelCase() }}Response.decode.bind({{ method.name.toCamelCase() }}Response),
{{ method.name.toCamelCase() }}Metadata.decode.bind({{ method.name.toCamelCase() }}Metadata))
{%- endfor %}
Expand Down
2 changes: 1 addition & 1 deletion typescript/test/testdata/keymanager/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^1.11.0"
"google-gax": "^1.12.0"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand Down
2 changes: 1 addition & 1 deletion typescript/test/testdata/redis/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^1.11.0"
"google-gax": "^1.12.0"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class CloudRedisClient {
private _pathTemplates: {[name: string]: gax.PathTemplate};
private _terminated = false;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
cloudRedisStub: Promise<{[name: string]: Function}>;

/**
Expand Down Expand Up @@ -168,7 +169,7 @@ export class CloudRedisClient {
gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
gaxModule.protobuf.loadSync(nodejsProtoPath);

const operationsClient = gaxModule.lro({
this.operationsClient = gaxModule.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined
}).operationsClient(opts);
Expand Down Expand Up @@ -199,27 +200,27 @@ export class CloudRedisClient {

this._descriptors.longrunning = {
createInstance: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
createInstanceResponse.decode.bind(createInstanceResponse),
createInstanceMetadata.decode.bind(createInstanceMetadata)),
updateInstance: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
updateInstanceResponse.decode.bind(updateInstanceResponse),
updateInstanceMetadata.decode.bind(updateInstanceMetadata)),
importInstance: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
importInstanceResponse.decode.bind(importInstanceResponse),
importInstanceMetadata.decode.bind(importInstanceMetadata)),
exportInstance: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
exportInstanceResponse.decode.bind(exportInstanceResponse),
exportInstanceMetadata.decode.bind(exportInstanceMetadata)),
failoverInstance: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
failoverInstanceResponse.decode.bind(failoverInstanceResponse),
failoverInstanceMetadata.decode.bind(failoverInstanceMetadata)),
deleteInstance: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
deleteInstanceResponse.decode.bind(deleteInstanceResponse),
deleteInstanceMetadata.decode.bind(deleteInstanceMetadata))
};
Expand Down
2 changes: 1 addition & 1 deletion typescript/test/testdata/showcase/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^1.11.0"
"google-gax": "^1.12.0"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class EchoClient {
private _innerApiCalls: {[name: string]: Function};
private _terminated = false;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
echoStub: Promise<{[name: string]: Function}>;

/**
Expand Down Expand Up @@ -152,7 +153,7 @@ export class EchoClient {
gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
gaxModule.protobuf.loadSync(nodejsProtoPath);

const operationsClient = gaxModule.lro({
this.operationsClient = gaxModule.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined
}).operationsClient(opts);
Expand All @@ -163,7 +164,7 @@ export class EchoClient {

this._descriptors.longrunning = {
wait: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
waitResponse.decode.bind(waitResponse),
waitMetadata.decode.bind(waitMetadata))
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^1.11.0"
"google-gax": "^1.12.0"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand Down
2 changes: 1 addition & 1 deletion typescript/test/testdata/translate/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^1.11.0"
"google-gax": "^1.12.0"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class TranslationServiceClient {
private _pathTemplates: {[name: string]: gax.PathTemplate};
private _terminated = false;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
translationServiceStub: Promise<{[name: string]: Function}>;

/**
Expand Down Expand Up @@ -154,7 +155,7 @@ export class TranslationServiceClient {
gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
gaxModule.protobuf.loadSync(nodejsProtoPath);

const operationsClient = gaxModule.lro({
this.operationsClient = gaxModule.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined
}).operationsClient(opts);
Expand All @@ -173,15 +174,15 @@ export class TranslationServiceClient {

this._descriptors.longrunning = {
batchTranslateText: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
batchTranslateTextResponse.decode.bind(batchTranslateTextResponse),
batchTranslateTextMetadata.decode.bind(batchTranslateTextMetadata)),
createGlossary: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
createGlossaryResponse.decode.bind(createGlossaryResponse),
createGlossaryMetadata.decode.bind(createGlossaryMetadata)),
deleteGlossary: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
deleteGlossaryResponse.decode.bind(deleteGlossaryResponse),
deleteGlossaryMetadata.decode.bind(deleteGlossaryMetadata))
};
Expand Down

0 comments on commit 17963fb

Please sign in to comment.