Skip to content

Commit 2a0523e

Browse files
sofislkweinmeister
authored andcommitted
feat!: initial stub of library
1 parent bd3acfe commit 2a0523e

File tree

4 files changed

+174
-0
lines changed

4 files changed

+174
-0
lines changed

org-policy/README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2+
[//]: # "To regenerate it, use `python -m synthtool`."
3+
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
4+
5+
# [Organization Policy: Node.js Samples](https://github.com/googleapis/nodejs-org-policy)
6+
7+
[![Open in Cloud Shell][shell_img]][shell_link]
8+
9+
10+
11+
## Table of Contents
12+
13+
* [Before you begin](#before-you-begin)
14+
* [Samples](#samples)
15+
* [Quickstart](#quickstart)
16+
17+
## Before you begin
18+
19+
Before running the samples, make sure you've followed the steps outlined in
20+
[Using the client library](https://github.com/googleapis/nodejs-org-policy#using-the-client-library).
21+
22+
`cd samples`
23+
24+
`npm install`
25+
26+
`cd ..`
27+
28+
## Samples
29+
30+
31+
32+
### Quickstart
33+
34+
View the [source code](https://github.com/googleapis/nodejs-org-policy/blob/master/samples/quickstart.js).
35+
36+
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-org-policy&page=editor&open_in_editor=samples/quickstart.js,samples/README.md)
37+
38+
__Usage:__
39+
40+
41+
`node samples/quickstart.js`
42+
43+
44+
45+
46+
47+
48+
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
49+
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-org-policy&page=editor&open_in_editor=samples/README.md
50+
[product-docs]: null

org-policy/package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nodejs-org-policy",
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+
"": "^0.1.0"
17+
},
18+
"devDependencies": {
19+
"c8": "^7.1.0",
20+
"chai": "^4.2.0",
21+
"mocha": "^8.0.0"
22+
}
23+
}

org-policy/quickstart.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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() {
17+
// [START nodejs_org_policy_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 {OrgPolicyClient} = require('');
23+
24+
// TODO(developer): replace with your prefered project ID.
25+
// const projectId = 'my-project'
26+
27+
// Creates a client
28+
// eslint-disable-next-line no-unused-vars
29+
const client = new {OrgPolicyClient}();
30+
31+
//TODO(library generator): write the actual function you will be testing
32+
async function doSomething() {
33+
console.log(
34+
'DPE! Change this code so that it shows how to use the library! See comments below on structure.'
35+
);
36+
// const [thing] = await client.methodName({
37+
// });
38+
// console.info(thing);
39+
}
40+
doSomething();
41+
// [END nodejs_org_policy_quickstart]
42+
}
43+
44+
main(...process.argv.slice(2)).catch(err => {
45+
console.error(err.message);
46+
process.exitCode = 1;
47+
});
48+
process.on('unhandledRejection', err => {
49+
console.error(err.message);
50+
process.exitCode = 1;
51+
});

org-policy/test/quickstart.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 {OrgPolicyClient} = require('');
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 {OrgPolicyClient}();
33+
34+
describe('Quickstart', () => {
35+
//TODO: remove this if not using the projectId
36+
// eslint-disable-next-line no-unused-vars
37+
let projectId;
38+
39+
before(async () => {
40+
// eslint-disable-next-line no-unused-vars
41+
projectId = await client.getProjectId();
42+
});
43+
44+
it('should run quickstart', async () => {
45+
//TODO: remove this line
46+
// eslint-disable-next-line no-unused-vars
47+
const stdout = execSync('node ./quickstart.js', {cwd});
48+
//assert(stdout, stdout !== null);
49+
});
50+
});

0 commit comments

Comments
 (0)