* Retrieves information about the specified job, most notably its status. * * @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 identi
(projectId, region, jobName, groupName, taskNumber)
| 28 | * @param {number} taskNumber - number of the task you want to look up. |
| 29 | */ |
| 30 | async function main(projectId, region, jobName, groupName, taskNumber) { |
| 31 | // [START batch_get_task] |
| 32 | /** |
| 33 | * TODO(developer): Uncomment and replace these variables before running the sample. |
| 34 | */ |
| 35 | // const projectId = 'YOUR_PROJECT_ID'; |
| 36 | /** |
| 37 | * The region that hosts the job. |
| 38 | */ |
| 39 | // const region = 'us-central-1'; |
| 40 | /** |
| 41 | * The name of the job you want to retrieve information about. |
| 42 | */ |
| 43 | // const jobName = 'YOUR_JOB_NAME'; |
| 44 | /** |
| 45 | * The name of the group that owns the task you want to check. |
| 46 | * Usually it's `group0`. |
| 47 | */ |
| 48 | // const groupName = 'group0'; |
| 49 | /** |
| 50 | * The number of the task you want to look up. |
| 51 | */ |
| 52 | // const taskNumber = 0; |
| 53 | |
| 54 | // Imports the Batch library |
| 55 | const batchLib = require('@google-cloud/batch'); |
| 56 | |
| 57 | // Instantiates a client |
| 58 | const batchClient = new batchLib.v1.BatchServiceClient(); |
| 59 | |
| 60 | async function callGetJob() { |
| 61 | // Construct request |
| 62 | const request = { |
| 63 | name: |
| 64 | `projects/${projectId}/locations/${region}/jobs/${jobName}` + |
| 65 | `/taskGroups/${groupName}/tasks/${taskNumber}`, |
| 66 | }; |
| 67 | |
| 68 | // Run request |
| 69 | const response = await batchClient.getTask(request); |
| 70 | console.log(response); |
| 71 | } |
| 72 | |
| 73 | await callGetJob(); |
| 74 | // [END batch_get_task] |
| 75 | } |
| 76 | |
| 77 | main(...process.argv.slice(2)).catch(err => { |
| 78 | console.error(err.message); |