* 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)
| 18 | * @param {string} projectId - project ID or project number of the Cloud project you want to use. |
| 19 | */ |
| 20 | function 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 | |
| 45 | main(...process.argv.slice(2)); |
| 46 | process.on('unhandledRejection', err => { |
no test coverage detected