notification - Configure object change notification
Synopsis
gsutil notification watchbucket [-i id] [-t token] app_url bucket_url... gsutil notification stopchannel channel_id resource_id
Description
The notification command can be used to configure notifications. For more information on the Object Change Notification feature, please see: https://developers.google.com/storage/docs/object-change-notification
The notification command has two sub-commands:
Watchbucket
The watchbucket sub-command can be used to watch a bucket for object changes. A service account must be used when running this command.
The app_url parameter must be an HTTPS URL to an application that will be notified of changes to any object in the bucket. The URL endpoint must be a verified domain on your project. See Notification Authorization for details.
The optional id parameter can be used to assign a unique identifier to the created notification channel. If not provided, a random UUID string will be generated.
The optional token parameter can be used to validate notifications events. To do this, set this custom token and store it to later verify that notification events contain the client token you expect.
Stopchannel
The stopchannel sub-command can be used to stop sending change events to a notification channel.
The channel_id and resource_id parameters should match the values from the response of a bucket watch request.
Examples
Watch the bucket example-bucket for changes and send notifications to an application server running at example.com:
gsutil notification watchbucket https://example.com/notify \
gs://example-bucket
Assign identifier my-channel-id to the created notification channel:
gsutil notification watchbucket -i my-channel-id \
https://example.com/notify gs://example-bucket
Set a custom client token that will be included with each notification event:
gsutil notification watchbucket -t my-client-token \
https://example.com/notify gs://example-bucket
Stop the notification event channel with channel identifier channel1 and resource identifier SoGqan08XDIFWr1Fv_nGpRJBHh8:
gsutil notification stopchannel channel1 SoGqan08XDIFWr1Fv_nGpRJBHh8
Notifications And Parallel Composite Uploads
By default, gsutil enables parallel composite uploads for large files (see gsutil help cp ), which means that an upload of a large object can result in multiple temporary component objects being uploaded before the actual intended object is created. Any subscriber to notifications for this bucket will then see a notification for each of these components being created and deleted. If this is a concern for you, note that parallel composite uploads can be disabled by setting “parallel_composite_upload_threshold = 0” in your boto config file.