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: use common interface from gax #122

Merged
merged 6 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"file-system": "^2.2.2",
"fs-extra": "^8.1.0",
"get-stdin": "^7.0.0",
"google-gax": "^1.8.0",
"google-gax": "^1.9.0",
"nunjucks": "^3.1.3",
"object-hash": "^2.0.0",
"protobufjs": "^6.8.8",
Expand Down
2 changes: 1 addition & 1 deletion templates/typescript_gapic/package.json.njk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.
"build/protos"
],
"dependencies": {
"google-gax": "^1.8.0"
"google-gax": "^1.9.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
Expand Down
42 changes: 10 additions & 32 deletions templates/typescript_gapic/src/$version/$service_client.ts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ limitations under the License.
{% import "../../_util.njk" as util -%}

import * as gax from 'google-gax';
{% if service.longRunning.length > 0 -%}
import {Callback, LROperation, Descriptors, ClientOptions} from 'google-gax';
{%- else -%}
import {Callback, Descriptors, ClientOptions} from 'google-gax';
{%- endif %}
import * as path from 'path';
{% if (service.paging.length > 0) %}
import { Transform } from 'stream';
Expand All @@ -29,33 +34,6 @@ import * as gapicConfig from './{{ service.name.toSnakeCase() }}_client_config.j

const version = require('../../../package.json').version;

export interface ClientOptions extends gax.GrpcClientOptions,
gax.GoogleAuthOptions,
gax.ClientStubOptions {
libName?: string;
libVersion?: string;
clientConfig?: gax.ClientConfig;
fallback?: boolean;
apiEndpoint?: string;
}

interface Descriptors {
page: {[name: string]: gax.PageDescriptor};
stream: {[name: string]: gax.StreamDescriptor};
longrunning: {[name: string]: gax.LongrunningDescriptor};
}

export interface Callback<
ResponseObject, NextRequestObject, RawResponseObject> {
(err: Error|null|undefined, value?: ResponseObject|null,
nextRequest?: NextRequestObject, rawResponse?: RawResponseObject): void;
}
{% if (service.longRunning.length > 0) %}
export interface Operation<ResultType, MetadataType> extends gax.Operation {
promise(): Promise<[ResultType, MetadataType, protosTypes.google.longrunning.IOperation]>;
}
{%- endif %}

{% if (service.paging.length > 0) %}
export interface PaginationCallback<
RequestObject, ResponseObject, ResponseType> {
Expand Down Expand Up @@ -465,14 +443,14 @@ export class {{ service.name }}Client {
request: protosTypes{{ util.toInterface(method.inputInterface) }},
options?: gax.CallOptions):
Promise<[
Operation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
LROperation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
protosTypes{{ util.toInterface(method.outputInterface) }}|undefined, {}|undefined
]>;
{{ method.name.toCamelCase() }}(
request: protosTypes{{ util.toInterface(method.inputInterface) }},
options: gax.CallOptions,
callback: Callback<
Operation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
LROperation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
protosTypes{{ util.toInterface(method.outputInterface) }}|undefined,
{}|undefined>): void;
/**
Expand All @@ -481,14 +459,14 @@ export class {{ service.name }}Client {
{{ method.name.toCamelCase() }}(
request: protosTypes{{ util.toInterface(method.inputInterface) }},
optionsOrCallback?: gax.CallOptions|Callback<
Operation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType)}}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
LROperation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType)}}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
protosTypes{{ util.toInterface(method.outputInterface) }}|undefined, {}|undefined>,
callback?: Callback<
Operation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
LROperation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
protosTypes{{ util.toInterface(method.outputInterface) }}|undefined,
{}|undefined>):
Promise<[
Operation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
LROperation<protosTypes{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, protosTypes{{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>,
protosTypes{{ util.toInterface(method.outputInterface) }}|undefined, {}|undefined
]>|void {
request = request || {};
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 @@ -10,7 +10,7 @@
"build/protos"
],
"dependencies": {
"google-gax": "^1.8.0"
"google-gax": "^1.9.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {Callback, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand All @@ -25,29 +26,6 @@ import * as gapicConfig from './key_management_service_client_config.json';

const version = require('../../../package.json').version;

export interface ClientOptions extends gax.GrpcClientOptions,
gax.GoogleAuthOptions,
gax.ClientStubOptions {
libName?: string;
libVersion?: string;
clientConfig?: gax.ClientConfig;
fallback?: boolean;
apiEndpoint?: string;
}

interface Descriptors {
page: {[name: string]: gax.PageDescriptor};
stream: {[name: string]: gax.StreamDescriptor};
longrunning: {[name: string]: gax.LongrunningDescriptor};
}

export interface Callback<
ResponseObject, NextRequestObject, RawResponseObject> {
(err: Error|null|undefined, value?: ResponseObject|null,
nextRequest?: NextRequestObject, rawResponse?: RawResponseObject): void;
}



export interface PaginationCallback<
RequestObject, ResponseObject, ResponseType> {
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 @@ -10,7 +10,7 @@
"build/protos"
],
"dependencies": {
"google-gax": "^1.8.0"
"google-gax": "^1.9.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {Callback, LROperation, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand All @@ -25,32 +26,6 @@ import * as gapicConfig from './echo_client_config.json';

const version = require('../../../package.json').version;

export interface ClientOptions extends gax.GrpcClientOptions,
gax.GoogleAuthOptions,
gax.ClientStubOptions {
libName?: string;
libVersion?: string;
clientConfig?: gax.ClientConfig;
fallback?: boolean;
apiEndpoint?: string;
}

interface Descriptors {
page: {[name: string]: gax.PageDescriptor};
stream: {[name: string]: gax.StreamDescriptor};
longrunning: {[name: string]: gax.LongrunningDescriptor};
}

export interface Callback<
ResponseObject, NextRequestObject, RawResponseObject> {
(err: Error|null|undefined, value?: ResponseObject|null,
nextRequest?: NextRequestObject, rawResponse?: RawResponseObject): void;
}

export interface Operation<ResultType, MetadataType> extends gax.Operation {
promise(): Promise<[ResultType, MetadataType, protosTypes.google.longrunning.IOperation]>;
}


export interface PaginationCallback<
RequestObject, ResponseObject, ResponseType> {
Expand Down Expand Up @@ -441,14 +416,14 @@ export class EchoClient {
request: protosTypes.google.showcase.v1beta1.IWaitRequest,
options?: gax.CallOptions):
Promise<[
Operation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
LROperation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
protosTypes.google.longrunning.IOperation|undefined, {}|undefined
]>;
wait(
request: protosTypes.google.showcase.v1beta1.IWaitRequest,
options: gax.CallOptions,
callback: Callback<
Operation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
LROperation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
protosTypes.google.longrunning.IOperation|undefined,
{}|undefined>): void;
/**
Expand All @@ -475,14 +450,14 @@ export class EchoClient {
wait(
request: protosTypes.google.showcase.v1beta1.IWaitRequest,
optionsOrCallback?: gax.CallOptions|Callback<
Operation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
LROperation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
protosTypes.google.longrunning.IOperation|undefined, {}|undefined>,
callback?: Callback<
Operation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
LROperation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
protosTypes.google.longrunning.IOperation|undefined,
{}|undefined>):
Promise<[
Operation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
LROperation<protosTypes.google.showcase.v1beta1.IWaitResponse, protosTypes.google.showcase.v1beta1.IWaitMetadata>,
protosTypes.google.longrunning.IOperation|undefined, {}|undefined
]>|void {
request = request || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build/protos"
],
"dependencies": {
"google-gax": "^1.8.0"
"google-gax": "^1.9.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,14 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {Callback, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import * as protosTypes from '../../protos/protos';
import * as gapicConfig from './text_to_speech_client_config.json';

const version = require('../../../package.json').version;

export interface ClientOptions extends gax.GrpcClientOptions,
gax.GoogleAuthOptions,
gax.ClientStubOptions {
libName?: string;
libVersion?: string;
clientConfig?: gax.ClientConfig;
fallback?: boolean;
apiEndpoint?: string;
}

interface Descriptors {
page: {[name: string]: gax.PageDescriptor};
stream: {[name: string]: gax.StreamDescriptor};
longrunning: {[name: string]: gax.LongrunningDescriptor};
}

export interface Callback<
ResponseObject, NextRequestObject, RawResponseObject> {
(err: Error|null|undefined, value?: ResponseObject|null,
nextRequest?: NextRequestObject, rawResponse?: RawResponseObject): void;
}




/**
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 @@ -10,7 +10,7 @@
"build/protos"
],
"dependencies": {
"google-gax": "^1.8.0"
"google-gax": "^1.9.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
Expand Down
Loading