Skip to content

Commit

Permalink
build: use bazel build (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
  • Loading branch information
alexander-fenster and JustinBeckwith authored Jul 11, 2020
1 parent 2c6c277 commit 3743061
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-bigquery-connection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"prelint": "cd samples/ && npm link ../ && npm i",
"prepare": "npm run compile-protos && npm run compile",
"system-test": "c8 mocha build/system-test",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
"test": "c8 mocha build/test"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export class ConnectionServiceClient {
connectionPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}/connections/{connection}'
),
locationPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}'
),
};

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

/**
* Return a fully-qualified location resource name string.
*
* @param {string} project
* @param {string} location
* @returns {string} Resource name string.
*/
locationPath(project: string, location: string) {
return this.pathTemplates.locationPathTemplate.render({
project: project,
location: location,
});
}

/**
* Parse the project from Location resource.
*
* @param {string} locationName
* A fully-qualified path representing Location resource.
* @returns {string} A string representing the project.
*/
matchProjectFromLocationName(locationName: string) {
return this.pathTemplates.locationPathTemplate.match(locationName).project;
}

/**
* Parse the location from Location resource.
*
* @param {string} locationName
* A fully-qualified path representing Location resource.
* @returns {string} A string representing the location.
*/
matchLocationFromLocationName(locationName: string) {
return this.pathTemplates.locationPathTemplate.match(locationName).location;
}

/**
* Terminate the GRPC channel and close the client.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,42 @@
},
"methods": {
"CreateConnection": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"GetConnection": {
"retry_codes_name": "non_idempotent",
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"ListConnections": {
"retry_codes_name": "non_idempotent",
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"UpdateConnection": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"DeleteConnection": {
"retry_codes_name": "non_idempotent",
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"GetIamPolicy": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"SetIamPolicy": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"TestIamPermissions": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
}
Expand Down
18 changes: 5 additions & 13 deletions packages/google-cloud-bigquery-connection/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@
{
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-bigquery-connection.git",
"sha": "9125a52480f9259e959a6a4ce706fb574b74ae0a"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "a98ede59fdb3120fd1cb0b025bf5a7a7f4345797",
"internalRef": "320277413"
"remote": "git@github.com:googleapis/nodejs-bigquery-connection.git",
"sha": "ebf1424b3e8a4c96585301a9ee26387b89ffabd8"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "799d8e6522c1ef7cb55a70d9ea0b15e045c3d00b"
"sha": "303271797a360f8a439203413f13a160f2f5b3b4"
}
}
],
Expand All @@ -29,8 +21,8 @@
"source": "googleapis",
"apiName": "bigquery-connection",
"apiVersion": "v1",
"language": "typescript",
"generator": "gapic-generator-typescript"
"language": "nodejs",
"generator": "bazel"
}
}
]
Expand Down
16 changes: 4 additions & 12 deletions packages/google-cloud-bigquery-connection/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,22 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.node as node
import subprocess
import logging

logging.basicConfig(level=logging.DEBUG)

# run the gapic generator
gapic = gcp.GAPICMicrogenerator()
gapic = gcp.GAPICBazel()
versions = ['v1']
for version in versions:
library = gapic.typescript_library(
'bigquery-connection',
generator_args={
'package-name': '@google-cloud/bigquery-connection'
},
proto_path='/google/cloud/bigquery/connection/v1',
version=version)
library = gapic.node_library('bigquery-connection', version, proto_path=f'google/cloud/bigquery/connection/{version}')
s.copy(library, excludes=['README.md', 'package.json'])

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

# Node.js specific cleanup
subprocess.run(['npm', 'install'])
subprocess.run(['npm', 'run', 'fix'])
subprocess.run(['npx', 'compileProtos', 'src'])
node.postprocess_gapic_library()
Original file line number Diff line number Diff line change
Expand Up @@ -1362,5 +1362,54 @@ describe('v1.ConnectionServiceClient', () => {
);
});
});

describe('location', () => {
const fakePath = '/rendered/path/location';
const expectedParameters = {
project: 'projectValue',
location: 'locationValue',
};
const client = new connectionserviceModule.v1.ConnectionServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
client.pathTemplates.locationPathTemplate.render = sinon
.stub()
.returns(fakePath);
client.pathTemplates.locationPathTemplate.match = sinon
.stub()
.returns(expectedParameters);

it('locationPath', () => {
const result = client.locationPath('projectValue', 'locationValue');
assert.strictEqual(result, fakePath);
assert(
(client.pathTemplates.locationPathTemplate.render as SinonStub)
.getCall(-1)
.calledWith(expectedParameters)
);
});

it('matchProjectFromLocationName', () => {
const result = client.matchProjectFromLocationName(fakePath);
assert.strictEqual(result, 'projectValue');
assert(
(client.pathTemplates.locationPathTemplate.match as SinonStub)
.getCall(-1)
.calledWith(fakePath)
);
});

it('matchLocationFromLocationName', () => {
const result = client.matchLocationFromLocationName(fakePath);
assert.strictEqual(result, 'locationValue');
assert(
(client.pathTemplates.locationPathTemplate.match as SinonStub)
.getCall(-1)
.calledWith(fakePath)
);
});
});
});
});

0 comments on commit 3743061

Please sign in to comment.