( project = 'my-project-id', // Your GCP Project id location = 'us-central1' // The GCP region to search for queues )
| 15 | 'use strict'; |
| 16 | |
| 17 | function main( |
| 18 | project = 'my-project-id', // Your GCP Project id |
| 19 | location = 'us-central1' // The GCP region to search for queues |
| 20 | ) { |
| 21 | // [START cloud_tasks_list_queues] |
| 22 | // Imports the Google Cloud Tasks library. |
| 23 | const cloudTasks = require('@google-cloud/tasks'); |
| 24 | |
| 25 | // Instantiates a client. |
| 26 | const client = new cloudTasks.CloudTasksClient(); |
| 27 | |
| 28 | async function listQueues() { |
| 29 | // Get the fully qualified path to the region |
| 30 | const parent = client.locationPath(project, location); |
| 31 | |
| 32 | // list all fo the queues |
| 33 | const [queues] = await client.listQueues({parent}); |
| 34 | |
| 35 | if (queues.length > 0) { |
| 36 | console.log('Queues:'); |
| 37 | queues.forEach(queue => { |
| 38 | console.log(` ${queue.name}`); |
| 39 | }); |
| 40 | } else { |
| 41 | console.log('No queues found!'); |
| 42 | } |
| 43 | } |
| 44 | listQueues(); |
| 45 | // [END cloud_tasks_list_queues] |
| 46 | } |
| 47 | |
| 48 | process.on('unhandledRejection', err => { |
| 49 | console.error(err.message); |
no test coverage detected