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

fix(protos): use require to load protos JSON #861

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 4 additions & 15 deletions baselines/asset/src/v1/asset_service_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'go
import * as path from 'path';

import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v1/asset_service_client_config.json`.
Expand Down Expand Up @@ -137,16 +138,7 @@ export class AssetServiceClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand All @@ -163,14 +155,11 @@ export class AssetServiceClient {
),
};

const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback ?
this._gaxModule.protobuf.Root.fromJSON(
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);

this.operationsClient = this._gaxModule.lro({
auth: this.auth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v1beta1/big_query_storage_client_config.json`.
Expand Down Expand Up @@ -138,16 +139,7 @@ export class BigQueryStorageClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down
19 changes: 4 additions & 15 deletions baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v1beta1/echo_client_config.json`.
Expand Down Expand Up @@ -143,16 +144,7 @@ export class EchoClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down Expand Up @@ -203,14 +195,11 @@ export class EchoClient {
chat: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING)
};

const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback ?
this._gaxModule.protobuf.Root.fromJSON(
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);

this.operationsClient = this._gaxModule.lro({
auth: this.auth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v1beta1/identity_client_config.json`.
Expand Down Expand Up @@ -138,16 +139,7 @@ export class IdentityClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v1beta1/messaging_client_config.json`.
Expand Down Expand Up @@ -142,16 +143,7 @@ export class MessagingClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down Expand Up @@ -204,14 +196,11 @@ export class MessagingClient {
connect: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING)
};

const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback ?
this._gaxModule.protobuf.Root.fromJSON(
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);

this.operationsClient = this._gaxModule.lro({
auth: this.auth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v1beta1/testing_client_config.json`.
Expand Down Expand Up @@ -139,16 +140,7 @@ export class TestingClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down
12 changes: 2 additions & 10 deletions baselines/dlp/src/v2/dlp_service_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v2/dlp_service_client_config.json`.
Expand Down Expand Up @@ -146,16 +147,7 @@ export class DlpServiceClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down
12 changes: 2 additions & 10 deletions baselines/kms/src/v1/key_management_service_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v1/key_management_service_client_config.json`.
Expand Down Expand Up @@ -150,16 +151,7 @@ export class KeyManagementServiceClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// Some of the methods on this service return "paged" results,
// (e.g. 50 results at a time, with tokens to get subsequent
Expand Down
12 changes: 2 additions & 10 deletions baselines/logging/src/v2/config_service_v2_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v2/config_service_v2_client_config.json`.
Expand Down Expand Up @@ -138,16 +139,7 @@ export class ConfigServiceV2Client {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down
21 changes: 3 additions & 18 deletions baselines/logging/src/v2/logging_service_v2_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v2/logging_service_v2_client_config.json`.
Expand Down Expand Up @@ -138,16 +139,7 @@ export class LoggingServiceV2Client {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down Expand Up @@ -233,14 +225,7 @@ export class LoggingServiceV2Client {
new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'logNames')
};

// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback ?
this._gaxModule.protobuf.Root.fromJSON(
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// Some methods on this API support automatically batching
// requests; denote this.
Expand Down
12 changes: 2 additions & 10 deletions baselines/logging/src/v2/metrics_service_v2_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v2/metrics_service_v2_client_config.json`.
Expand Down Expand Up @@ -138,16 +139,7 @@ export class MetricsServiceV2Client {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as path from 'path';
import { Transform } from 'stream';
import { RequestType } from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v3/alert_policy_service_client_config.json`.
Expand Down Expand Up @@ -146,16 +147,7 @@ export class AlertPolicyServiceClient {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(
opts.fallback ?
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../../protos/protos.json") :
nodejsProtoPath
);
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
Expand Down
Loading