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

Function main

cloud-tasks/snippets/listQueues.js:17–46  ·  view source on GitHub ↗
(
  project = 'my-project-id', // Your GCP Project id
  location = 'us-central1' // The GCP region to search for queues
)

Source from the content-addressed store, hash-verified

15'use strict';
16
17function 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
48process.on('unhandledRejection', err => {
49 console.error(err.message);

Callers 1

listQueues.jsFile · 0.70

Calls 1

listQueuesFunction · 0.85

Tested by

no test coverage detected