Skip to content

Commit 3743061

Browse files
build: use bazel build (#9)
Co-authored-by: Justin Beckwith <[email protected]>
1 parent 2c6c277 commit 3743061

File tree

6 files changed

+109
-29
lines changed

6 files changed

+109
-29
lines changed

packages/google-cloud-bigquery-connection/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"prelint": "cd samples/ && npm link ../ && npm i",
3636
"prepare": "npm run compile-protos && npm run compile",
3737
"system-test": "c8 mocha build/system-test",
38-
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
38+
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
3939
"test": "c8 mocha build/test"
4040
},
4141
"dependencies": {

packages/google-cloud-bigquery-connection/src/v1/connection_service_client.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ export class ConnectionServiceClient {
163163
connectionPathTemplate: new this._gaxModule.PathTemplate(
164164
'projects/{project}/locations/{location}/connections/{connection}'
165165
),
166+
locationPathTemplate: new this._gaxModule.PathTemplate(
167+
'projects/{project}/locations/{location}'
168+
),
166169
};
167170

168171
// Some of the methods on this service return "paged" results,
@@ -1222,6 +1225,42 @@ export class ConnectionServiceClient {
12221225
.connection;
12231226
}
12241227

1228+
/**
1229+
* Return a fully-qualified location resource name string.
1230+
*
1231+
* @param {string} project
1232+
* @param {string} location
1233+
* @returns {string} Resource name string.
1234+
*/
1235+
locationPath(project: string, location: string) {
1236+
return this.pathTemplates.locationPathTemplate.render({
1237+
project: project,
1238+
location: location,
1239+
});
1240+
}
1241+
1242+
/**
1243+
* Parse the project from Location resource.
1244+
*
1245+
* @param {string} locationName
1246+
* A fully-qualified path representing Location resource.
1247+
* @returns {string} A string representing the project.
1248+
*/
1249+
matchProjectFromLocationName(locationName: string) {
1250+
return this.pathTemplates.locationPathTemplate.match(locationName).project;
1251+
}
1252+
1253+
/**
1254+
* Parse the location from Location resource.
1255+
*
1256+
* @param {string} locationName
1257+
* A fully-qualified path representing Location resource.
1258+
* @returns {string} A string representing the location.
1259+
*/
1260+
matchLocationFromLocationName(locationName: string) {
1261+
return this.pathTemplates.locationPathTemplate.match(locationName).location;
1262+
}
1263+
12251264
/**
12261265
* Terminate the GRPC channel and close the client.
12271266
*

packages/google-cloud-bigquery-connection/src/v1/connection_service_client_config.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,42 @@
2121
},
2222
"methods": {
2323
"CreateConnection": {
24+
"timeout_millis": 60000,
2425
"retry_codes_name": "non_idempotent",
2526
"retry_params_name": "default"
2627
},
2728
"GetConnection": {
28-
"retry_codes_name": "non_idempotent",
29+
"timeout_millis": 60000,
30+
"retry_codes_name": "idempotent",
2931
"retry_params_name": "default"
3032
},
3133
"ListConnections": {
32-
"retry_codes_name": "non_idempotent",
34+
"timeout_millis": 60000,
35+
"retry_codes_name": "idempotent",
3336
"retry_params_name": "default"
3437
},
3538
"UpdateConnection": {
39+
"timeout_millis": 60000,
3640
"retry_codes_name": "non_idempotent",
3741
"retry_params_name": "default"
3842
},
3943
"DeleteConnection": {
40-
"retry_codes_name": "non_idempotent",
44+
"timeout_millis": 60000,
45+
"retry_codes_name": "idempotent",
4146
"retry_params_name": "default"
4247
},
4348
"GetIamPolicy": {
49+
"timeout_millis": 60000,
4450
"retry_codes_name": "non_idempotent",
4551
"retry_params_name": "default"
4652
},
4753
"SetIamPolicy": {
54+
"timeout_millis": 60000,
4855
"retry_codes_name": "non_idempotent",
4956
"retry_params_name": "default"
5057
},
5158
"TestIamPermissions": {
59+
"timeout_millis": 60000,
5260
"retry_codes_name": "non_idempotent",
5361
"retry_params_name": "default"
5462
}

packages/google-cloud-bigquery-connection/synth.metadata

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,15 @@
33
{
44
"git": {
55
"name": ".",
6-
"remote": "https://github.com/googleapis/nodejs-bigquery-connection.git",
7-
"sha": "9125a52480f9259e959a6a4ce706fb574b74ae0a"
8-
}
9-
},
10-
{
11-
"git": {
12-
"name": "googleapis",
13-
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "a98ede59fdb3120fd1cb0b025bf5a7a7f4345797",
15-
"internalRef": "320277413"
6+
"remote": "[email protected]:googleapis/nodejs-bigquery-connection.git",
7+
"sha": "ebf1424b3e8a4c96585301a9ee26387b89ffabd8"
168
}
179
},
1810
{
1911
"git": {
2012
"name": "synthtool",
2113
"remote": "https://github.com/googleapis/synthtool.git",
22-
"sha": "799d8e6522c1ef7cb55a70d9ea0b15e045c3d00b"
14+
"sha": "303271797a360f8a439203413f13a160f2f5b3b4"
2315
}
2416
}
2517
],
@@ -29,8 +21,8 @@
2921
"source": "googleapis",
3022
"apiName": "bigquery-connection",
3123
"apiVersion": "v1",
32-
"language": "typescript",
33-
"generator": "gapic-generator-typescript"
24+
"language": "nodejs",
25+
"generator": "bazel"
3426
}
3527
}
3628
]

packages/google-cloud-bigquery-connection/synth.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,22 @@
1515

1616
import synthtool as s
1717
import synthtool.gcp as gcp
18+
import synthtool.languages.node as node
1819
import subprocess
1920
import logging
2021

2122
logging.basicConfig(level=logging.DEBUG)
2223

2324
# run the gapic generator
24-
gapic = gcp.GAPICMicrogenerator()
25+
gapic = gcp.GAPICBazel()
2526
versions = ['v1']
2627
for version in versions:
27-
library = gapic.typescript_library(
28-
'bigquery-connection',
29-
generator_args={
30-
'package-name': '@google-cloud/bigquery-connection'
31-
},
32-
proto_path='/google/cloud/bigquery/connection/v1',
33-
version=version)
28+
library = gapic.node_library('bigquery-connection', version, proto_path=f'google/cloud/bigquery/connection/{version}')
3429
s.copy(library, excludes=['README.md', 'package.json'])
3530

3631
# Copy common templates
3732
common_templates = gcp.CommonTemplates()
3833
templates = common_templates.node_library(source_location='build/src')
3934
s.copy(templates, excludes=[])
4035

41-
# Node.js specific cleanup
42-
subprocess.run(['npm', 'install'])
43-
subprocess.run(['npm', 'run', 'fix'])
44-
subprocess.run(['npx', 'compileProtos', 'src'])
36+
node.postprocess_gapic_library()

packages/google-cloud-bigquery-connection/test/gapic_connection_service_v1.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,5 +1362,54 @@ describe('v1.ConnectionServiceClient', () => {
13621362
);
13631363
});
13641364
});
1365+
1366+
describe('location', () => {
1367+
const fakePath = '/rendered/path/location';
1368+
const expectedParameters = {
1369+
project: 'projectValue',
1370+
location: 'locationValue',
1371+
};
1372+
const client = new connectionserviceModule.v1.ConnectionServiceClient({
1373+
credentials: {client_email: 'bogus', private_key: 'bogus'},
1374+
projectId: 'bogus',
1375+
});
1376+
client.initialize();
1377+
client.pathTemplates.locationPathTemplate.render = sinon
1378+
.stub()
1379+
.returns(fakePath);
1380+
client.pathTemplates.locationPathTemplate.match = sinon
1381+
.stub()
1382+
.returns(expectedParameters);
1383+
1384+
it('locationPath', () => {
1385+
const result = client.locationPath('projectValue', 'locationValue');
1386+
assert.strictEqual(result, fakePath);
1387+
assert(
1388+
(client.pathTemplates.locationPathTemplate.render as SinonStub)
1389+
.getCall(-1)
1390+
.calledWith(expectedParameters)
1391+
);
1392+
});
1393+
1394+
it('matchProjectFromLocationName', () => {
1395+
const result = client.matchProjectFromLocationName(fakePath);
1396+
assert.strictEqual(result, 'projectValue');
1397+
assert(
1398+
(client.pathTemplates.locationPathTemplate.match as SinonStub)
1399+
.getCall(-1)
1400+
.calledWith(fakePath)
1401+
);
1402+
});
1403+
1404+
it('matchLocationFromLocationName', () => {
1405+
const result = client.matchLocationFromLocationName(fakePath);
1406+
assert.strictEqual(result, 'locationValue');
1407+
assert(
1408+
(client.pathTemplates.locationPathTemplate.match as SinonStub)
1409+
.getCall(-1)
1410+
.calledWith(fakePath)
1411+
);
1412+
});
1413+
});
13651414
});
13661415
});

0 commit comments

Comments
 (0)