A URL that can be used to access the notification using the REST API.
Returns
(String)
#bucket
defbucket()->String
The name of the Bucket to which this
notification belongs.
Returns
(String) — the current value of bucket
#custom_attrs
defcustom_attrs()->Hash(String=>String)
The custom attributes of this notification. An optional list of
additional attributes to attach to each Cloud Pub/Sub message
published for this notification subscription.
Returns
(Hash(String => String))
#delete
defdelete()->Boolean
Permanently deletes the notification.
The API call to delete the notification may be retried under certain
conditions. See Google::Cloud#storage to control this behavior.
Returns
(Boolean) — Returns true if the notification was deleted.
The event types of this notification. If present, messages will only
be sent for the listed event types. If empty, messages will be sent
for all event types.
The following is a list of event types currently supported by Cloud
Storage:
OBJECT_FINALIZE - Sent when a new object (or a new generation of
an existing object) is successfully created in the bucket. This
includes copying or rewriting an existing object. A failed upload
does not trigger this event.
OBJECT_METADATA_UPDATE - Sent when the metadata of an existing
object changes.
OBJECT_DELETE - Sent when an object has been permanently deleted.
This includes objects that are overwritten or are deleted as part of
the bucket's lifecycle configuration. For buckets with object
versioning enabled, this is not sent when an object is archived (see
OBJECT_ARCHIVE), even if archival occurs via the File#delete
method.
OBJECT_ARCHIVE - Only sent when a bucket has enabled object
versioning. This event indicates that the live version of an object
has become an archived version, either because it was archived or
because it was overwritten by the upload of an object of the same
name.
Important: Additional event types may be released later. Client code
should either safely ignore unrecognized event types, or else
explicitly specify in their notification configuration which event
types they are prepared to accept.
Returns
(Array<String>)
#id
defid()->String
The ID of the notification.
Returns
(String)
#kind
defkind()->String
The kind of item this is.
For notifications, this is always storage#notification.
Returns
(String)
#payload
defpayload()->String
The desired content of the Pub/Sub message payload. Acceptable values
are:
JSON_API_V1 - The payload will be a UTF-8 string containing the
resource
representation
of the file's metadata.
NONE - No payload is included with the notification.
Returns
(String)
#prefix
defprefix()->String
The file name prefix of this notification. If present, only apply
this notification configuration to file names that begin with this
prefix.
Returns
(String)
#topic
deftopic()->String
The Cloud Pub/Sub topic to which this subscription publishes.
Formatted as:
//pubsub.googleapis.com/projects/{project-id}/topics/{my-topic}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Storage API - Class Google::Cloud::Storage::Notification (v1.57.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.57.0 (latest)](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Notification)\n- [1.56.0](/ruby/docs/reference/google-cloud-storage/1.56.0/Google-Cloud-Storage-Notification)\n- [1.55.0](/ruby/docs/reference/google-cloud-storage/1.55.0/Google-Cloud-Storage-Notification)\n- [1.54.0](/ruby/docs/reference/google-cloud-storage/1.54.0/Google-Cloud-Storage-Notification)\n- [1.53.0](/ruby/docs/reference/google-cloud-storage/1.53.0/Google-Cloud-Storage-Notification)\n- [1.52.0](/ruby/docs/reference/google-cloud-storage/1.52.0/Google-Cloud-Storage-Notification)\n- [1.51.0](/ruby/docs/reference/google-cloud-storage/1.51.0/Google-Cloud-Storage-Notification)\n- [1.50.0](/ruby/docs/reference/google-cloud-storage/1.50.0/Google-Cloud-Storage-Notification)\n- [1.49.0](/ruby/docs/reference/google-cloud-storage/1.49.0/Google-Cloud-Storage-Notification)\n- [1.48.1](/ruby/docs/reference/google-cloud-storage/1.48.1/Google-Cloud-Storage-Notification)\n- [1.47.0](/ruby/docs/reference/google-cloud-storage/1.47.0/Google-Cloud-Storage-Notification)\n- [1.46.0](/ruby/docs/reference/google-cloud-storage/1.46.0/Google-Cloud-Storage-Notification)\n- [1.45.0](/ruby/docs/reference/google-cloud-storage/1.45.0/Google-Cloud-Storage-Notification)\n- [1.44.0](/ruby/docs/reference/google-cloud-storage/1.44.0/Google-Cloud-Storage-Notification)\n- [1.43.0](/ruby/docs/reference/google-cloud-storage/1.43.0/Google-Cloud-Storage-Notification)\n- [1.42.0](/ruby/docs/reference/google-cloud-storage/1.42.0/Google-Cloud-Storage-Notification)\n- [1.41.0](/ruby/docs/reference/google-cloud-storage/1.41.0/Google-Cloud-Storage-Notification)\n- [1.40.0](/ruby/docs/reference/google-cloud-storage/1.40.0/Google-Cloud-Storage-Notification)\n- [1.39.0](/ruby/docs/reference/google-cloud-storage/1.39.0/Google-Cloud-Storage-Notification)\n- [1.38.0](/ruby/docs/reference/google-cloud-storage/1.38.0/Google-Cloud-Storage-Notification)\n- [1.37.0](/ruby/docs/reference/google-cloud-storage/1.37.0/Google-Cloud-Storage-Notification)\n- [1.36.2](/ruby/docs/reference/google-cloud-storage/1.36.2/Google-Cloud-Storage-Notification)\n- [1.35.0](/ruby/docs/reference/google-cloud-storage/1.35.0/Google-Cloud-Storage-Notification) \nReference documentation and code samples for the Cloud Storage API class Google::Cloud::Storage::Notification.\n\nNotification\n------------\n\nRepresents a Pub/Sub notification subscription for a Cloud Storage\nbucket.\n\nSee [Bucket#create_notification](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket#Google__Cloud__Storage__Bucket_create_notification_instance_ \"Google::Cloud::Storage::Bucket#create_notification (method)\"), [Bucket#notifications](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket#Google__Cloud__Storage__Bucket_notifications_instance_ \"Google::Cloud::Storage::Bucket#notifications (method)\"), and\n[Bucket#notification](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket#Google__Cloud__Storage__Bucket_notification_instance_ \"Google::Cloud::Storage::Bucket#notification (method)\"). \n\nInherits\n--------\n\n- Object\n\nExample\n-------\n\n```ruby\nrequire \"google/cloud/pubsub\"\nrequire \"google/cloud/storage\"\n\npubsub = Google::Cloud::Pubsub.new\nstorage = Google::Cloud::Storage.new\n\ntopic = pubsub.create_topic \"my-topic\"\ntopic.policy do |p|\n p.add \"roles/pubsub.publisher\",\n \"serviceAccount:#{storage.service_account_email}\"\nend\n\nbucket = storage.bucket \"my-bucket\"\n\nnotification = bucket.create_notification topic.name\n```\n\nMethods\n-------\n\n### #api_url\n\n def api_url() -\u003e String\n\nA URL that can be used to access the notification using the REST API. \n**Returns**\n\n- (String)\n\n### #bucket\n\n def bucket() -\u003e String\n\nThe name of the [Bucket](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket \"Google::Cloud::Storage::Bucket (class)\") to which this\nnotification belongs. \n**Returns**\n\n- (String) --- the current value of bucket\n\n### #custom_attrs\n\n def custom_attrs() -\u003e Hash(String =\u003e String)\n\nThe custom attributes of this notification. An optional list of\nadditional attributes to attach to each Cloud Pub/Sub message\npublished for this notification subscription. \n**Returns**\n\n- (Hash(String =\\\u003e String))\n\n### #delete\n\n def delete() -\u003e Boolean\n\nPermanently deletes the notification.\n\n\n\u003cbr /\u003e\n\nThe API call to delete the notification may be retried under certain\nconditions. See [Google::Cloud#storage](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud#Google__Cloud_storage_instance_ \"Google::Cloud#storage (method)\") to control this behavior. \n**Returns**\n\n- (Boolean) --- Returns `true` if the notification was deleted.\n**Example** \n\n```ruby\nrequire \"google/cloud/storage\"\n\nstorage = Google::Cloud::Storage.new\n\nbucket = storage.bucket \"my-bucket\"\nnotification = bucket.notification \"1\"\nnotification.delete\n```\n\n### #event_types\n\n def event_types() -\u003e Array\u003cString\u003e\n\nThe event types of this notification. If present, messages will only\nbe sent for the listed event types. If empty, messages will be sent\nfor all event types.\n\n\nThe following is a list of event types currently supported by Cloud\nStorage:\n\n- `OBJECT_FINALIZE` - Sent when a new object (or a new generation of an existing object) is successfully created in the bucket. This includes copying or rewriting an existing object. A failed upload does not trigger this event.\n- `OBJECT_METADATA_UPDATE` - Sent when the metadata of an existing object changes.\n- `OBJECT_DELETE` - Sent when an object has been permanently deleted. This includes objects that are overwritten or are deleted as part of the bucket's lifecycle configuration. For buckets with object versioning enabled, this is not sent when an object is archived (see `OBJECT_ARCHIVE`), even if archival occurs via the [File#delete](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-File#Google__Cloud__Storage__File_delete_instance_ \"Google::Cloud::Storage::File#delete (method)\") method.\n- `OBJECT_ARCHIVE` - Only sent when a bucket has enabled object versioning. This event indicates that the live version of an object has become an archived version, either because it was archived or because it was overwritten by the upload of an object of the same name.\n\n\u003cbr /\u003e\n\nImportant: Additional event types may be released later. Client code\nshould either safely ignore unrecognized event types, or else\nexplicitly specify in their notification configuration which event\ntypes they are prepared to accept. \n**Returns**\n\n- (Array\\\u003cString\\\u003e)\n\n### #id\n\n def id() -\u003e String\n\nThe ID of the notification. \n**Returns**\n\n- (String)\n\n### #kind\n\n def kind() -\u003e String\n\nThe kind of item this is.\nFor notifications, this is always storage#notification. \n**Returns**\n\n- (String)\n\n### #payload\n\n def payload() -\u003e String\n\nThe desired content of the Pub/Sub message payload. Acceptable values\nare:\n\n- `JSON_API_V1` - The payload will be a UTF-8 string containing the [resource\n representation](https://cloud.google.com/storage/docs/json_api/v1/objects#resource-representations) of the file's metadata.\n- `NONE` - No payload is included with the notification. \n**Returns**\n\n- (String)\n\n### #prefix\n\n def prefix() -\u003e String\n\nThe file name prefix of this notification. If present, only apply\nthis notification configuration to file names that begin with this\nprefix. \n**Returns**\n\n- (String)\n\n### #topic\n\n def topic() -\u003e String\n\nThe Cloud Pub/Sub topic to which this subscription publishes.\nFormatted as:\n`//pubsub.googleapis.com/projects/{project-id}/topics/{my-topic}` \n**Returns**\n\n- (String)"]]