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

Function main

batch/list/list_tasks.js:28–68  ·  view source on GitHub ↗

* Get a list of all jobs defined in given region. * * @param {string} projectId - ID or number of the Google Cloud project you want to use. * @param {string} region - The Google Cloud region to use, e.g. 'us-central1' * @param {string} jobName - ID used to uniquely identify the Job within this p

(projectId, region, jobName, groupName)

Source from the content-addressed store, hash-verified

26 * @param {string} groupName - name of the group of tasks. Usually it's `group0`.
27 */
28async function main(projectId, region, jobName, groupName) {
29 // [START batch_list_tasks]
30 /**
31 * TODO(developer): Uncomment and replace these variables before running the sample.
32 */
33 // const projectId = 'YOUR_PROJECT_ID';
34 /**
35 * The region that hosts the job.
36 */
37 // const region = 'us-central-1';
38 /**
39 * The name of the job which tasks you want to list.
40 */
41 // const jobName = 'YOUR_JOB_NAME';
42 /**
43 * The name of the group of tasks. Usually it's `group0`.
44 */
45 // const groupName = 'group0';
46
47 // Imports the Batch library
48 const batchLib = require('@google-cloud/batch');
49
50 // Instantiates a client
51 const batchClient = new batchLib.v1.BatchServiceClient();
52
53 async function callListTasks() {
54 // Construct request
55 const request = {
56 parent: `projects/${projectId}/locations/${region}/jobs/${jobName}/taskGroups/${groupName}`,
57 };
58
59 // Run request
60 const iterable = await batchClient.listTasksAsync(request);
61 for await (const response of iterable) {
62 console.log(response);
63 }
64 }
65
66 await callListTasks();
67 // [END batch_list_tasks]
68}
69
70main(...process.argv.slice(2)).catch(err => {
71 console.error(err.message);

Callers 1

list_tasks.jsFile · 0.70

Calls 1

callListTasksFunction · 0.85

Tested by

no test coverage detected