Cloud Storage Client - Class Notification (1.32.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\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.

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

Delete the notification.

Example:

$notification->delete();
Parameter
NameDescription
options array

[optional]

Returns
TypeDescription
void

info

Retrieves the notification's details. If no notification data is cached a network request will be made to retrieve it.

Example:

$info = $notification->info();
echo $info['topic'];
Parameter
NameDescription
options array

[optional]

Returns
TypeDescription
array

reload

Triggers a network request to reload the notification's details.

Example:

$notification->reload();
$info = $notification->info();
echo $info['topic'];
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