Delete a Pub/Sub notification

Delete a Pub/Sub notification from a Cloud Storage storage bucket.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


For more information, see the Cloud Storage C++ API reference documentation.

namespace gcs = ::google::cloud::storage;
[](gcs::Client client, std::string const& bucket_name,
   std::string const& notification_id) {
  google::cloud::Status status =
      client.DeleteNotification(bucket_name, notification_id);
  if (!status.ok()) throw std::runtime_error(status.message());

  std::cout << "Successfully deleted notification " << notification_id
            << " on bucket " << bucket_name << "\n";


For more information, see the Cloud Storage Node.js API reference documentation.

 * TODO(developer): Uncomment the following lines before running the sample.
// The ID of your GCS bucket
// const bucketName = 'your-unique-bucket-name';

// The ID of the notification
// const notificationId = '1';

// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');

// Creates a client
const storage = new Storage();

async function deleteNotification() {
  // Deletes the notification from the bucket
  await storage.bucket(bucketName).notification(notificationId).delete();

  console.log(`Notification ${notificationId} deleted.`);



For more information, see the Cloud Storage Python API reference documentation.

from import storage

def delete_bucket_notification(bucket_name, notification_id):
    """Deletes a notification configuration for a bucket."""
    # The ID of your GCS bucket
    # bucket_name = "your-bucket-name"
    # The ID of the notification
    # notification_id = "your-notification-id"

    storage_client = storage.Client()
    bucket = storage_client.bucket(bucket_name)
    notification = bucket.notification(notification_id=notification_id)

    print(f"Successfully deleted notification with ID {notification_id} for bucket {bucket_name}")

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.