-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathbigtable_client.ts
1678 lines (1624 loc) · 63.7 KB
/
bigtable_client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
/* global window */
import type * as gax from 'google-gax';
import type {
Callback,
CallOptions,
Descriptors,
ClientOptions,
} from 'google-gax';
import {PassThrough} from 'stream';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
/**
* Client JSON configuration object, loaded from
* `src/v2/bigtable_client_config.json`.
* This file defines retry strategy and timeouts for all API methods in this library.
*/
import * as gapicConfig from './bigtable_client_config.json';
const version = require('../../../package.json').version;
/**
* Service for reading from and writing to existing Bigtable tables.
* @class
* @memberof v2
*/
export class BigtableClient {
private _terminated = false;
private _opts: ClientOptions;
private _providedCustomServicePath: boolean;
private _gaxModule: typeof gax | typeof gax.fallback;
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
private _protos: {};
private _defaults: {[method: string]: gax.CallSettings};
private _universeDomain: string;
private _servicePath: string;
auth: gax.GoogleAuth;
descriptors: Descriptors = {
page: {},
stream: {},
longrunning: {},
batching: {},
};
warn: (code: string, message: string, warnType?: string) => void;
innerApiCalls: {[name: string]: Function};
pathTemplates: {[name: string]: gax.PathTemplate};
bigtableStub?: Promise<{[name: string]: Function}>;
/**
* Construct an instance of BigtableClient.
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
* @param {string} [options.credentials.private_key]
* @param {string} [options.email] - Account email address. Required when
* using a .pem or .p12 keyFilename.
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
* .p12 key downloaded from the Google Developers Console. If you provide
* a path to a JSON file, the projectId option below is not necessary.
* NOTE: .pem and .p12 require you to specify options.email as well.
* @param {number} [options.port] - The port on which to connect to
* the remote host.
* @param {string} [options.projectId] - The project ID from the Google
* 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.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new BigtableClient({fallback: true}, gax);
* ```
*/
constructor(
opts?: ClientOptions,
gaxInstance?: typeof gax | typeof gax.fallback
) {
// Ensure that options include all the required fields.
const staticMembers = this.constructor as typeof BigtableClient;
if (
opts?.universe_domain &&
opts?.universeDomain &&
opts?.universe_domain !== opts?.universeDomain
) {
throw new Error(
'Please set either universe_domain or universeDomain, but not both.'
);
}
const universeDomainEnvVar =
typeof process === 'object' && typeof process.env === 'object'
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
: undefined;
this._universeDomain =
opts?.universeDomain ??
opts?.universe_domain ??
universeDomainEnvVar ??
'googleapis.com';
this._servicePath = 'bigtable.' + this._universeDomain;
const servicePath =
opts?.servicePath || opts?.apiEndpoint || this._servicePath;
this._providedCustomServicePath = !!(
opts?.servicePath || opts?.apiEndpoint
);
const port = opts?.port || staticMembers.port;
const clientConfig = opts?.clientConfig ?? {};
const fallback =
opts?.fallback ??
(typeof window !== 'undefined' && typeof window?.fetch === 'function');
opts = Object.assign({servicePath, port, clientConfig, fallback}, opts);
// Request numeric enum values if REST transport is used.
opts.numericEnums = true;
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
if (servicePath !== this._servicePath && !('scopes' in opts)) {
opts['scopes'] = staticMembers.scopes;
}
// Load google-gax module synchronously if needed
if (!gaxInstance) {
gaxInstance = require('google-gax') as typeof gax;
}
// Choose either gRPC or proto-over-HTTP implementation of google-gax.
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = this._gaxGrpc.auth as gax.GoogleAuth;
// Set useJWTAccessWithScope on the auth object.
this.auth.useJWTAccessWithScope = true;
// Set defaultServicePath on the auth object.
this.auth.defaultServicePath = this._servicePath;
// Set the default scopes in auth client if needed.
if (servicePath === this._servicePath) {
this.auth.defaultScopes = staticMembers.scopes;
}
// Determine the client header string.
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process === 'object' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
} else {
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
// Create useful helper objects for these.
this.pathTemplates = {
authorizedViewPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view}'
),
instancePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/instances/{instance}'
),
tablePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/instances/{instance}/tables/{table}'
),
};
// Some of the methods on this service provide streaming responses.
// Provide descriptors for these.
this.descriptors.stream = {
readRows: new this._gaxModule.StreamDescriptor(
this._gaxModule.StreamType.SERVER_STREAMING,
!!opts.fallback,
!!opts.gaxServerStreamingRetries
),
sampleRowKeys: new this._gaxModule.StreamDescriptor(
this._gaxModule.StreamType.SERVER_STREAMING,
!!opts.fallback,
!!opts.gaxServerStreamingRetries
),
mutateRows: new this._gaxModule.StreamDescriptor(
this._gaxModule.StreamType.SERVER_STREAMING,
!!opts.fallback,
!!opts.gaxServerStreamingRetries
),
generateInitialChangeStreamPartitions:
new this._gaxModule.StreamDescriptor(
this._gaxModule.StreamType.SERVER_STREAMING,
!!opts.fallback,
!!opts.gaxServerStreamingRetries
),
readChangeStream: new this._gaxModule.StreamDescriptor(
this._gaxModule.StreamType.SERVER_STREAMING,
!!opts.fallback,
!!opts.gaxServerStreamingRetries
),
executeQuery: new this._gaxModule.StreamDescriptor(
this._gaxModule.StreamType.SERVER_STREAMING,
!!opts.fallback,
!!opts.gaxServerStreamingRetries
),
};
// Put together the default options sent with requests.
this._defaults = this._gaxGrpc.constructSettings(
'google.bigtable.v2.Bigtable',
gapicConfig as gax.ClientConfig,
opts.clientConfig || {},
{'x-goog-api-client': clientHeader.join(' ')}
);
// Set up a dictionary of "inner API calls"; the core implementation
// of calling the API is handled in `google-gax`, with this code
// merely providing the destination and request information.
this.innerApiCalls = {};
// Add a warn function to the client constructor so it can be easily tested.
this.warn = this._gaxModule.warn;
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.bigtableStub) {
return this.bigtableStub;
}
// Put together the "service stub" for
// google.bigtable.v2.Bigtable.
this.bigtableStub = this._gaxGrpc.createStub(
this._opts.fallback
? (this._protos as protobuf.Root).lookupService(
'google.bigtable.v2.Bigtable'
)
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._protos as any).google.bigtable.v2.Bigtable,
this._opts,
this._providedCustomServicePath
) as Promise<{[method: string]: Function}>;
// Iterate over each of the methods that the service provides
// and create an API call method for each.
const bigtableStubMethods = [
'readRows',
'sampleRowKeys',
'mutateRow',
'mutateRows',
'checkAndMutateRow',
'pingAndWarm',
'readModifyWriteRow',
'generateInitialChangeStreamPartitions',
'readChangeStream',
'executeQuery',
];
for (const methodName of bigtableStubMethods) {
const callPromise = this.bigtableStub.then(
stub =>
(...args: Array<{}>) => {
if (this._terminated) {
if (methodName in this.descriptors.stream) {
const stream = new PassThrough();
setImmediate(() => {
stream.emit(
'error',
new this._gaxModule.GoogleError(
'The client has already been closed.'
)
);
});
return stream;
}
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
(err: Error | null | undefined) => () => {
throw err;
}
);
const descriptor = this.descriptors.stream[methodName] || undefined;
const apiCall = this._gaxModule.createApiCall(
callPromise,
this._defaults[methodName],
descriptor,
this._opts.fallback
);
this.innerApiCalls[methodName] = apiCall;
}
return this.bigtableStub;
}
/**
* The DNS address for this API service.
* @deprecated Use the apiEndpoint method of the client instance.
* @returns {string} The DNS address for this service.
*/
static get servicePath() {
if (
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
'Static servicePath is deprecated, please use the instance method instead.',
'DeprecationWarning'
);
}
return 'bigtable.googleapis.com';
}
/**
* The DNS address for this API service - same as servicePath.
* @deprecated Use the apiEndpoint method of the client instance.
* @returns {string} The DNS address for this service.
*/
static get apiEndpoint() {
if (
typeof process === 'object' &&
typeof process.emitWarning === 'function'
) {
process.emitWarning(
'Static apiEndpoint is deprecated, please use the instance method instead.',
'DeprecationWarning'
);
}
return 'bigtable.googleapis.com';
}
/**
* The DNS address for this API service.
* @returns {string} The DNS address for this service.
*/
get apiEndpoint() {
return this._servicePath;
}
get universeDomain() {
return this._universeDomain;
}
/**
* The port for this API service.
* @returns {number} The default port for this service.
*/
static get port() {
return 443;
}
/**
* The scopes needed to make gRPC calls for every method defined
* in this service.
* @returns {string[]} List of default scopes.
*/
static get scopes() {
return [
'https://www.googleapis.com/auth/bigtable.data',
'https://www.googleapis.com/auth/bigtable.data.readonly',
'https://www.googleapis.com/auth/cloud-bigtable.data',
'https://www.googleapis.com/auth/cloud-bigtable.data.readonly',
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/cloud-platform.read-only',
];
}
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
/**
* Return the project ID used by this class.
* @returns {Promise} A promise that resolves to string containing the project ID.
*/
getProjectId(
callback?: Callback<string, undefined, undefined>
): Promise<string> | void {
if (callback) {
this.auth.getProjectId(callback);
return;
}
return this.auth.getProjectId();
}
// -------------------
// -- Service calls --
// -------------------
/**
* Mutates a row atomically. Cells already present in the row are left
* unchanged unless explicitly changed by `mutation`.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} [request.tableName]
* Optional. The unique name of the table to which the mutation should be
* applied.
*
* Values are of the form
* `projects/<project>/instances/<instance>/tables/<table>`.
* @param {string} [request.authorizedViewName]
* Optional. The unique name of the AuthorizedView to which the mutation
* should be applied.
*
* Values are of the form
* `projects/<project>/instances/<instance>/tables/<table>/authorizedViews/<authorized_view>`.
* @param {string} request.appProfileId
* This value specifies routing for replication. If not specified, the
* "default" application profile will be used.
* @param {Buffer} request.rowKey
* Required. The key of the row to which the mutation should be applied.
* @param {number[]} request.mutations
* Required. Changes to be atomically applied to the specified row. Entries
* are applied in order, meaning that earlier mutations can be masked by later
* ones. Must contain at least one entry and at most 100000.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing {@link protos.google.bigtable.v2.MutateRowResponse|MutateRowResponse}.
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
* for more details and examples.
*/
mutateRow(
request?: protos.google.bigtable.v2.IMutateRowRequest,
options?: CallOptions
): Promise<
[
protos.google.bigtable.v2.IMutateRowResponse,
protos.google.bigtable.v2.IMutateRowRequest | undefined,
{} | undefined,
]
>;
mutateRow(
request: protos.google.bigtable.v2.IMutateRowRequest,
options: CallOptions,
callback: Callback<
protos.google.bigtable.v2.IMutateRowResponse,
protos.google.bigtable.v2.IMutateRowRequest | null | undefined,
{} | null | undefined
>
): void;
mutateRow(
request: protos.google.bigtable.v2.IMutateRowRequest,
callback: Callback<
protos.google.bigtable.v2.IMutateRowResponse,
protos.google.bigtable.v2.IMutateRowRequest | null | undefined,
{} | null | undefined
>
): void;
mutateRow(
request?: protos.google.bigtable.v2.IMutateRowRequest,
optionsOrCallback?:
| CallOptions
| Callback<
protos.google.bigtable.v2.IMutateRowResponse,
protos.google.bigtable.v2.IMutateRowRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.bigtable.v2.IMutateRowResponse,
protos.google.bigtable.v2.IMutateRowRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.bigtable.v2.IMutateRowResponse,
protos.google.bigtable.v2.IMutateRowRequest | undefined,
{} | undefined,
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
const routingParameter = {};
{
const fieldValue = request.tableName;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(
RegExp('(?<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)')
);
if (match) {
const parameterValue = match.groups?.['table_name'] ?? fieldValue;
Object.assign(routingParameter, {table_name: parameterValue});
}
}
}
{
const fieldValue = request.appProfileId;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(RegExp('(?<app_profile_id>.*)'));
if (match) {
const parameterValue = match.groups?.['app_profile_id'] ?? fieldValue;
Object.assign(routingParameter, {app_profile_id: parameterValue});
}
}
}
{
const fieldValue = request.authorizedViewName;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(
RegExp(
'(?<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)'
)
);
if (match) {
const parameterValue =
match.groups?.['authorized_view_name'] ?? fieldValue;
Object.assign(routingParameter, {
authorized_view_name: parameterValue,
});
}
}
}
options.otherArgs.headers['x-goog-request-params'] =
this._gaxModule.routingHeader.fromParams(routingParameter);
this.initialize();
return this.innerApiCalls.mutateRow(request, options, callback);
}
/**
* Mutates a row atomically based on the output of a predicate Reader filter.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} [request.tableName]
* Optional. The unique name of the table to which the conditional mutation
* should be applied.
*
* Values are of the form
* `projects/<project>/instances/<instance>/tables/<table>`.
* @param {string} [request.authorizedViewName]
* Optional. The unique name of the AuthorizedView to which the conditional
* mutation should be applied.
*
* Values are of the form
* `projects/<project>/instances/<instance>/tables/<table>/authorizedViews/<authorized_view>`.
* @param {string} request.appProfileId
* This value specifies routing for replication. If not specified, the
* "default" application profile will be used.
* @param {Buffer} request.rowKey
* Required. The key of the row to which the conditional mutation should be
* applied.
* @param {google.bigtable.v2.RowFilter} request.predicateFilter
* The filter to be applied to the contents of the specified row. Depending
* on whether or not any results are yielded, either `true_mutations` or
* `false_mutations` will be executed. If unset, checks that the row contains
* any values at all.
* @param {number[]} request.trueMutations
* Changes to be atomically applied to the specified row if `predicate_filter`
* yields at least one cell when applied to `row_key`. Entries are applied in
* order, meaning that earlier mutations can be masked by later ones.
* Must contain at least one entry if `false_mutations` is empty, and at most
* 100000.
* @param {number[]} request.falseMutations
* Changes to be atomically applied to the specified row if `predicate_filter`
* does not yield any cells when applied to `row_key`. Entries are applied in
* order, meaning that earlier mutations can be masked by later ones.
* Must contain at least one entry if `true_mutations` is empty, and at most
* 100000.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing {@link protos.google.bigtable.v2.CheckAndMutateRowResponse|CheckAndMutateRowResponse}.
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
* for more details and examples.
*/
checkAndMutateRow(
request?: protos.google.bigtable.v2.ICheckAndMutateRowRequest,
options?: CallOptions
): Promise<
[
protos.google.bigtable.v2.ICheckAndMutateRowResponse,
protos.google.bigtable.v2.ICheckAndMutateRowRequest | undefined,
{} | undefined,
]
>;
checkAndMutateRow(
request: protos.google.bigtable.v2.ICheckAndMutateRowRequest,
options: CallOptions,
callback: Callback<
protos.google.bigtable.v2.ICheckAndMutateRowResponse,
protos.google.bigtable.v2.ICheckAndMutateRowRequest | null | undefined,
{} | null | undefined
>
): void;
checkAndMutateRow(
request: protos.google.bigtable.v2.ICheckAndMutateRowRequest,
callback: Callback<
protos.google.bigtable.v2.ICheckAndMutateRowResponse,
protos.google.bigtable.v2.ICheckAndMutateRowRequest | null | undefined,
{} | null | undefined
>
): void;
checkAndMutateRow(
request?: protos.google.bigtable.v2.ICheckAndMutateRowRequest,
optionsOrCallback?:
| CallOptions
| Callback<
protos.google.bigtable.v2.ICheckAndMutateRowResponse,
| protos.google.bigtable.v2.ICheckAndMutateRowRequest
| null
| undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.bigtable.v2.ICheckAndMutateRowResponse,
protos.google.bigtable.v2.ICheckAndMutateRowRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.bigtable.v2.ICheckAndMutateRowResponse,
protos.google.bigtable.v2.ICheckAndMutateRowRequest | undefined,
{} | undefined,
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
const routingParameter = {};
{
const fieldValue = request.tableName;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(
RegExp('(?<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)')
);
if (match) {
const parameterValue = match.groups?.['table_name'] ?? fieldValue;
Object.assign(routingParameter, {table_name: parameterValue});
}
}
}
{
const fieldValue = request.appProfileId;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(RegExp('(?<app_profile_id>.*)'));
if (match) {
const parameterValue = match.groups?.['app_profile_id'] ?? fieldValue;
Object.assign(routingParameter, {app_profile_id: parameterValue});
}
}
}
{
const fieldValue = request.authorizedViewName;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(
RegExp(
'(?<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)'
)
);
if (match) {
const parameterValue =
match.groups?.['authorized_view_name'] ?? fieldValue;
Object.assign(routingParameter, {
authorized_view_name: parameterValue,
});
}
}
}
options.otherArgs.headers['x-goog-request-params'] =
this._gaxModule.routingHeader.fromParams(routingParameter);
this.initialize();
return this.innerApiCalls.checkAndMutateRow(request, options, callback);
}
/**
* Warm up associated instance metadata for this connection.
* This call is not required but may be useful for connection keep-alive.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. The unique name of the instance to check permissions for as well
* as respond. Values are of the form
* `projects/<project>/instances/<instance>`.
* @param {string} request.appProfileId
* This value specifies routing for replication. If not specified, the
* "default" application profile will be used.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing {@link protos.google.bigtable.v2.PingAndWarmResponse|PingAndWarmResponse}.
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
* for more details and examples.
*/
pingAndWarm(
request?: protos.google.bigtable.v2.IPingAndWarmRequest,
options?: CallOptions
): Promise<
[
protos.google.bigtable.v2.IPingAndWarmResponse,
protos.google.bigtable.v2.IPingAndWarmRequest | undefined,
{} | undefined,
]
>;
pingAndWarm(
request: protos.google.bigtable.v2.IPingAndWarmRequest,
options: CallOptions,
callback: Callback<
protos.google.bigtable.v2.IPingAndWarmResponse,
protos.google.bigtable.v2.IPingAndWarmRequest | null | undefined,
{} | null | undefined
>
): void;
pingAndWarm(
request: protos.google.bigtable.v2.IPingAndWarmRequest,
callback: Callback<
protos.google.bigtable.v2.IPingAndWarmResponse,
protos.google.bigtable.v2.IPingAndWarmRequest | null | undefined,
{} | null | undefined
>
): void;
pingAndWarm(
request?: protos.google.bigtable.v2.IPingAndWarmRequest,
optionsOrCallback?:
| CallOptions
| Callback<
protos.google.bigtable.v2.IPingAndWarmResponse,
protos.google.bigtable.v2.IPingAndWarmRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.bigtable.v2.IPingAndWarmResponse,
protos.google.bigtable.v2.IPingAndWarmRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.bigtable.v2.IPingAndWarmResponse,
protos.google.bigtable.v2.IPingAndWarmRequest | undefined,
{} | undefined,
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
const routingParameter = {};
{
const fieldValue = request.name;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(RegExp('(?<name>projects/[^/]+/instances/[^/]+)'));
if (match) {
const parameterValue = match.groups?.['name'] ?? fieldValue;
Object.assign(routingParameter, {name: parameterValue});
}
}
}
{
const fieldValue = request.appProfileId;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(RegExp('(?<app_profile_id>.*)'));
if (match) {
const parameterValue = match.groups?.['app_profile_id'] ?? fieldValue;
Object.assign(routingParameter, {app_profile_id: parameterValue});
}
}
}
options.otherArgs.headers['x-goog-request-params'] =
this._gaxModule.routingHeader.fromParams(routingParameter);
this.initialize();
return this.innerApiCalls.pingAndWarm(request, options, callback);
}
/**
* Modifies a row atomically on the server. The method reads the latest
* existing timestamp and value from the specified columns and writes a new
* entry based on pre-defined read/modify/write rules. The new value for the
* timestamp is the greater of the existing timestamp or the current server
* time. The method returns the new contents of all modified cells.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} [request.tableName]
* Optional. The unique name of the table to which the read/modify/write rules
* should be applied.
*
* Values are of the form
* `projects/<project>/instances/<instance>/tables/<table>`.
* @param {string} [request.authorizedViewName]
* Optional. The unique name of the AuthorizedView to which the
* read/modify/write rules should be applied.
*
* Values are of the form
* `projects/<project>/instances/<instance>/tables/<table>/authorizedViews/<authorized_view>`.
* @param {string} request.appProfileId
* This value specifies routing for replication. If not specified, the
* "default" application profile will be used.
* @param {Buffer} request.rowKey
* Required. The key of the row to which the read/modify/write rules should be
* applied.
* @param {number[]} request.rules
* Required. Rules specifying how the specified row's contents are to be
* transformed into writes. Entries are applied in order, meaning that earlier
* rules will affect the results of later ones.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing {@link protos.google.bigtable.v2.ReadModifyWriteRowResponse|ReadModifyWriteRowResponse}.
* Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
* for more details and examples.
*/
readModifyWriteRow(
request?: protos.google.bigtable.v2.IReadModifyWriteRowRequest,
options?: CallOptions
): Promise<
[
protos.google.bigtable.v2.IReadModifyWriteRowResponse,
protos.google.bigtable.v2.IReadModifyWriteRowRequest | undefined,
{} | undefined,
]
>;
readModifyWriteRow(
request: protos.google.bigtable.v2.IReadModifyWriteRowRequest,
options: CallOptions,
callback: Callback<
protos.google.bigtable.v2.IReadModifyWriteRowResponse,
protos.google.bigtable.v2.IReadModifyWriteRowRequest | null | undefined,
{} | null | undefined
>
): void;
readModifyWriteRow(
request: protos.google.bigtable.v2.IReadModifyWriteRowRequest,
callback: Callback<
protos.google.bigtable.v2.IReadModifyWriteRowResponse,
protos.google.bigtable.v2.IReadModifyWriteRowRequest | null | undefined,
{} | null | undefined
>
): void;
readModifyWriteRow(
request?: protos.google.bigtable.v2.IReadModifyWriteRowRequest,
optionsOrCallback?:
| CallOptions
| Callback<
protos.google.bigtable.v2.IReadModifyWriteRowResponse,
| protos.google.bigtable.v2.IReadModifyWriteRowRequest
| null
| undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.bigtable.v2.IReadModifyWriteRowResponse,
protos.google.bigtable.v2.IReadModifyWriteRowRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.bigtable.v2.IReadModifyWriteRowResponse,
protos.google.bigtable.v2.IReadModifyWriteRowRequest | undefined,
{} | undefined,
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
const routingParameter = {};
{
const fieldValue = request.tableName;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(
RegExp('(?<table_name>projects/[^/]+/instances/[^/]+/tables/[^/]+)')
);
if (match) {
const parameterValue = match.groups?.['table_name'] ?? fieldValue;
Object.assign(routingParameter, {table_name: parameterValue});
}
}
}
{
const fieldValue = request.appProfileId;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(RegExp('(?<app_profile_id>.*)'));
if (match) {
const parameterValue = match.groups?.['app_profile_id'] ?? fieldValue;
Object.assign(routingParameter, {app_profile_id: parameterValue});
}
}
}
{
const fieldValue = request.authorizedViewName;
if (fieldValue !== undefined && fieldValue !== null) {
const match = fieldValue
.toString()
.match(
RegExp(
'(?<authorized_view_name>projects/[^/]+/instances/[^/]+/tables/[^/]+/authorizedViews/[^/]+)'
)
);
if (match) {
const parameterValue =
match.groups?.['authorized_view_name'] ?? fieldValue;
Object.assign(routingParameter, {
authorized_view_name: parameterValue,
});
}
}
}
options.otherArgs.headers['x-goog-request-params'] =
this._gaxModule.routingHeader.fromParams(routingParameter);
this.initialize();
return this.innerApiCalls.readModifyWriteRow(request, options, callback);