(projectId, jobName)
| 17 | 'use strict'; |
| 18 | |
| 19 | async function main(projectId, jobName) { |
| 20 | // [START storagetransfer_transfer_check] |
| 21 | |
| 22 | // Imports the Google Cloud client library |
| 23 | const { |
| 24 | StorageTransferServiceClient, |
| 25 | protos, |
| 26 | } = require('@google-cloud/storage-transfer'); |
| 27 | |
| 28 | // Proto for TransferOperation |
| 29 | const TransferOperation = protos.google.storagetransfer.v1.TransferOperation; |
| 30 | |
| 31 | /** |
| 32 | * TODO(developer): Uncomment the following lines before running the sample. |
| 33 | */ |
| 34 | // The ID of the Google Cloud Platform Project that owns the job |
| 35 | // projectId = 'my-project-id' |
| 36 | |
| 37 | // Storage Transfer Service job name |
| 38 | // jobName = 'transferJobs/1234567890' |
| 39 | |
| 40 | // Creates a client |
| 41 | const client = new StorageTransferServiceClient(); |
| 42 | |
| 43 | /** |
| 44 | * Lists operations for a transfer job. |
| 45 | */ |
| 46 | async function checkLatestTransferOperation() { |
| 47 | const filter = JSON.stringify({ |
| 48 | project_id: projectId, |
| 49 | job_names: [jobName], |
| 50 | }); |
| 51 | |
| 52 | const [operations] = await client.operationsClient.listOperations({ |
| 53 | name: 'transferOperations', |
| 54 | filter, |
| 55 | }); |
| 56 | |
| 57 | console.log(`Transfer operations for ${jobName}:`); |
| 58 | for (const {metadata} of operations) { |
| 59 | const transferOperation = TransferOperation.decode(metadata.value); |
| 60 | |
| 61 | console.dir(transferOperation); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | checkLatestTransferOperation(); |
| 66 | // [END storagetransfer_transfer_check] |
| 67 | } |
| 68 | |
| 69 | main(...process.argv.slice(2)); |
| 70 |
no test coverage detected