1.62.2 (latest) 1.62.1 1.61.0 1.60.0 1.59.0 1.58.0 1.57.1 1.56.0 1.55.0 1.54.0 1.53.0 1.52.0 1.51.0 1.50.0 1.49.0 1.48.1 1.47.0 1.46.0 1.45.0 1.44.0 1.43.0 1.42.0 1.41.0 1.40.0 1.39.0 1.38.0 1.37.0 1.36.2 1.35.0 Reference documentation and code samples for the Cloud Storage API class Google::Cloud::Storage::Notification.

## Notification

Represents a Pub/Sub notification subscription for a Cloud Storage
bucket.

See [Bucket#create_notification](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket.md.txt#Google__Cloud__Storage__Bucket_create_notification_instance_ "Google::Cloud::Storage::Bucket#create_notification (method)"), [Bucket#notifications](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket.md.txt#Google__Cloud__Storage__Bucket_notifications_instance_ "Google::Cloud::Storage::Bucket#notifications (method)"), and
[Bucket#notification](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket.md.txt#Google__Cloud__Storage__Bucket_notification_instance_ "Google::Cloud::Storage::Bucket#notification (method)").

## Inherits

- Object

## Example

```ruby
require "google/cloud/pubsub"
require "google/cloud/storage"

pubsub = Google::Cloud::Pubsub.new
storage = Google::Cloud::Storage.new

topic = pubsub.create_topic "my-topic"
topic.policy do |p|
  p.add "roles/pubsub.publisher",
        "serviceAccount:#{storage.service_account_email}"
end

bucket = storage.bucket "my-bucket"

notification = bucket.create_notification topic.name
```

## Methods

### #api_url

```ruby
def api_url() -> String
```
A URL that can be used to access the notification using the REST API.
**Returns**

- (String)

### #bucket

```ruby
def bucket() -> String
```
The name of the [Bucket](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket.md.txt "Google::Cloud::Storage::Bucket (class)") to which this
notification belongs.
**Returns**

- (String) --- the current value of bucket

### #custom_attrs

```ruby
def custom_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

```ruby
def delete() -> Boolean
```
Permanently deletes the notification.


<br />

The API call to delete the notification may be retried under certain
conditions. See [Google::Cloud#storage](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud.md.txt#Google__Cloud_storage_instance_ "Google::Cloud#storage (method)") to control this behavior.
**Returns**

- (Boolean) --- Returns `true` if the notification was deleted.
**Example**

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"
notification = bucket.notification "1"
notification.delete
```

### #event_types

```ruby
def event_types() -> Array<String>
```
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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-File.md.txt#Google__Cloud__Storage__File_delete_instance_ "Google::Cloud::Storage::File#delete (method)") 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.

<br />

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

```ruby
def id() -> String
```
The ID of the notification.
**Returns**

- (String)

### #kind

```ruby
def kind() -> String
```
The kind of item this is.
For notifications, this is always storage#notification.
**Returns**

- (String)

### #payload

```ruby
def payload() -> 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](https://cloud.google.com/storage/docs/json_api/v1/objects#resource-representations) of the file's metadata.
- `NONE` - No payload is included with the notification.
**Returns**

- (String)

### #prefix

```ruby
def prefix() -> 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

```ruby
def topic() -> String
```
The Cloud Pub/Sub topic to which this subscription publishes.
Formatted as:
`//pubsub.googleapis.com/projects/{project-id}/topics/{my-topic}`
**Returns**

- (String)