@@ -225,26 +225,43 @@ To run this sample:
225
225
226
226
$ python notification_polling.py
227
227
228
- usage: notification_polling.py [-h] subscription
228
+ usage: notification_polling.py [-h] project subscription
229
229
230
- This application demonstrates how to poll for GCS notifications from a Cloud
231
- Pub/Sub subscription, parse the incoming message, and acknowledge the
232
- successful processing of the message. This application will work with any
233
- subscription configured for pull rather than push notifications. If you do not
234
- already have notifications configured, you may consult the docs at
230
+ This application demonstrates how to poll for GCS notifications from a
231
+ Cloud Pub/Sub subscription, parse the incoming message, and acknowledge the
232
+ successful processing of the message.
233
+
234
+ This application will work with any subscription configured for pull rather
235
+ than push notifications. If you do not already have notifications configured,
236
+ you may consult the docs at
235
237
https://cloud.google.com/storage/docs/reporting-changes or follow the steps
236
- below: 1. Activate the Google Cloud Pub/Sub API, if you have not already done
237
- so. https://console.cloud.google.com/flows/enableapi? apiid=pubsub 2. Create a
238
- Google Cloud Storage bucket: $ gsutil mb gs://testbucket 3. Create a Cloud
239
- Pub/Sub topic and publish bucket notifications there: $ gsutil notification
240
- create -f json -t testtopic gs://testbucket 4. Create a subscription for your
241
- new topic: $ gcloud beta pubsub subscriptions create testsubscription
242
- --topic=testtopic 5. Run this program: $ python notification_polling
243
- testsubscription 6. While the program is running, upload and delete some files
244
- in the testbucket bucket (you could use the console or gsutil) and watch as
245
- changes scroll by in the app.
238
+ below:
239
+
240
+ 1. First, follow the common setup steps for these snippets, specically
241
+ configuring auth and installing dependencies. See the README' s "Setup"
242
+ section.
243
+
244
+ 2. Activate the Google Cloud Pub/Sub API, if you have not already done so.
245
+ https://console.cloud.google.com/flows/enableapi?apiid=pubsub
246
+
247
+ 3. Create a Google Cloud Storage bucket:
248
+ $ gsutil mb gs://testbucket
249
+
250
+ 4. Create a Cloud Pub/Sub topic and publish bucket notifications there:
251
+ $ gsutil notification create -f json -t testtopic gs://testbucket
252
+
253
+ 5. Create a subscription for your new topic:
254
+ $ gcloud beta pubsub subscriptions create testsubscription --topic=testtopic
255
+
256
+ 6. Run this program:
257
+ $ python notification_polling my-project-id testsubscription
258
+
259
+ 7. While the program is running, upload and delete some files in the testbucket
260
+ bucket (you could use the console or gsutil) and watch as changes scroll by
261
+ in the app.
246
262
247
263
positional arguments:
264
+ project The ID of the project that owns the subscription
248
265
subscription The ID of the Pub/Sub subscription
249
266
250
267
optional arguments:
0 commit comments