Cloud Storage Client - Class Notification (1.34.0)

Reference documentation and code samples for the Cloud Storage Client class Notification.

Cloud Pub/Sub Notifications sends information about changes to objects in your buckets to Google Cloud Pub/Sub, where the information is added to a Cloud Pub/Sub topic of your choice in the form of messages. For example, you can track objects that are created and deleted in your bucket. Each notification contains information describing both the event that triggered it and the object that changed.

To utilize this class and see more examples, please see the relevant notifications based methods exposed on Google\Cloud\Storage\Bucket.

Example:

use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient();

// Fetch an existing notification by ID.
$bucket = $storage->bucket('my-bucket');
$notification = $bucket->notification('2482');

Namespace

Google \ Cloud \ Storage

Methods

__construct

Parameters
NameDescription
connection Google\Cloud\Storage\Connection\ConnectionInterface

Represents a connection to Cloud Storage. This object is created by StorageClient, and should not be instantiated outside of this client.

id string

The notification's ID.

bucket string

The name of the bucket associated with this notification.

info array

[optional] The notification's metadata.

exists

Check whether or not the notification exists.

Example:

if ($notification->exists()) {
    echo 'Notification exists!';
}
Parameter
NameDescription
options array

Configuration options.

Returns
TypeDescription
bool

delete

Parameter
NameDescription
options array

[optional]

Returns
TypeDescription
void

info

Parameter
NameDescription
options array

[optional]

Returns
TypeDescription
array

reload

Parameter
NameDescription
options array

[optional]

Returns
TypeDescription
array

id

Retrieves the notification's ID.

Example:

echo $notification->id();
Returns
TypeDescription
string

identity

Retrieves the notification's identity.

Example:

echo $notification->identity()['bucket'];
Returns
TypeDescription
array