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

Function main

storage/listNotifications.js:25–60  ·  view source on GitHub ↗

* This application demonstrates how to perform basic operations on files with * the Google Cloud Storage API. * * For more information, see the README.md under /storage and the documentation * at https://cloud.google.com/storage/docs.

(bucketName = 'my-bucket')

Source from the content-addressed store, hash-verified

23 */
24
25function main(bucketName = 'my-bucket') {
26 // [START storage_list_bucket_notifications]
27 /**
28 * TODO(developer): Uncomment the following lines before running the sample.
29 */
30 // The ID of your GCS bucket
31 // const bucketName = 'your-unique-bucket-name';
32
33 // Imports the Google Cloud client library
34 const {Storage} = require('@google-cloud/storage');
35
36 // Creates a client
37 const storage = new Storage();
38
39 async function listNotifications() {
40 try {
41 // Lists notifications in the bucket
42 const [notifications] = await storage
43 .bucket(bucketName)
44 .getNotifications();
45
46 console.log('Notifications:');
47 notifications.forEach(notification => {
48 console.log(notification.id);
49 });
50 } catch (error) {
51 console.error(
52 'Error executing list notifications:',
53 error.message || error
54 );
55 }
56 }
57
58 listNotifications();
59 // [END storage_list_bucket_notifications]
60}
61main(...process.argv.slice(2));

Callers 1

Calls 1

listNotificationsFunction · 0.85

Tested by

no test coverage detected