Skip to content

Commit 053ec0b

Browse files
authored
feat!: initial generation of library (#1)
0 parents  commit 053ec0b

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

eventarc/quickstart/package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nodejs-eventarc",
3+
"private": true,
4+
"license": "Apache-2.0",
5+
"author": "Google LLC",
6+
"engines": {
7+
"node": ">=10"
8+
},
9+
"files": [
10+
"*.js"
11+
],
12+
"scripts": {
13+
"test": "c8 mocha --timeout 600000 test/*.js"
14+
},
15+
"dependencies": {
16+
"@google-cloud/eventarc": "^0.1.0"
17+
},
18+
"devDependencies": {
19+
"c8": "^7.1.0",
20+
"chai": "^4.2.0",
21+
"mocha": "^8.0.0"
22+
}
23+
}

eventarc/quickstart/quickstart.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// https://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
//
13+
14+
'use strict';
15+
16+
async function main(projectId) {
17+
// [START nodejs_eventarc_quickstart]
18+
// Imports the Google Cloud client library
19+
20+
// remove this line after package is released
21+
// eslint-disable-next-line node/no-missing-require
22+
const {EventarcClient} = require('@google-cloud/eventarc');
23+
24+
// TODO(developer): replace with your prefered project ID.
25+
// const projectId = 'my-project'
26+
27+
// Creates a client
28+
const client = new EventarcClient();
29+
30+
//TODO(library generator): write the actual function you will be testing
31+
async function doSomething() {
32+
for await (const trigger of await client.listTriggersAsync({
33+
parent: client.locationPath(projectId, 'us-central1'),
34+
})) {
35+
console.info(trigger.name);
36+
}
37+
}
38+
doSomething();
39+
// [END nodejs_eventarc_quickstart]
40+
}
41+
42+
main(...process.argv.slice(2)).catch(err => {
43+
console.error(err.message);
44+
process.exitCode = 1;
45+
});
46+
process.on('unhandledRejection', err => {
47+
console.error(err.message);
48+
process.exitCode = 1;
49+
});
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// https://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
//
14+
// ** This file is automatically generated by gapic-generator-typescript. **
15+
// ** https://github.com/googleapis/gapic-generator-typescript **
16+
// ** All changes to this file may be overwritten. **
17+
18+
'use strict';
19+
20+
const path = require('path');
21+
const cp = require('child_process');
22+
const {before, describe, it} = require('mocha');
23+
// eslint-disable-next-line node/no-missing-require
24+
const {EventarcClient} = require('@google-cloud/eventarc');
25+
// eslint-disable-next-line no-unused-vars, node/no-missing-require
26+
const {assert} = require('chai');
27+
28+
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
29+
30+
const cwd = path.join(__dirname, '..');
31+
32+
const client = new EventarcClient();
33+
34+
describe('Quickstart', () => {
35+
let projectId;
36+
37+
before(async () => {
38+
projectId = await client.getProjectId();
39+
});
40+
41+
it('should run quickstart', async () => {
42+
const stdout = execSync(`node ./quickstart.js ${projectId}`, {cwd});
43+
assert.strictEqual(stdout.includes('test-event-arc-api'), true);
44+
});
45+
});

0 commit comments

Comments
 (0)