* 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', notificationId = '1')
| 23 | */ |
| 24 | |
| 25 | function main(bucketName = 'my-bucket', notificationId = '1') { |
| 26 | // [START storage_delete_bucket_notification] |
| 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 | // The ID of the notification |
| 34 | // const notificationId = '1'; |
| 35 | |
| 36 | // Imports the Google Cloud client library |
| 37 | const {Storage} = require('@google-cloud/storage'); |
| 38 | |
| 39 | // Creates a client |
| 40 | const storage = new Storage(); |
| 41 | |
| 42 | async function deleteNotification() { |
| 43 | try { |
| 44 | // Deletes the notification from the bucket |
| 45 | await storage.bucket(bucketName).notification(notificationId).delete(); |
| 46 | |
| 47 | console.log(`Notification ${notificationId} deleted.`); |
| 48 | } catch (error) { |
| 49 | console.error( |
| 50 | 'Error executing delete notification:', |
| 51 | error.message || error |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | deleteNotification(); |
| 57 | // [END storage_delete_bucket_notification] |
| 58 | } |
| 59 | main(...process.argv.slice(2)); |
no test coverage detected