@google-cloud/bigquery-storage-api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +111 -0
  2. package/build/protos/google/cloud/bigquery/storage/v1/annotations.proto +28 -0
  3. package/build/protos/google/cloud/bigquery/storage/v1/arrow.proto +89 -0
  4. package/build/protos/google/cloud/bigquery/storage/v1/avro.proto +81 -0
  5. package/build/protos/google/cloud/bigquery/storage/v1/protobuf.proto +48 -0
  6. package/build/protos/google/cloud/bigquery/storage/v1/storage.proto +786 -0
  7. package/build/protos/google/cloud/bigquery/storage/v1/stream.proto +335 -0
  8. package/build/protos/google/cloud/bigquery/storage/v1/table.proto +200 -0
  9. package/build/protos/protos.d.ts +12699 -0
  10. package/build/protos/protos.js +1 -0
  11. package/build/protos/protos.json +1 -0
  12. package/build/src/index.d.ts +14 -0
  13. package/build/src/index.js +30 -0
  14. package/build/src/index.js.map +1 -0
  15. package/build/src/v1/big_query_read_client.d.ts +424 -0
  16. package/build/src/v1/big_query_read_client.js +689 -0
  17. package/build/src/v1/big_query_read_client.js.map +1 -0
  18. package/build/src/v1/big_query_read_client_config.json +44 -0
  19. package/build/src/v1/big_query_read_proto_list.json +9 -0
  20. package/build/src/v1/big_query_write_client.d.ts +486 -0
  21. package/build/src/v1/big_query_write_client.js +835 -0
  22. package/build/src/v1/big_query_write_client.js.map +1 -0
  23. package/build/src/v1/big_query_write_client_config.json +73 -0
  24. package/build/src/v1/big_query_write_proto_list.json +9 -0
  25. package/build/src/v1/gapic_metadata.json +117 -0
  26. package/build/src/v1/index.d.ts +2 -0
  27. package/build/src/v1/index.js +25 -0
  28. package/build/src/v1/index.js.map +1 -0
  29. package/package.json +66 -0
