(bucketName)
| 16 | 'use strict'; |
| 17 | |
| 18 | function main(bucketName) { |
| 19 | // [START storage_control_list_folders] |
| 20 | /** |
| 21 | * TODO(developer): Uncomment these variables before running the sample. |
| 22 | */ |
| 23 | |
| 24 | // The name of your GCS bucket |
| 25 | // const bucketName = 'bucketName'; |
| 26 | |
| 27 | // Imports the Control library |
| 28 | const {StorageControlClient} = require('@google-cloud/storage-control').v2; |
| 29 | |
| 30 | // Instantiates a client |
| 31 | const controlClient = new StorageControlClient(); |
| 32 | |
| 33 | async function callListFolders() { |
| 34 | const bucketPath = controlClient.bucketPath('_', bucketName); |
| 35 | |
| 36 | // Create the request |
| 37 | const request = { |
| 38 | parent: bucketPath, |
| 39 | }; |
| 40 | |
| 41 | // Run request |
| 42 | const [folders] = await controlClient.listFolders(request); |
| 43 | for (const curFolder of folders) { |
| 44 | console.log(curFolder.name); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | callListFolders(); |
| 49 | // [END storage_control_list_folders] |
| 50 | } |
| 51 | |
| 52 | process.on('unhandledRejection', err => { |
| 53 | console.error(err.message); |
no test coverage detected