Skip to content

Commit 89124f6

Browse files
Benjamin E. CoeJustinBeckwith
authored andcommitted
feat: support apiEndpoint override (#500)
* build: switch to GitHub magic proxy * lint: fix linting
1 parent c9f6f7e commit 89124f6

File tree

11 files changed

+188
-67
lines changed

11 files changed

+188
-67
lines changed

.kokoro/continuous/node10/test.cfg

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,30 @@ before_action {
88
}
99
}
1010

11-
# token used by release-please to keep an up-to-date release PR.
11+
# tokens used by release-please to keep an up-to-date release PR.
1212
before_action {
1313
fetch_keystore {
1414
keystore_resource {
1515
keystore_config_id: 73713
16-
keyname: "yoshi-automation-github-key"
16+
keyname: "github-magic-proxy-key-release-please"
17+
}
18+
}
19+
}
20+
21+
before_action {
22+
fetch_keystore {
23+
keystore_resource {
24+
keystore_config_id: 73713
25+
keyname: "github-magic-proxy-token-release-please"
26+
}
27+
}
28+
}
29+
30+
before_action {
31+
fetch_keystore {
32+
keystore_resource {
33+
keystore_config_id: 73713
34+
keyname: "github-magic-proxy-url-release-please"
1735
}
1836
}
1937
}

.kokoro/test.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ else
3636
echo "coverage is only reported for Node $COVERAGE_NODE"
3737
fi
3838

39-
# if the GITHUB_TOKEN is set, we kick off a task to update the release-PR.
40-
GITHUB_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_yoshi-automation-github-key) || true
41-
if [ "$GITHUB_TOKEN" ]; then
42-
npx release-please release-pr --token=$GITHUB_TOKEN \
39+
# if release-please keys set, we kick off a task to update the release-PR.
40+
if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then
41+
npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \
4342
--repo-url=googleapis/nodejs-bigtable \
44-
--package-name=@google-cloud/bigtable
43+
--package-name=@google-cloud/bigtable \
44+
--api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \
45+
--proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please
4546
fi

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
4040
### Before you begin
4141

4242
1. [Select or create a Cloud Platform project][projects].
43+
1. [Enable billing for your project][billing].
4344
1. [Enable the Cloud Bigtable API][enable_api].
4445
1. [Set up authentication with a service account][auth] so you can access the
4546
API from your local workstation.

samples/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
* [Instances](#instances)
1616
* [Quickstart](#quickstart)
1717
* [Tableadmin](#tableadmin)
18+
* [Write Batch](#write-batch)
19+
* [Write Conditionally](#write-conditionally)
20+
* [Write Increment](#write-increment)
21+
* [Write Simple](#write-simple)
1822

1923
## Before you begin
2024

@@ -71,6 +75,74 @@ __Usage:__
7175
`node tableadmin.js`
7276

7377

78+
-----
79+
80+
81+
82+
83+
### Write Batch
84+
85+
View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeBatch.js).
86+
87+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md)
88+
89+
__Usage:__
90+
91+
92+
`node writeBatch.js`
93+
94+
95+
-----
96+
97+
98+
99+
100+
### Write Conditionally
101+
102+
View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeConditionally.js).
103+
104+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md)
105+
106+
__Usage:__
107+
108+
109+
`node writeConditionally.js`
110+
111+
112+
-----
113+
114+
115+
116+
117+
### Write Increment
118+
119+
View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeIncrement.js).
120+
121+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md)
122+
123+
__Usage:__
124+
125+
126+
`node writeIncrement.js`
127+
128+
129+
-----
130+
131+
132+
133+
134+
### Write Simple
135+
136+
View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js).
137+
138+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md)
139+
140+
__Usage:__
141+
142+
143+
`node writeSimple.js`
144+
145+
74146

75147

76148

src/v2/bigtable_client.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
const gapicConfig = require('./bigtable_client_config.json');
1818
const gax = require('google-gax');
19-
const merge = require('lodash.merge');
2019
const path = require('path');
2120