@@ -0,0 +1,689 @@
1
+ "use strict";
2
+ // Copyright 2026 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.BigQueryReadClient = void 0;
21
+ const stream_1 = require("stream");
22
+ const jsonProtos = require("../../protos/protos.json");
23
+ const google_gax_1 = require("google-gax");
24
+ /**
25
+ * Client JSON configuration object, loaded from
26
+ * `src/v1/big_query_read_client_config.json`.
27
+ * This file defines retry strategy and timeouts for all API methods in this library.
28
+ */
29
+ const gapicConfig = require("./big_query_read_client_config.json");
30
+ const version = require('../../../package.json').version;
31
+ /**
32
+ * BigQuery Read API.
33
+ *
34
+ * The Read API can be used to read data from BigQuery.
35
+ * @class
36
+ * @memberof v1
37
+ */
38
+ class BigQueryReadClient {
39
+ _terminated = false;
40
+ _opts;
41
+ _providedCustomServicePath;
42
+ _gaxModule;
43
+ _gaxGrpc;
44
+ _protos;
45
+ _defaults;
46
+ _universeDomain;
47
+ _servicePath;
48
+ _log = google_gax_1.loggingUtils.log('bigquery-storage-api');
49
+ auth;
50
+ descriptors = {
51
+ page: {},
52
+ stream: {},
53
+ longrunning: {},
54
+ batching: {},
55
+ };
56
+ warn;
57
+ innerApiCalls;
58
+ pathTemplates;
59
+ bigQueryReadStub;
60
+ /**
61
+ * Construct an instance of BigQueryReadClient.
62
+ *
63
+ * @param {object} [options] - The configuration object.
64
+ * The options accepted by the constructor are described in detail
65
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
66
+ * The common options are:
67
+ * @param {object} [options.credentials] - Credentials object.
68
+ * @param {string} [options.credentials.client_email]
69
+ * @param {string} [options.credentials.private_key]
70
+ * @param {string} [options.email] - Account email address. Required when
71
+ * using a .pem or .p12 keyFilename.
72
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
73
+ * .p12 key downloaded from the Google Developers Console. If you provide
74
+ * a path to a JSON file, the projectId option below is not necessary.
75
+ * NOTE: .pem and .p12 require you to specify options.email as well.
76
+ * @param {number} [options.port] - The port on which to connect to
77
+ * the remote host.
78
+ * @param {string} [options.projectId] - The project ID from the Google
79
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
80
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
81
+ * app is running in an environment which supports
82
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
83
+ * your project ID will be detected automatically.
84
+ * @param {string} [options.apiEndpoint] - The domain name of the
85
+ * API remote host.
86
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
87
+ * Follows the structure of {@link gapicConfig}.
88
+ * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
89
+ * For more information, please check the
90
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
91
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
92
+ * need to avoid loading the default gRPC version and want to use the fallback
93
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
94
+ * ```
95
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
96
+ * const client = new BigQueryReadClient({fallback: true}, gax);
97
+ * ```
98
+ */
99
+ constructor(opts, gaxInstance) {
100
+ // Ensure that options include all the required fields.
101
+ const staticMembers = this.constructor;
102
+ if (opts?.universe_domain &&
103
+ opts?.universeDomain &&
104
+ opts?.universe_domain !== opts?.universeDomain) {
105
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
106
+ }
107
+ const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
108
+ ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
109
+ : undefined;
110
+ this._universeDomain =
111
+ opts?.universeDomain ??
112
+ opts?.universe_domain ??
113
+ universeDomainEnvVar ??
114
+ 'googleapis.com';
115
+ this._servicePath = 'bigquerystorage.' + this._universeDomain;
116
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
117
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
118
+ const port = opts?.port || staticMembers.port;
119
+ const clientConfig = opts?.clientConfig ?? {};
120
+ const fallback = opts?.fallback ??
121
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
122
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
123
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
124
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
125
+ opts['scopes'] = staticMembers.scopes;
126
+ }
127
+ // Load google-gax module synchronously if needed
128
+ if (!gaxInstance) {
129
+ gaxInstance = require('google-gax');
130
+ }
131
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
132
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
133
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
134
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
135
+ // Save options to use in initialize() method.
136
+ this._opts = opts;
137
+ // Save the auth object to the client, for use by other methods.
138
+ this.auth = this._gaxGrpc.auth;
139
+ // Set useJWTAccessWithScope on the auth object.
140
+ this.auth.useJWTAccessWithScope = true;
141
+ // Set defaultServicePath on the auth object.
142
+ this.auth.defaultServicePath = this._servicePath;
143
+ // Set the default scopes in auth client if needed.
144
+ if (servicePath === this._servicePath) {
145
+ this.auth.defaultScopes = staticMembers.scopes;
146
+ }
147
+ // Determine the client header string.
148
+ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
149
+ if (typeof process === 'object' && 'versions' in process) {
150
+ clientHeader.push(`gl-node/${process.versions.node}`);
151
+ }
152
+ else {
153
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
154
+ }
155
+ if (!opts.fallback) {
156
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
157
+ }
158
+ else {
159
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
160
+ }
161
+ if (opts.libName && opts.libVersion) {
162
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
163
+ }
164
+ // Load the applicable protos.
165
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
166
+ // This API contains "path templates"; forward-slash-separated
167
+ // identifiers to uniquely identify resources within the API.
168
+ // Create useful helper objects for these.
169
+ this.pathTemplates = {
170
+ projectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}'),
171
+ readSessionPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/sessions/{session}'),
172
+ readStreamPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/sessions/{session}/streams/{stream}'),
173
+ tablePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/datasets/{dataset}/tables/{table}'),
174
+ writeStreamPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}'),
175
+ };
176
+ // Some of the methods on this service provide streaming responses.
177
+ // Provide descriptors for these.
178
+ this.descriptors.stream = {
179
+ readRows: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
180
+ };
181
+ // Put together the default options sent with requests.
182
+ this._defaults = this._gaxGrpc.constructSettings('google.cloud.bigquery.storage.v1.BigQueryRead', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
183
+ // Set up a dictionary of "inner API calls"; the core implementation
184
+ // of calling the API is handled in `google-gax`, with this code
185
+ // merely providing the destination and request information.
186
+ this.innerApiCalls = {};
187
+ // Add a warn function to the client constructor so it can be easily tested.
188
+ this.warn = this._gaxModule.warn;
189
+ }
190
+ /**
191
+ * Initialize the client.
192
+ * Performs asynchronous operations (such as authentication) and prepares the client.
193
+ * This function will be called automatically when any class method is called for the
194
+ * first time, but if you need to initialize it before calling an actual method,
195
+ * feel free to call initialize() directly.
196
+ *
197
+ * You can await on this method if you want to make sure the client is initialized.
198
+ *
199
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
200
+ */
201
+ initialize() {
202
+ // If the client stub promise is already initialized, return immediately.
203
+ if (this.bigQueryReadStub) {
204
+ return this.bigQueryReadStub;
205
+ }
206
+ // Put together the "service stub" for
207
+ // google.cloud.bigquery.storage.v1.BigQueryRead.
208
+ this.bigQueryReadStub = this._gaxGrpc.createStub(this._opts.fallback
209
+ ? this._protos.lookupService('google.cloud.bigquery.storage.v1.BigQueryRead')
210
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
211
+ this._protos.google.cloud.bigquery.storage.v1.BigQueryRead, this._opts, this._providedCustomServicePath);
212
+ // Iterate over each of the methods that the service provides
213
+ // and create an API call method for each.
214
+ const bigQueryReadStubMethods = [
215
+ 'createReadSession',
216
+ 'readRows',
217
+ 'splitReadStream',
218
+ ];
219
+ for (const methodName of bigQueryReadStubMethods) {
220
+ const callPromise = this.bigQueryReadStub.then((stub) => (...args) => {
221
+ if (this._terminated) {
222
+ if (methodName in this.descriptors.stream) {
223
+ const stream = new stream_1.PassThrough({ objectMode: true });
224
+ setImmediate(() => {
225
+ stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
226
+ });
227
+ return stream;
228
+ }
229
+ return Promise.reject('The client has already been closed.');
230
+ }
231
+ const func = stub[methodName];
232
+ return func.apply(stub, args);
233
+ }, (err) => () => {
234
+ throw err;
235
+ });
236
+ const descriptor = this.descriptors.stream[methodName] || undefined;
237
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
238
+ this.innerApiCalls[methodName] = apiCall;
239
+ }
240
+ return this.bigQueryReadStub;
241
+ }
242
+ /**
243
+ * The DNS address for this API service.
244
+ * @deprecated Use the apiEndpoint method of the client instance.
245
+ * @returns {string} The DNS address for this service.
246
+ */
247
+ static get servicePath() {
248
+ if (typeof process === 'object' &&
249
+ typeof process.emitWarning === 'function') {
250
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
251
+ }
252
+ return 'bigquerystorage.googleapis.com';
253
+ }
254
+ /**
255
+ * The DNS address for this API service - same as servicePath.
256
+ * @deprecated Use the apiEndpoint method of the client instance.
257
+ * @returns {string} The DNS address for this service.
258
+ */
259
+ static get apiEndpoint() {
260
+ if (typeof process === 'object' &&
261
+ typeof process.emitWarning === 'function') {
262
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
263
+ }
264
+ return 'bigquerystorage.googleapis.com';
265
+ }
266
+ /**
267
+ * The DNS address for this API service.
268
+ * @returns {string} The DNS address for this service.
269
+ */
270
+ get apiEndpoint() {
271
+ return this._servicePath;
272
+ }
273
+ get universeDomain() {
274
+ return this._universeDomain;
275
+ }
276
+ /**
277
+ * The port for this API service.
278
+ * @returns {number} The default port for this service.
279
+ */
280
+ static get port() {
281
+ return 443;
282
+ }
283
+ /**
284
+ * The scopes needed to make gRPC calls for every method defined
285
+ * in this service.
286
+ * @returns {string[]} List of default scopes.
287
+ */
288
+ static get scopes() {
289
+ return [
290
+ 'https://www.googleapis.com/auth/bigquery',
291
+ 'https://www.googleapis.com/auth/cloud-platform',
292
+ ];
293
+ }
294
+ /**
295
+ * Return the project ID used by this class.
296
+ * @returns {Promise} A promise that resolves to string containing the project ID.
297
+ */
298
+ getProjectId(callback) {
299
+ if (callback) {
300
+ this.auth.getProjectId(callback);
301
+ return;
302
+ }
303
+ return this.auth.getProjectId();
304
+ }
305
+ createReadSession(request, optionsOrCallback, callback) {
306
+ request = request || {};
307
+ let options;
308
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
309
+ callback = optionsOrCallback;
310
+ options = {};
311
+ }
312
+ else {
313
+ options = optionsOrCallback;
314
+ }
315
+ options = options || {};
316
+ options.otherArgs = options.otherArgs || {};
317
+ options.otherArgs.headers = options.otherArgs.headers || {};
318
+ options.otherArgs.headers['x-goog-request-params'] =
319
+ this._gaxModule.routingHeader.fromParams({
320
+ 'read_session.table': request.readSession.table ?? '',
321
+ });
322
+ this.initialize().catch((err) => {
323
+ throw err;
324
+ });
325
+ this._log.info('createReadSession request %j', request);
326
+ const wrappedCallback = callback
327
+ ? (error, response, options, rawResponse) => {
328
+ this._log.info('createReadSession response %j', response);
329
+ callback(error, response, options, rawResponse); // We verified callback above.
330
+ }
331
+ : undefined;
332
+ return this.innerApiCalls
333
+ .createReadSession(request, options, wrappedCallback)
334
+ ?.then(([response, options, rawResponse]) => {
335
+ this._log.info('createReadSession response %j', response);
336
+ return [response, options, rawResponse];
337
+ })
338
+ .catch((error) => {
339
+ if (error &&
340
+ 'statusDetails' in error &&
341
+ error.statusDetails instanceof Array) {
342
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
343
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
344
+ }
345
+ throw error;
346
+ });
347
+ }
348
+ splitReadStream(request, optionsOrCallback, callback) {
349
+ request = request || {};
350
+ let options;
351
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
352
+ callback = optionsOrCallback;
353
+ options = {};
354
+ }
355
+ else {
356
+ options = optionsOrCallback;
357
+ }
358
+ options = options || {};
359
+ options.otherArgs = options.otherArgs || {};
360
+ options.otherArgs.headers = options.otherArgs.headers || {};
361
+ options.otherArgs.headers['x-goog-request-params'] =
362
+ this._gaxModule.routingHeader.fromParams({
363
+ name: request.name ?? '',
364
+ });
365
+ this.initialize().catch((err) => {
366
+ throw err;
367
+ });
368
+ this._log.info('splitReadStream request %j', request);
369
+ const wrappedCallback = callback
370
+ ? (error, response, options, rawResponse) => {
371
+ this._log.info('splitReadStream response %j', response);
372
+ callback(error, response, options, rawResponse); // We verified callback above.
373
+ }
374
+ : undefined;
375
+ return this.innerApiCalls
376
+ .splitReadStream(request, options, wrappedCallback)
377
+ ?.then(([response, options, rawResponse]) => {
378
+ this._log.info('splitReadStream response %j', response);
379
+ return [response, options, rawResponse];
380
+ })
381
+ .catch((error) => {
382
+ if (error &&
383
+ 'statusDetails' in error &&
384
+ error.statusDetails instanceof Array) {
385
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
386
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
387
+ }
388
+ throw error;
389
+ });
390
+ }
391
+ /**
392
+ * Reads rows from the stream in the format prescribed by the ReadSession.
393
+ * Each response contains one or more table rows, up to a maximum of 128 MB
394
+ * per response; read requests which attempt to read individual rows larger
395
+ * than 128 MB will fail.
396
+ *
397
+ * Each request also returns a set of stream statistics reflecting the current
398
+ * state of the stream.
399
+ *
400
+ * @param {Object} request
401
+ * The request object that will be sent.
402
+ * @param {string} request.readStream
403
+ * Required. Stream to read rows from.
404
+ * @param {number} request.offset
405
+ * The offset requested must be less than the last row read from Read.
406
+ * Requesting a larger offset is undefined. If not specified, start reading
407
+ * from offset zero.
408
+ * @param {object} [options]
409
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
410
+ * @returns {Stream}
411
+ * An object stream which emits {@link protos.google.cloud.bigquery.storage.v1.ReadRowsResponse|ReadRowsResponse} on 'data' event.
412
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
413
+ * for more details and examples.
414
+ * @example <caption>include:samples/generated/v1/big_query_read.read_rows.js</caption>
415
+ * region_tag:bigquerystorage_v1_generated_BigQueryRead_ReadRows_async
416
+ */
417
+ readRows(request, options) {
418
+ request = request || {};
419
+ options = options || {};
420
+ options.otherArgs = options.otherArgs || {};
421
+ options.otherArgs.headers = options.otherArgs.headers || {};
422
+ options.otherArgs.headers['x-goog-request-params'] =
423
+ this._gaxModule.routingHeader.fromParams({
424
+ read_stream: request.readStream ?? '',
425
+ });
426
+ this.initialize().catch((err) => {
427
+ throw err;
428
+ });
429
+ this._log.info('readRows stream %j', options);
430
+ return this.innerApiCalls.readRows(request, options);
431
+ }
432
+ // --------------------
433
+ // -- Path templates --
434
+ // --------------------
435
+ /**
436
+ * Return a fully-qualified project resource name string.
437
+ *
438
+ * @param {string} project
439
+ * @returns {string} Resource name string.
440
+ */
441
+ projectPath(project) {
442
+ return this.pathTemplates.projectPathTemplate.render({
443
+ project: project,
444
+ });
445
+ }
446
+ /**
447
+ * Parse the project from Project resource.
448
+ *
449
+ * @param {string} projectName
450
+ * A fully-qualified path representing Project resource.
451
+ * @returns {string} A string representing the project.
452
+ */
453
+ matchProjectFromProjectName(projectName) {
454
+ return this.pathTemplates.projectPathTemplate.match(projectName).project;
455
+ }
456
+ /**
457
+ * Return a fully-qualified readSession resource name string.
458
+ *
459
+ * @param {string} project
460
+ * @param {string} location
461
+ * @param {string} session
462
+ * @returns {string} Resource name string.
463
+ */
464
+ readSessionPath(project, location, session) {
465
+ return this.pathTemplates.readSessionPathTemplate.render({
466
+ project: project,
467
+ location: location,
468
+ session: session,
469
+ });
470
+ }
471
+ /**
472
+ * Parse the project from ReadSession resource.
473
+ *
474
+ * @param {string} readSessionName
475
+ * A fully-qualified path representing ReadSession resource.
476
+ * @returns {string} A string representing the project.
477
+ */
478
+ matchProjectFromReadSessionName(readSessionName) {
479
+ return this.pathTemplates.readSessionPathTemplate.match(readSessionName)
480
+ .project;
481
+ }
482
+ /**
483
+ * Parse the location from ReadSession resource.
484
+ *
485
+ * @param {string} readSessionName
486
+ * A fully-qualified path representing ReadSession resource.
487
+ * @returns {string} A string representing the location.
488
+ */
489
+ matchLocationFromReadSessionName(readSessionName) {
490
+ return this.pathTemplates.readSessionPathTemplate.match(readSessionName)
491
+ .location;
492
+ }
493
+ /**
494
+ * Parse the session from ReadSession resource.
495
+ *
496
+ * @param {string} readSessionName
497
+ * A fully-qualified path representing ReadSession resource.
498
+ * @returns {string} A string representing the session.
499
+ */
500
+ matchSessionFromReadSessionName(readSessionName) {
501
+ return this.pathTemplates.readSessionPathTemplate.match(readSessionName)
502
+ .session;
503
+ }
504
+ /**
505
+ * Return a fully-qualified readStream resource name string.
506
+ *
507
+ * @param {string} project
508
+ * @param {string} location
509
+ * @param {string} session
510
+ * @param {string} stream
511
+ * @returns {string} Resource name string.
512
+ */
513
+ readStreamPath(project, location, session, stream) {
514
+ return this.pathTemplates.readStreamPathTemplate.render({
515
+ project: project,
516
+ location: location,
517
+ session: session,
518
+ stream: stream,
519
+ });
520
+ }
521
+ /**
522
+ * Parse the project from ReadStream resource.
523
+ *
524
+ * @param {string} readStreamName
525
+ * A fully-qualified path representing ReadStream resource.
526
+ * @returns {string} A string representing the project.
527
+ */
528
+ matchProjectFromReadStreamName(readStreamName) {
529
+ return this.pathTemplates.readStreamPathTemplate.match(readStreamName)
530
+ .project;
531
+ }
532
+ /**
533
+ * Parse the location from ReadStream resource.
534
+ *
535
+ * @param {string} readStreamName
536
+ * A fully-qualified path representing ReadStream resource.
537
+ * @returns {string} A string representing the location.
538
+ */
539
+ matchLocationFromReadStreamName(readStreamName) {
540
+ return this.pathTemplates.readStreamPathTemplate.match(readStreamName)
541
+ .location;
542
+ }
543
+ /**
544
+ * Parse the session from ReadStream resource.
545
+ *
546
+ * @param {string} readStreamName
547
+ * A fully-qualified path representing ReadStream resource.
548
+ * @returns {string} A string representing the session.
549
+ */
550
+ matchSessionFromReadStreamName(readStreamName) {
551
+ return this.pathTemplates.readStreamPathTemplate.match(readStreamName)
552
+ .session;
553
+ }
554
+ /**
555
+ * Parse the stream from ReadStream resource.
556
+ *
557
+ * @param {string} readStreamName
558
+ * A fully-qualified path representing ReadStream resource.
559
+ * @returns {string} A string representing the stream.
560
+ */
561
+ matchStreamFromReadStreamName(readStreamName) {
562
+ return this.pathTemplates.readStreamPathTemplate.match(readStreamName)
563
+ .stream;
564
+ }
565
+ /**
566
+ * Return a fully-qualified table resource name string.
567
+ *
568
+ * @param {string} project
569
+ * @param {string} dataset
570
+ * @param {string} table
571
+ * @returns {string} Resource name string.
572
+ */
573
+ tablePath(project, dataset, table) {
574
+ return this.pathTemplates.tablePathTemplate.render({
575
+ project: project,
576
+ dataset: dataset,
577
+ table: table,
578
+ });
579
+ }
580
+ /**
581
+ * Parse the project from Table resource.
582
+ *
583
+ * @param {string} tableName
584
+ * A fully-qualified path representing Table resource.
585
+ * @returns {string} A string representing the project.
586
+ */
587
+ matchProjectFromTableName(tableName) {
588
+ return this.pathTemplates.tablePathTemplate.match(tableName).project;
589
+ }
590
+ /**
591
+ * Parse the dataset from Table resource.
592
+ *
593
+ * @param {string} tableName
594
+ * A fully-qualified path representing Table resource.
595
+ * @returns {string} A string representing the dataset.
596
+ */
597
+ matchDatasetFromTableName(tableName) {
598
+ return this.pathTemplates.tablePathTemplate.match(tableName).dataset;
599
+ }
600
+ /**
601
+ * Parse the table from Table resource.
602
+ *
603
+ * @param {string} tableName
604
+ * A fully-qualified path representing Table resource.
605
+ * @returns {string} A string representing the table.
606
+ */
607
+ matchTableFromTableName(tableName) {
608
+ return this.pathTemplates.tablePathTemplate.match(tableName).table;
609
+ }
610
+ /**
611
+ * Return a fully-qualified writeStream resource name string.
612
+ *
613
+ * @param {string} project
614
+ * @param {string} dataset
615
+ * @param {string} table
616
+ * @param {string} stream
617
+ * @returns {string} Resource name string.
618
+ */
619
+ writeStreamPath(project, dataset, table, stream) {
620
+ return this.pathTemplates.writeStreamPathTemplate.render({
621
+ project: project,
622
+ dataset: dataset,
623
+ table: table,
624
+ stream: stream,
625
+ });
626
+ }
627
+ /**
628
+ * Parse the project from WriteStream resource.
629
+ *
630
+ * @param {string} writeStreamName
631
+ * A fully-qualified path representing WriteStream resource.
632
+ * @returns {string} A string representing the project.
633
+ */
634
+ matchProjectFromWriteStreamName(writeStreamName) {
635
+ return this.pathTemplates.writeStreamPathTemplate.match(writeStreamName)
636
+ .project;
637
+ }
638
+ /**
639
+ * Parse the dataset from WriteStream resource.
640
+ *
641
+ * @param {string} writeStreamName
642
+ * A fully-qualified path representing WriteStream resource.
643
+ * @returns {string} A string representing the dataset.
644
+ */
645
+ matchDatasetFromWriteStreamName(writeStreamName) {
646
+ return this.pathTemplates.writeStreamPathTemplate.match(writeStreamName)
647
+ .dataset;
648
+ }
649
+ /**
650
+ * Parse the table from WriteStream resource.
651
+ *
652
+ * @param {string} writeStreamName
653
+ * A fully-qualified path representing WriteStream resource.
654
+ * @returns {string} A string representing the table.
655
+ */
656
+ matchTableFromWriteStreamName(writeStreamName) {
657
+ return this.pathTemplates.writeStreamPathTemplate.match(writeStreamName)
658
+ .table;
659
+ }
660
+ /**
661
+ * Parse the stream from WriteStream resource.
662
+ *
663
+ * @param {string} writeStreamName
664
+ * A fully-qualified path representing WriteStream resource.
665
+ * @returns {string} A string representing the stream.
666
+ */
667
+ matchStreamFromWriteStreamName(writeStreamName) {
668
+ return this.pathTemplates.writeStreamPathTemplate.match(writeStreamName)
669
+ .stream;
670
+ }
671
+ /**
672
+ * Terminate the gRPC channel and close the client.
673
+ *
674
+ * The client will no longer be usable and all future behavior is undefined.
675
+ * @returns {Promise} A promise that resolves when the client is closed.
676
+ */
677
+ close() {
678
+ if (this.bigQueryReadStub && !this._terminated) {
679
+ return this.bigQueryReadStub.then((stub) => {
680
+ this._log.info('ending gRPC channel');
681
+ this._terminated = true;
682
+ stub.close();
683
+ });
684
+ }
685
+ return Promise.resolve();
686
+ }
687
+ }
688
+ exports.BigQueryReadClient = BigQueryReadClient;
689
+ //# sourceMappingURL=big_query_read_client.js.map