Skip to content

Commit

Permalink
fix: more minor fixes (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fenster committed Nov 7, 2019
1 parent d58c6b2 commit 4909e3c
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 79 deletions.
2 changes: 1 addition & 1 deletion templates/typescript_gapic/_util.njk
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ limitations under the License.
{%- macro printCommentsForService(service) -%}
{%- set lines = service.comments -%}
{% for line in lines %}
* {{ line | safe}}
* {{ line | safe}}
{%- endfor %}
{%- endmacro -%}

Expand Down
27 changes: 14 additions & 13 deletions templates/typescript_gapic/src/$version/$service_client.ts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ export interface PaginationResponse<
rawResponse?: ResponseObject;
}
{% endif %}

/**
{{- util.printCommentsForService(service) }}
*/
export class {{ service.name }}Client {
/**
{{- util.printCommentsForService(service) }}
*/
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
{%- if (service.pathTemplates.length > 0) %}
Expand Down Expand Up @@ -99,10 +100,8 @@ export class {{ service.name }}Client {
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@@link
* https://developers.google.com/identity/protocols/application-default-credentials
* Application Default Credentials}, your project ID will be detected
* automatically.
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the
Expand Down Expand Up @@ -144,10 +143,8 @@ export class {{ service.name }}Client {

// Determine the client header string.
const clientHeader = [
`grpc/${gaxGrpc.grpcVersion}`,
`gax/${gaxModule.version}`,
`gapic/${version}`,
`gl-web/${gaxModule.version}`
];
if (typeof process !== 'undefined' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
Expand Down Expand Up @@ -255,14 +252,16 @@ export class {{ service.name }}Client {
this._innerApiCalls = {};

// Put together the "service stub" for
// google.showcase.v1alpha2.Echo.
// {{api.naming.protoPackage}}.{{ service.name }}.
const {{ service.name.toCamelCase() }}Stub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('{{api.naming.protoPackage}}.{{ service.name }}') :
// tslint:disable-next-line no-any
(protos as any).{{api.naming.protoPackage}}.{{ service.name }},
opts) as Promise<{[method: string]: Function}>;

// Iterate over each of the methods that the service provides
// and create an API call method for each.
const {{ service.name.toCamelCase() }}StubMethods =
[
{%- set stubMethodsJoiner = joiner(', ') -%}
Expand All @@ -281,7 +280,7 @@ export class {{ service.name }}Client {
throw err;
});

this._innerApiCalls[methodName] = gax.createApiCall(
this._innerApiCalls[methodName] = gaxModule.createApiCall(
innerCallPromise,
defaults[methodName],
this._descriptors.page[methodName] ||
Expand All @@ -290,12 +289,14 @@ export class {{ service.name }}Client {
);
}
}

/**
* The DNS address for this API service.
*/
static get servicePath() {
return '{{ api.hostName }}';
}

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
Expand Down Expand Up @@ -329,13 +330,13 @@ export class {{ service.name }}Client {
{%- endif %}
}

getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
/**
* Return the project ID used by this class.
* @param {function(Error, string)} callback - the callback to
* be called with the current project Id.
*/
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
getProjectId(callback?: Callback<string, undefined, undefined>):
Promise<string>|void {
if (callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,21 @@ export interface PaginationResponse<
rawResponse?: ResponseObject;
}


/**
* Google Cloud Key Management Service
*
* Manages cryptographic keys and operations using those keys. Implements a REST
* model with the following objects:
*
* * [KeyRing][google.cloud.kms.v1.KeyRing]
* * [CryptoKey][google.cloud.kms.v1.CryptoKey]
* * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
*
* If you are using manual gRPC libraries, see
* [Using gRPC with Cloud KMS](https://cloud.google.com/kms/docs/grpc).
*/
export class KeyManagementServiceClient {
/**
* Google Cloud Key Management Service
*
* Manages cryptographic keys and operations using those keys. Implements a REST
* model with the following objects:
*
* * [KeyRing][google.cloud.kms.v1.KeyRing]
* * [CryptoKey][google.cloud.kms.v1.CryptoKey]
* * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
*
* If you are using manual gRPC libraries, see
* [Using gRPC with Cloud KMS](https://cloud.google.com/kms/docs/grpc).
*/
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;
Expand All @@ -99,10 +100,8 @@ export class KeyManagementServiceClient {
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@@link
* https://developers.google.com/identity/protocols/application-default-credentials
* Application Default Credentials}, your project ID will be detected
* automatically.
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the
Expand Down Expand Up @@ -144,10 +143,8 @@ export class KeyManagementServiceClient {

// Determine the client header string.
const clientHeader = [
`grpc/${gaxGrpc.grpcVersion}`,
`gax/${gaxModule.version}`,
`gapic/${version}`,
`gl-web/${gaxModule.version}`
];
if (typeof process !== 'undefined' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
Expand Down Expand Up @@ -196,14 +193,16 @@ export class KeyManagementServiceClient {
this._innerApiCalls = {};

// Put together the "service stub" for
// google.showcase.v1alpha2.Echo.
// google.cloud.kms.v1.KeyManagementService.
const keyManagementServiceStub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('google.cloud.kms.v1.KeyManagementService') :
// tslint:disable-next-line no-any
(protos as any).google.cloud.kms.v1.KeyManagementService,
opts) as Promise<{[method: string]: Function}>;

// Iterate over each of the methods that the service provides
// and create an API call method for each.
const keyManagementServiceStubMethods =
['listKeyRings', 'listCryptoKeys', 'listCryptoKeyVersions', 'listImportJobs', 'getKeyRing', 'getCryptoKey', 'getCryptoKeyVersion', 'getPublicKey', 'getImportJob', 'createKeyRing', 'createCryptoKey', 'createCryptoKeyVersion', 'importCryptoKeyVersion', 'createImportJob', 'updateCryptoKey', 'updateCryptoKeyVersion', 'encrypt', 'decrypt', 'asymmetricSign', 'asymmetricDecrypt', 'updateCryptoKeyPrimaryVersion', 'destroyCryptoKeyVersion', 'restoreCryptoKeyVersion'];

Expand All @@ -216,7 +215,7 @@ export class KeyManagementServiceClient {
throw err;
});

this._innerApiCalls[methodName] = gax.createApiCall(
this._innerApiCalls[methodName] = gaxModule.createApiCall(
innerCallPromise,
defaults[methodName],
this._descriptors.page[methodName] ||
Expand All @@ -225,12 +224,14 @@ export class KeyManagementServiceClient {
);
}
}

/**
* The DNS address for this API service.
*/
static get servicePath() {
return 'cloudkms.googleapis.com';
}

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
Expand All @@ -257,13 +258,13 @@ export class KeyManagementServiceClient {
];
}

getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
/**
* Return the project ID used by this class.
* @param {function(Error, string)} callback - the callback to
* be called with the current project Id.
*/
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
getProjectId(callback?: Callback<string, undefined, undefined>):
Promise<string>|void {
if (callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ export interface PaginationResponse<
rawResponse?: ResponseObject;
}


/**
* This service is used showcase the four main types of rpcs - unary, server
* side streaming, client side streaming, and bidirectional streaming. This
* service also exposes methods that explicitly implement server delay, and
* paginated calls.
*/
export class EchoClient {
/**
* This service is used showcase the four main types of rpcs - unary, server
* side streaming, client side streaming, and bidirectional streaming. This
* service also exposes methods that explicitly implement server delay, and
* paginated calls.
*/
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;
Expand All @@ -95,10 +96,8 @@ export class EchoClient {
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@@link
* https://developers.google.com/identity/protocols/application-default-credentials
* Application Default Credentials}, your project ID will be detected
* automatically.
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the
Expand Down Expand Up @@ -140,10 +139,8 @@ export class EchoClient {

// Determine the client header string.
const clientHeader = [
`grpc/${gaxGrpc.grpcVersion}`,
`gax/${gaxModule.version}`,
`gapic/${version}`,
`gl-web/${gaxModule.version}`
];
if (typeof process !== 'undefined' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
Expand Down Expand Up @@ -217,14 +214,16 @@ export class EchoClient {
this._innerApiCalls = {};

// Put together the "service stub" for
// google.showcase.v1alpha2.Echo.
// google.showcase.v1beta1.Echo.
const echoStub = gaxGrpc.createStub(
opts.fallback ?
(protos as protobuf.Root).lookupService('google.showcase.v1beta1.Echo') :
// tslint:disable-next-line no-any
(protos as any).google.showcase.v1beta1.Echo,
opts) as Promise<{[method: string]: Function}>;

// Iterate over each of the methods that the service provides
// and create an API call method for each.
const echoStubMethods =
['echo', 'expand', 'collect', 'chat', 'pagedExpand', 'wait'];

Expand All @@ -237,7 +236,7 @@ export class EchoClient {
throw err;
});

this._innerApiCalls[methodName] = gax.createApiCall(
this._innerApiCalls[methodName] = gaxModule.createApiCall(
innerCallPromise,
defaults[methodName],
this._descriptors.page[methodName] ||
Expand All @@ -246,12 +245,14 @@ export class EchoClient {
);
}
}

/**
* The DNS address for this API service.
*/
static get servicePath() {
return 'localhost';
}

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
Expand All @@ -275,13 +276,13 @@ export class EchoClient {
return [];
}

getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
/**
* Return the project ID used by this class.
* @param {function(Error, string)} callback - the callback to
* be called with the current project Id.
*/
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
getProjectId(callback?: Callback<string, undefined, undefined>):
Promise<string>|void {
if (callback) {
Expand Down

0 comments on commit 4909e3c

Please sign in to comment.