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: allow constructors with no parameters #65

Merged
merged 30 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
168bcfa
add checking config & proto list file to baseline test
xiaozhenliu-gg5 Oct 15, 2019
e890177
restructure setup
xiaozhenliu-gg5 Oct 16, 2019
a722f93
compare all files generated
xiaozhenliu-gg5 Oct 17, 2019
70d7175
iterate output folder for multiple layers
xiaozhenliu-gg5 Oct 17, 2019
2d4887b
remove console warn
xiaozhenliu-gg5 Oct 17, 2019
1f0f721
check all baseline files are generated
xiaozhenliu-gg5 Oct 17, 2019
9ef068a
feedback
xiaozhenliu-gg5 Oct 18, 2019
6871fc8
reuse compare function to multiple proto test
xiaozhenliu-gg5 Oct 18, 2019
06ec2d3
console error & not stop the test
xiaozhenliu-gg5 Oct 18, 2019
3e14fb5
gtc check
xiaozhenliu-gg5 Oct 18, 2019
3dc7f65
typo
xiaozhenliu-gg5 Oct 18, 2019
347423a
fix
xiaozhenliu-gg5 Oct 18, 2019
31594e3
order of dependencies
alexander-fenster Oct 18, 2019
84da435
Merge branch 'master' into expand_baseline
alexander-fenster Oct 18, 2019
41f3aee
make it work after merge
alexander-fenster Oct 18, 2019
3337fb9
gts fix
alexander-fenster Oct 18, 2019
f839835
skip comparing proto file
xiaozhenliu-gg5 Oct 18, 2019
53a7abb
update config yaml
xiaozhenliu-gg5 Oct 18, 2019
002fa50
assert in test, warn in util
xiaozhenliu-gg5 Oct 18, 2019
95effad
service config & update baseline
xiaozhenliu-gg5 Oct 18, 2019
66f0c3c
Merge branch 'master' into expand_baseline
xiaozhenliu-gg5 Oct 18, 2019
20c8f6f
polish
xiaozhenliu-gg5 Oct 18, 2019
61fa0f4
Merge branch 'expand_baseline' of https://github.com/googleapis/gapic…
xiaozhenliu-gg5 Oct 18, 2019
77db89c
fix
xiaozhenliu-gg5 Oct 18, 2019
05ca5ca
fix result
xiaozhenliu-gg5 Oct 18, 2019
97d505c
Merge branch 'master' into expand_baseline
xiaozhenliu-gg5 Oct 18, 2019
b09e890
update baseline for keymanager
xiaozhenliu-gg5 Oct 18, 2019
4b723b8
feat: client constructor with no parameters
alexander-fenster Oct 21, 2019
b327d30
Merge branch 'master' into constructor-no-parameters
alexander-fenster Oct 21, 2019
1ab0a3e
merge conflict
alexander-fenster Oct 21, 2019
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
36 changes: 19 additions & 17 deletions templates/typescript_gapic/src/$version/$service_client.ts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export interface PaginationResponse<
}
{% endif %}
export class {{ service.name }}Client {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;

/**
* Construct an instance of {{ service.name }}Client.
*
Expand Down Expand Up @@ -77,13 +81,23 @@ export class {{ service.name }}Client {
* @@param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;

constructor(opts: ClientOptions) {
constructor(opts?: ClientOptions) {
// Ensure that options include the service address and port.
opts = opts || {};
const staticMembers = this.constructor as typeof {{ service.name }}Client;
const servicePath = opts && opts.servicePath ?
opts.servicePath :
((opts && opts.apiEndpoint) ? opts.apiEndpoint :
staticMembers.servicePath);
const port = opts && opts.port ? opts.port : staticMembers.port;

if (!opts) {
opts = {servicePath, port};
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;
opts.clientConfig = opts.clientConfig || {};

const isBrowser = (typeof window !== 'undefined');
if (isBrowser){
opts.fallback = true;
Expand All @@ -92,18 +106,6 @@ export class {{ service.name }}Client {
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
const servicePath =
opts.servicePath ||
opts.apiEndpoint ||
(this.constructor as typeof {{service.name}}Client).servicePath;

opts = Object.assign(
{
clientConfig: {},
port: (this.constructor as typeof {{ service.name }}Client).port,
servicePath: servicePath,
},
opts);

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export interface PaginationResponse<
}

export class KeyManagementServiceClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;

/**
* Construct an instance of KeyManagementServiceClient.
*
Expand Down Expand Up @@ -90,13 +94,23 @@ export class KeyManagementServiceClient {
* @@param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;

constructor(opts: ClientOptions) {
constructor(opts?: ClientOptions) {
// Ensure that options include the service address and port.
opts = opts || {};
const staticMembers = this.constructor as typeof KeyManagementServiceClient;
const servicePath = opts && opts.servicePath ?
opts.servicePath :
((opts && opts.apiEndpoint) ? opts.apiEndpoint :
staticMembers.servicePath);
const port = opts && opts.port ? opts.port : staticMembers.port;

if (!opts) {
opts = {servicePath, port};
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;
opts.clientConfig = opts.clientConfig || {};

const isBrowser = (typeof window !== 'undefined');
if (isBrowser){
opts.fallback = true;
Expand All @@ -105,18 +119,6 @@ export class KeyManagementServiceClient {
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
const servicePath =
opts.servicePath ||
opts.apiEndpoint ||
(this.constructor as typeof KeyManagementServiceClient).servicePath;

opts = Object.assign(
{
clientConfig: {},
port: (this.constructor as typeof KeyManagementServiceClient).port,
servicePath: servicePath,
},
opts);

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export interface PaginationResponse<
}

export class EchoClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;

/**
* Construct an instance of EchoClient.
*
Expand Down Expand Up @@ -93,13 +97,23 @@ export class EchoClient {
* @@param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _innerApiCalls: {[name: string]: Function};
auth: gax.GoogleAuth;

constructor(opts: ClientOptions) {
constructor(opts?: ClientOptions) {
// Ensure that options include the service address and port.
opts = opts || {};
const staticMembers = this.constructor as typeof EchoClient;
const servicePath = opts && opts.servicePath ?
opts.servicePath :
((opts && opts.apiEndpoint) ? opts.apiEndpoint :
staticMembers.servicePath);
const port = opts && opts.port ? opts.port : staticMembers.port;

if (!opts) {
opts = {servicePath, port};
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;
opts.clientConfig = opts.clientConfig || {};

const isBrowser = (typeof window !== 'undefined');
if (isBrowser){
opts.fallback = true;
Expand All @@ -108,18 +122,6 @@ export class EchoClient {
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
const servicePath =
opts.servicePath ||
opts.apiEndpoint ||
(this.constructor as typeof EchoClient).servicePath;

opts = Object.assign(
{
clientConfig: {},
port: (this.constructor as typeof EchoClient).port,
servicePath: servicePath,
},
opts);

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down