MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

compute/firewall/listFirewallRules.js:20–43  ·  view source on GitHub ↗

* Prints a list of all firewall rules in specified project. * * @param {string} projectId - project ID or project number of the Cloud project you want to use.

(projectId)

Source from the content-addressed store, hash-verified

18 * @param {string} projectId - project ID or project number of the Cloud project you want to use.
19 */
20function main(projectId) {
21 // [START compute_firewall_list]
22 /**
23 * TODO(developer): Uncomment and replace these variables before running the sample.
24 */
25 // const projectId = 'YOUR_PROJECT_ID';
26
27 const compute = require('@google-cloud/compute');
28
29 async function listFirewallRules() {
30 const firewallsClient = new compute.FirewallsClient();
31
32 const [firewallRules] = await firewallsClient.list({
33 project: projectId,
34 });
35
36 for (const rule of firewallRules) {
37 console.log(` - ${rule.name}: ${rule.description}`);
38 }
39 }
40
41 listFirewallRules();
42 // [END compute_firewall_list]
43}
44
45main(...process.argv.slice(2));
46process.on('unhandledRejection', err => {

Callers 1

Calls 1

listFirewallRulesFunction · 0.85

Tested by

no test coverage detected