2221
const VERSION = require('../../../package.json').version;
@@ -56,14 +55,18 @@ class BigtableClient {
5655
* API remote host.
5756
*/
5857
constructor(opts) {
58+
opts = opts || {};
5959
this._descriptors = {};
6060

61+
const servicePath =
62+
opts.servicePath || opts.apiEndpoint || this.constructor.servicePath;
63+
6164
// Ensure that options include the service address and port.
6265
opts = Object.assign(
6366
{
6467
clientConfig: {},
6568
port: this.constructor.port,
66-
servicePath: this.constructor.servicePath,
69+
servicePath,
6770
},
6871
opts
6972
);
@@ -88,12 +91,9 @@ class BigtableClient {
8891
}
8992

9093
// Load the applicable protos.
91-
const protos = merge(
92-
{},
93-
gaxGrpc.loadProto(
94-
path.join(__dirname, '..', '..', 'protos'),
95-
'google/bigtable/v2/bigtable.proto'
96-
)
94+
const protos = gaxGrpc.loadProto(
95+
path.join(__dirname, '..', '..', 'protos'),
96+
['google/bigtable/v2/bigtable.proto']
9797
);
9898

9999
// This API contains "path templates"; forward-slash-separated
@@ -169,6 +169,14 @@ class BigtableClient {
169169
return 'bigtable.googleapis.com';
170170
}
171171

172+
/**
173+
* The DNS address for this API service - same as servicePath(),
174+
* exists for compatibility reasons.
175+
*/
176+
static get apiEndpoint() {
177+
return 'bigtable.googleapis.com';
178+
}
179+
172180
/**
173181
* The port for this API service.
174182
*/
@@ -234,7 +242,7 @@ class BigtableClient {
234242
* default (zero) is to return all results.
235243
* @param {Object} [options]
236244
* Optional parameters. You can override the default settings for this call, e.g, timeout,
237-
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
245+
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
238246
* @returns {Stream}
239247
* An object stream which emits [ReadRowsResponse]{@link google.bigtable.v2.ReadRowsResponse} on 'data' event.
240248
*
@@ -281,7 +289,7 @@ class BigtableClient {
281289
* "default" application profile will be used.
282290
* @param {Object} [options]
283291
* Optional parameters. You can override the default settings for this call, e.g, timeout,
284-
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
292+
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
285293
* @returns {Stream}
286294
* An object stream which emits [SampleRowKeysResponse]{@link google.bigtable.v2.SampleRowKeysResponse} on 'data' event.
287295
*
@@ -321,7 +329,7 @@ class BigtableClient {
321329
* The unique name of the table to which the mutation should be applied.
322330
* Values are of the form
323331
* `projects/<project>/instances/<instance>/tables/<table>`.
324-
* @param {string} request.rowKey
332+
* @param {Buffer} request.rowKey
325333
* The key of the row to which the mutation should be applied.
326334
* @param {Object[]} request.mutations
327335
* Changes to be atomically applied to the specified row. Entries are applied
@@ -334,7 +342,7 @@ class BigtableClient {
334342
* "default" application profile will be used.
335343
* @param {Object} [options]
336344
* Optional parameters. You can override the default settings for this call, e.g, timeout,
337-
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
345+
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
338346
* @param {function(?Error, ?Object)} [callback]
339347
* The function which will be called with the result of the API call.
340348
*
@@ -352,7 +360,7 @@ class BigtableClient {
352360
* });
353361
*
354362
* const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
355-
* const rowKey = '';
363+
* const rowKey = Buffer.from('');
356364
* const mutations = [];
357365
* const request = {
358366
* tableName: formattedTableName,
@@ -407,7 +415,7 @@ class BigtableClient {
407415
* "default" application profile will be used.
408416
* @param {Object} [options]
409417
* Optional parameters. You can override the default settings for this call, e.g, timeout,
410-
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
418+
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
411419
* @returns {Stream}
412420
* An object stream which emits [MutateRowsResponse]{@link google.bigtable.v2.MutateRowsResponse} on 'data' event.
413421
*
@@ -452,7 +460,7 @@ class BigtableClient {
452460
* applied.
453461
* Values are of the form
454462
* `projects/<project>/instances/<instance>/tables/<table>`.
455-
* @param {string} request.rowKey
463+
* @param {Buffer} request.rowKey
456464
* The key of the row to which the conditional mutation should be applied.
457465
* @param {string} [request.appProfileId]
458466
* This value specifies routing for replication. If not specified, the
@@ -482,7 +490,7 @@ class BigtableClient {
482490
* This object should have the same structure as [Mutation]{@link google.bigtable.v2.Mutation}
483491
* @param {Object} [options]
484492
* Optional parameters. You can override the default settings for this call, e.g, timeout,
485-
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
493+
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
486494
* @param {function(?Error, ?Object)} [callback]
487495
* The function which will be called with the result of the API call.
488496
*
@@ -500,7 +508,7 @@ class BigtableClient {
500508
* });
501509
*
502510
* const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
503-
* const rowKey = '';
511+
* const rowKey = Buffer.from('');
504512
* const request = {
505513
* tableName: formattedTableName,
506514
* rowKey: rowKey,
@@ -545,7 +553,7 @@ class BigtableClient {
545553
* applied.
546554
* Values are of the form
547555
* `projects/<project>/instances/<instance>/tables/<table>`.
548-
* @param {string} request.rowKey
556+
* @param {Buffer} request.rowKey
549557
* The key of the row to which the read/modify/write rules should be applied.
550558
* @param {Object[]} request.rules
551559
* Rules specifying how the specified row's contents are to be transformed
@@ -558,7 +566,7 @@ class BigtableClient {
558566
* "default" application profile will be used.
559567
* @param {Object} [options]
560568
* Optional parameters. You can override the default settings for this call, e.g, timeout,
561-
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
569+
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
562570
* @param {function(?Error, ?Object)} [callback]
563571
* The function which will be called with the result of the API call.
564572
*
@@ -576,7 +584,7 @@ class BigtableClient {
576584
* });
577585
*
578586
* const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
579-
* const rowKey = '';
587+
* const rowKey = Buffer.from('');
580588
* const rules = [];
581589
* const request = {
582590
* tableName: formattedTableName,

src/v2/doc/google/bigtable/v2/doc_bigtable.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const ReadRowsRequest = {
5656
* @property {Object[]} chunks
5757
* This object should have the same structure as [CellChunk]{@link google.bigtable.v2.CellChunk}
5858
*
59-
* @property {string} lastScannedRowKey
59+
* @property {Buffer} lastScannedRowKey
6060
* Optionally the server might return the row key of the last row it
6161
* has scanned. The client can use this to construct a more
6262
* efficient retry request if needed: any row keys or portions of
@@ -76,7 +76,7 @@ const ReadRowsResponse = {
7676
* Specifies a piece of a row's contents returned as part of the read
7777
* response stream.
7878
*
79-
* @property {string} rowKey
79+
* @property {Buffer} rowKey
8080
* The row key for this chunk of data. If the row key is empty,
8181
* this CellChunk is a continuation of the same row as the previous
8282
* CellChunk in the response stream, even if that CellChunk was in a
@@ -116,7 +116,7 @@ const ReadRowsResponse = {
116116
* RowFilter. Labels are only set
117117
* on the first CellChunk per cell.
118118
*
119-
* @property {string} value
119+
* @property {Buffer} value
120120
* The value stored in the cell. Cell values can be split across
121121
* multiple CellChunks. In that case only the value field will be
122122
* set in CellChunks after the first: the timestamp and labels
@@ -169,7 +169,7 @@ const SampleRowKeysRequest = {
169169
/**
170170
* Response message for Bigtable.SampleRowKeys.
171171
*
172-
* @property {string} rowKey
172+
* @property {Buffer} rowKey
173173
* Sorted streamed sequence of sample row keys in the table. The table might
174174
* have contents before the first row key in the list and after the last one,
175175
* but a key containing the empty string indicates "end of table" and will be
@@ -204,7 +204,7 @@ const SampleRowKeysResponse = {
204204
* This value specifies routing for replication. If not specified, the
205205
* "default" application profile will be used.
206206
*
207-
* @property {string} rowKey
207+
* @property {Buffer} rowKey
208208
* The key of the row to which the mutation should be applied.
209209
*
210210
* @property {Object[]} mutations
@@ -259,7 +259,7 @@ const MutateRowsRequest = {
259259
// This is for documentation. Actual contents will be loaded by gRPC.
260260

261261
/**
262-
* @property {string} rowKey
262+
* @property {Buffer} rowKey
263263
* The key of the row to which the `mutations` should be applied.
264264
*
265265
* @property {Object[]} mutations
@@ -329,7 +329,7 @@ const MutateRowsResponse = {
329329
* This value specifies routing for replication. If not specified, the
330330
* "default" application profile will be used.
331331
*
332-
* @property {string} rowKey
332+
* @property {Buffer} rowKey
333333
* The key of the row to which the conditional mutation should be applied.
334334
*
335335
* @property {Object} predicateFilter
@@ -394,7 +394,7 @@ const CheckAndMutateRowResponse = {
394394
* This value specifies routing for replication. If not specified, the
395395
* "default" application profile will be used.
396396
*
397-
* @property {string} rowKey
397+
* @property {Buffer} rowKey
398398
* The key of the row to which the read/modify/write rules should be applied.
399399
*
400400
* @property {Object[]} rules

0 commit comments

Comments
 (0)