Skip to content

Commit e70714a

Browse files
plamutJon Wayne Parrottdpebotjmdobrywaprin
authored andcommitted
samples: add samples from pubsub/cloud-client (googleapis#134)
* Add pubsub publisher and subscriber samples Change-Id: I38b90c10aef72c37188c4520897302933b9d2ea7 * Update readme Change-Id: Ie95e2e1556a8d97b5321dc86bf8de431aa36a2d5 * Add pubsub iam samples Change-Id: I12c407d3cdf4a3f9736dfaeca6f20b31df6d310a * Fix lint issue Change-Id: Ifebdab0b974cc3d3fe8900a23ca7416fed9e026a * Auto-update dependencies. [(googleapis#540)](GoogleCloudPlatform/python-docs-samples#540) * Auto-update dependencies. [(googleapis#542)](GoogleCloudPlatform/python-docs-samples#542) * Move to google-cloud [(googleapis#544)](GoogleCloudPlatform/python-docs-samples#544) * Add new "quickstart" samples [(googleapis#547)](GoogleCloudPlatform/python-docs-samples#547) * Quickstart tests [(googleapis#569)](GoogleCloudPlatform/python-docs-samples#569) * Add tests for quickstarts * Update secrets * Generate readmes for most service samples [(googleapis#599)](GoogleCloudPlatform/python-docs-samples#599) * Update samples to support latest Google Cloud Python [(googleapis#656)](GoogleCloudPlatform/python-docs-samples#656) * Auto-update dependencies. [(googleapis#715)](GoogleCloudPlatform/python-docs-samples#715) * Fix pubusb tests Change-Id: I7dfe60b0f1240dc58a664968fd97ca5a8fa1109d * Auto-update dependencies. [(googleapis#825)](GoogleCloudPlatform/python-docs-samples#825) * Auto-update dependencies. [(googleapis#876)](GoogleCloudPlatform/python-docs-samples#876) * Fix reference to our testing tools * Re-generate all readmes * Auto-update dependencies. [(googleapis#922)](GoogleCloudPlatform/python-docs-samples#922) * Auto-update dependencies. * Fix pubsub iam samples * Fix README rst links [(googleapis#962)](GoogleCloudPlatform/python-docs-samples#962) * Fix README rst links * Update all READMEs * Auto-update dependencies. [(googleapis#1004)](GoogleCloudPlatform/python-docs-samples#1004) * Auto-update dependencies. * Fix natural language samples * Fix pubsub iam samples * Fix language samples * Fix bigquery samples * Auto-update dependencies. [(googleapis#1055)](GoogleCloudPlatform/python-docs-samples#1055) * Auto-update dependencies. * Explicitly use latest bigtable client Change-Id: Id71e9e768f020730e4ca9514a0d7ebaa794e7d9e * Revert language update for now Change-Id: I8867f154e9a5aae00d0047c9caf880e5e8f50c53 * Remove pdb. smh Change-Id: I5ff905fadc026eebbcd45512d4e76e003e3b2b43 * Update pubsub samples [(googleapis#1092)](GoogleCloudPlatform/python-docs-samples#1092) * Fix argpraser for pubsub subscriber Change-Id: I776863091846ee8ff8a70078c8b8d5498cf81ed6 * Add comment about result blocking in pubsub samples Change-Id: I149fc1242ceb6b2cff8eae7ef18b364dd5c26566 * Auto-update dependencies. [(googleapis#1097)](GoogleCloudPlatform/python-docs-samples#1097) * Update all generated readme auth instructions [(googleapis#1121)](GoogleCloudPlatform/python-docs-samples#1121) Change-Id: I03b5eaef8b17ac3dc3c0339fd2c7447bd3e11bd2 * Added Link to Python Setup Guide [(googleapis#1158)](GoogleCloudPlatform/python-docs-samples#1158) * Update Readme.rst to add Python setup guide As requested in b/64770713. This sample is linked in documentation https://cloud.google.com/bigtable/docs/scaling, and it would make more sense to update the guide here than in the documentation. * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update install_deps.tmpl.rst * Updated readmegen scripts and re-generated related README files * Fixed the lint error * Auto-update dependencies. [(googleapis#1138)](GoogleCloudPlatform/python-docs-samples#1138) * Fix a few more lint issues Change-Id: I0d420f3053f391fa225e4b8179e45fd1138f5c65 * Add Snippet for Listing All Subscriptions in a Project [(googleapis#1169)](GoogleCloudPlatform/python-docs-samples#1169) * Auto-update dependencies. [(googleapis#1186)](GoogleCloudPlatform/python-docs-samples#1186) * Auto-update dependencies. [(googleapis#1234)](GoogleCloudPlatform/python-docs-samples#1234) * Auto-update dependencies. * Drop pytest-logcapture as it's no longer needed Change-Id: Ia8b9e8aaf248e9770db6bc4842a4532df8383893 * Auto-update dependencies. [(googleapis#1239)](GoogleCloudPlatform/python-docs-samples#1239) * Added "Open in Cloud Shell" buttons to README files [(googleapis#1254)](GoogleCloudPlatform/python-docs-samples#1254) * Auto-update dependencies. [(googleapis#1263)](GoogleCloudPlatform/python-docs-samples#1263) * Auto-update dependencies. [(googleapis#1272)](GoogleCloudPlatform/python-docs-samples#1272) * Auto-update dependencies. * Update requirements.txt * Auto-update dependencies. [(googleapis#1282)](GoogleCloudPlatform/python-docs-samples#1282) * Auto-update dependencies. * Fix storage acl sample Change-Id: I413bea899fdde4c4859e4070a9da25845b81f7cf * Add listen for errors sample. [(googleapis#1306)](GoogleCloudPlatform/python-docs-samples#1306) * Add listen for errors sample. * Update subscriber.py * Update subscriber.py * Fix subscription.open get called twice in the client libraries [(googleapis#1321)](GoogleCloudPlatform/python-docs-samples#1321) * Add tests for creating push subscription. [(googleapis#1332)](GoogleCloudPlatform/python-docs-samples#1332) This is a separate PR from actually adding the sample, which is in GoogleCloudPlatform/python-docs-samples#1331. * Add create push subscription sample. [(googleapis#1331)](GoogleCloudPlatform/python-docs-samples#1331) * Update API version and body. [(googleapis#1326)](GoogleCloudPlatform/python-docs-samples#1326) The API version should be v1, not v1beta1. Also remove the unnecessary 'data' field from the body and just use 'binary_data'. * Add sample for updating a subscription. [(googleapis#1335)](GoogleCloudPlatform/python-docs-samples#1335) * Change update_subscription to change endpoint URL. [(googleapis#1344)](GoogleCloudPlatform/python-docs-samples#1344) The documentation specifies that the update subscription commands show how to update an endpoint URL: https://cloud.google.com/pubsub/docs/admin#update_a_subscription. * Auto-update dependencies. [(googleapis#1359)](GoogleCloudPlatform/python-docs-samples#1359) * Auto-update dependencies. [(googleapis#1389)](GoogleCloudPlatform/python-docs-samples#1389) * Added sample for publishing/receiving messages with custom attributes [(googleapis#1409)](GoogleCloudPlatform/python-docs-samples#1409) * Auto-update dependencies. * Regenerate the README files and fix the Open in Cloud Shell link for some samples [(#1441)](GoogleCloudPlatform/python-docs-samples#1441) * Update READMEs to fix numbering and add git clone [(#1464)](GoogleCloudPlatform/python-docs-samples#1464) * PubSub: adds region tags and updates existing to standard [(#1491)](GoogleCloudPlatform/python-docs-samples#1491) * Pubsub: Add missing region tag [(#1498)](GoogleCloudPlatform/python-docs-samples#1498) * Add the Pub/Sub handle_publisher_error sample [(#1440)](GoogleCloudPlatform/python-docs-samples#1440) * Add the Pub/Sub handle_publisher_error sample * Update requirements.txt * Update publisher.py * Update publisher.py * Added region tag * Modified publisher with error handling [(#1568)](GoogleCloudPlatform/python-docs-samples#1568) * Updated google-cloud-pubsub to version 0.35 [(#1624)](GoogleCloudPlatform/python-docs-samples#1624) * Updated library version * Rewrote test for publish with error handler * Custom _publish function in test prints no 'Attributes' * Added timeout in error handling [(#1636)](GoogleCloudPlatform/python-docs-samples#1636) * Auto-update dependencies. [(#1658)](GoogleCloudPlatform/python-docs-samples#1658) * Auto-update dependencies. * Rollback appengine/standard/bigquery/. * Rollback appengine/standard/iap/. * Rollback bigtable/metricscaler. * Rolledback appengine/flexible/datastore. * Rollback dataproc/ * Rollback jobs/api_client * Rollback vision/cloud-client. * Rollback functions/ocr/app. * Rollback iot/api-client/end_to_end_example. * Rollback storage/cloud-client. * Rollback kms/api-client. * Rollback dlp/ * Rollback bigquery/cloud-client. * Rollback iot/api-client/manager. * Rollback appengine/flexible/cloudsql_postgresql. * Added sample for Pub/Sub synchronous pull subscriber [(#1673)](GoogleCloudPlatform/python-docs-samples#1673) * Added sample for synchronous pull * Updated variable name [(#1680)](GoogleCloudPlatform/python-docs-samples#1680) * Fixed return object from `subscriber.subscribe()` [(#1685)](GoogleCloudPlatform/python-docs-samples#1685) * Pub/Sub: synchronous pull with lease management [(#1701)](GoogleCloudPlatform/python-docs-samples#1701) * Synchronous pull with lease management * Updated library version * Pub/Sub: moved import statements inside region tags [(#1753)](GoogleCloudPlatform/python-docs-samples#1753) * Moved import stataments inside region tags * Explained topic and subscription path methods * Pub/Sub end-to-end sample [(#1800)](GoogleCloudPlatform/python-docs-samples#1800) * Created new end-to-end sample, moved old sample * Add space around operator * Add test for updating a subscription. [(googleapis#1336)](GoogleCloudPlatform/python-docs-samples#1336) Tests for GoogleCloudPlatform/python-docs-samples#1335. Using ack_deadline_seconds as the example. * Fix update test to use new endpoint [(#1925)](GoogleCloudPlatform/python-docs-samples#1925) * Fix update test to use new endpoint * Handle subscription already exists Previous deletions don't always succeed * Use a new endpoint for update * Auto-update dependencies. [(#1980)](GoogleCloudPlatform/python-docs-samples#1980) * Auto-update dependencies. * Update requirements.txt * Update requirements.txt * Cloud Pub/Sub Quickstart V2 [(#2004)](GoogleCloudPlatform/python-docs-samples#2004) * Quickstart V2 * Adopts Kir's suggestions * Adopted Tim's suggestions * proper resource deletion during teardown * Pub/Sub: publish with error-handling comments [(#2222)](GoogleCloudPlatform/python-docs-samples#2222) * Resolve all futures [(#2231)](GoogleCloudPlatform/python-docs-samples#2231) * Pub/Sub: add publish retry sample [(#2273)](GoogleCloudPlatform/python-docs-samples#2273) * Publish retry sample * double to single quotes * double to single quotes * license year * Fix a TODO comment on pubsub/cloud-client/subscriber.py [(#2302)](GoogleCloudPlatform/python-docs-samples#2302) * Print actual number of messages pulled [(#2078)](GoogleCloudPlatform/python-docs-samples#2078) * Print actual number of messages pulled * Pub/Sub: fix subscriber async region tag mistake [(#2334)](GoogleCloudPlatform/python-docs-samples#2334) * Pub/Sub: update retry settings in sample [(#2395)](GoogleCloudPlatform/python-docs-samples#2395) * Pub/Sub: improve pub.py [(#2403)](GoogleCloudPlatform/python-docs-samples#2403) * print number of messages published * two nit's * Adds updates for samples profiler ... vision [(#2439)](GoogleCloudPlatform/python-docs-samples#2439) * Pub/Sub: update how subscriber client listens to StreamingPullFuture [(#2475)](GoogleCloudPlatform/python-docs-samples#2475) * update sub.py & requirements.txt * fix flaky subscriber test with separate subscriptions * Pub/Sub: update how to test with mock [(#2555)](GoogleCloudPlatform/python-docs-samples#2555) * Update test with mock * Clean up resources after tests * Use unique resource names avoid test failures * Delete subscriptions in cleanup phase * Ensure unique topic name * Update assert to remove bytestring notation * Rewrite PubSubToGCS test using dataflow testing module * Pub/Sub: remove infinite while loops in subscriber examples [(#2604)](GoogleCloudPlatform/python-docs-samples#2604) * use result() on streaming pull futures instead of infinite while * remove unused imports * Pub/Sub: add timeout in argparse [(#2637)](GoogleCloudPlatform/python-docs-samples#2637) * Auto-update dependencies. [(#2005)](GoogleCloudPlatform/python-docs-samples#2005) * Auto-update dependencies. * Revert update of appengine/flexible/datastore. * revert update of appengine/flexible/scipy * revert update of bigquery/bqml * revert update of bigquery/cloud-client * revert update of bigquery/datalab-migration * revert update of bigtable/quickstart * revert update of compute/api * revert update of container_registry/container_analysis * revert update of dataflow/run_template * revert update of datastore/cloud-ndb * revert update of dialogflow/cloud-client * revert update of dlp * revert update of functions/imagemagick * revert update of functions/ocr/app * revert update of healthcare/api-client/fhir * revert update of iam/api-client * revert update of iot/api-client/gcs_file_to_device * revert update of iot/api-client/mqtt_example * revert update of language/automl * revert update of run/image-processing * revert update of vision/automl * revert update testing/requirements.txt * revert update of vision/cloud-client/detect * revert update of vision/cloud-client/product_search * revert update of jobs/v2/api_client * revert update of jobs/v3/api_client * revert update of opencensus * revert update of translate/cloud-client * revert update to speech/cloud-client Co-authored-by: Kurtis Van Gent <[email protected]> Co-authored-by: Doug Mahugh <[email protected]> * remove publish concurrency control sample [(#2960)](GoogleCloudPlatform/python-docs-samples#2960) * Pub/Sub: remove unreferenced samples [(#2986)](GoogleCloudPlatform/python-docs-samples#2986) * remove qs samples * update README * Pub/Sub: add SubscriberClient.close() to examples [(#3118)](GoogleCloudPlatform/python-docs-samples#3118) * Add SubscriberClient.close() to examples. Co-authored-by: Prad Nelluru <[email protected]> Co-authored-by: Prad Nelluru <[email protected]> * Pub/Sub: update publish with batch settings sample [(#3137)](GoogleCloudPlatform/python-docs-samples#3137) * non-blocking publish * remove unused lib * lint * add defaults * Simplify noxfile setup. [(#2806)](GoogleCloudPlatform/python-docs-samples#2806) * chore(deps): update dependency requests to v2.23.0 * Simplify noxfile and add version control. * Configure appengine/standard to only test Python 2.7. * Update Kokokro configs to match noxfile. * Add requirements-test to each folder. * Remove Py2 versions from everything execept appengine/standard. * Remove conftest.py. * Remove appengine/standard/conftest.py * Remove 'no-sucess-flaky-report' from pytest.ini. * Add GAE SDK back to appengine/standard tests. * Fix typo. * Roll pytest to python 2 version. * Add a bunch of testing requirements. * Remove typo. * Add appengine lib directory back in. * Add some additional requirements. * Fix issue with flake8 args. * Even more requirements. * Readd appengine conftest.py. * Add a few more requirements. * Even more Appengine requirements. * Add webtest for appengine/standard/mailgun. * Add some additional requirements. * Add workaround for issue with mailjet-rest. * Add responses for appengine/standard/mailjet. Co-authored-by: Renovate Bot <[email protected]> * chore: remove gcp-devrel-py-tools from iot and pubsub [(#3470)](GoogleCloudPlatform/python-docs-samples#3470) * [iot] chore: remove unused dependency * [pubsub] chore: remove gcp-devrel-py-tools * Update dependency google-cloud-pubsub to v1.4.2 in Storage and Pub/Sub [(#3343)](GoogleCloudPlatform/python-docs-samples#3343) * chore: some lint fixes [(#3748)](GoogleCloudPlatform/python-docs-samples#3748) * chore(deps): update dependency google-cloud-pubsub to v1.4.3 [(#3725)](GoogleCloudPlatform/python-docs-samples#3725) Co-authored-by: Bu Sun Kim <[email protected]> Co-authored-by: Takashi Matsuo <[email protected]> * chore(deps): update dependency google-cloud-pubsub to v1.5.0 [(#3781)](GoogleCloudPlatform/python-docs-samples#3781) Co-authored-by: Bu Sun Kim <[email protected]> * samples: add Pub/Sub dead letter queue samples [(#3904)](GoogleCloudPlatform/python-docs-samples#3904) * fix: make timeout an optional positional arg [(#3938)](GoogleCloudPlatform/python-docs-samples#3938) * fix: make timeout an optional positional arg * place `none` back in function signature Co-authored-by: Bu Sun Kim <[email protected]> * fix: replace name with id in samples [(#3953)](GoogleCloudPlatform/python-docs-samples#3953) * Replace GCLOUD_PROJECT with GOOGLE_CLOUD_PROJECT. [(#4022)](GoogleCloudPlatform/python-docs-samples#4022) * nit: remove redundant/wrong Pub/Sub region tag [(#4027)](GoogleCloudPlatform/python-docs-samples#4027) * Pub/Sub: wrap subscriber in a with block and add comments [(#4070)](GoogleCloudPlatform/python-docs-samples#4070) Use a `with` block to wrap subscriber and describe its purpose. Internal bug: b/157401623 * Update dependency google-cloud-pubsub to v1.6.0 [(#4039)](GoogleCloudPlatform/python-docs-samples#4039) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [google-cloud-pubsub](https://togithub.com/googleapis/python-pubsub) | minor | `==1.5.0` -> `==1.6.0` | --- <details> <summary>googleapis/python-pubsub</summary> [Compare Source](https://togithub.com/googleapis/python-pubsub/compare/v1.5.0...v1.6.0) - Add flow control for message publishing ([#&#8203;96](https://www.github.com/googleapis/python-pubsub/issues/96)) ([06085c4](https://www.github.com/googleapis/python-pubsub/commit/06085c4083b9dccdd50383257799904510bbf3a0)) - Fix PubSub incompatibility with api-core 1.17.0+ ([#&#8203;103](https://www.github.com/googleapis/python-pubsub/issues/103)) ([c02060f](https://www.github.com/googleapis/python-pubsub/commit/c02060fbbe6e2ca4664bee08d2de10665d41dc0b)) - Clarify that Schedulers shouldn't be used with multiple SubscriberClients ([#&#8203;100](https://togithub.com/googleapis/python-pubsub/pull/100)) ([cf9e87c](https://togithub.com/googleapis/python-pubsub/commit/cf9e87c80c0771f3fa6ef784a8d76cb760ad37ef)) - Fix update subscription/snapshot/topic samples ([#&#8203;113](https://togithub.com/googleapis/python-pubsub/pull/113)) ([e62c38b](https://togithub.com/googleapis/python-pubsub/commit/e62c38bb33de2434e32f866979de769382dea34a)) - Re-generated service implementaton using synth: removed experimental notes from the RetryPolicy and filtering features in anticipation of GA, added DetachSubscription (experimental) ([#&#8203;114](https://togithub.com/googleapis/python-pubsub/pull/114)) ([0132a46](https://togithub.com/googleapis/python-pubsub/commit/0132a4680e0727ce45d5e27d98ffc9f3541a0962)) - Incorporate will_accept() checks into publish() ([#&#8203;108](https://togithub.com/googleapis/python-pubsub/pull/108)) ([6c7677e](https://togithub.com/googleapis/python-pubsub/commit/6c7677ecb259672bbb9b6f7646919e602c698570)) </details> --- :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Never, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#GoogleCloudPlatform/python-docs-samples). * chore: update templates Co-authored-by: Jon Wayne Parrott <[email protected]> Co-authored-by: DPE bot <[email protected]> Co-authored-by: Jason Dobry <[email protected]> Co-authored-by: Bill Prin <[email protected]> Co-authored-by: michaelawyu <[email protected]> Co-authored-by: noerog <[email protected]> Co-authored-by: L J <[email protected]> Co-authored-by: Frank Natividad <[email protected]> Co-authored-by: Alix Hamilton <[email protected]> Co-authored-by: michaelawyu <[email protected]> Co-authored-by: Tianzi Cai <[email protected]> Co-authored-by: Charles Engelke <[email protected]> Co-authored-by: Tianzi Cai <[email protected]> Co-authored-by: Keiji Yoshida <[email protected]> Co-authored-by: oli <[email protected]> Co-authored-by: Gus Class <[email protected]> Co-authored-by: Kurtis Van Gent <[email protected]> Co-authored-by: Doug Mahugh <[email protected]> Co-authored-by: Prad Nelluru <[email protected]> Co-authored-by: Prad Nelluru <[email protected]> Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Takashi Matsuo <[email protected]> Co-authored-by: Bu Sun Kim <[email protected]>
1 parent 12cf512 commit e70714a

19 files changed

+2826
-1
lines changed

.github/CODEOWNERS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Code owners file.
2+
# This file controls who is tagged for review for any given pull request.
3+
#
4+
# For syntax help see:
5+
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
6+
7+
8+
# The python-samples-owners team is the default owner for anything not
9+
# explicitly taken by someone else.
10+
11+
/samples/ @anguillanneuf @hongalex @googleapis/python-samples-owners

samples/AUTHORING_GUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md

samples/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/CONTRIBUTING.md

samples/snippets/README.rst

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
2+
.. This file is automatically generated. Do not edit this file directly.
3+
4+
Google Cloud Pub/Sub Python Samples
5+
===============================================================================
6+
7+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
8+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=pubsub/cloud-client/README.rst
9+
10+
11+
This directory contains samples for Google Cloud Pub/Sub. `Google Cloud Pub/Sub`_ is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications.
12+
13+
14+
15+
16+
.. _Google Cloud Pub/Sub: https://cloud.google.com/pubsub/docs
17+
18+
19+
Setup
20+
-------------------------------------------------------------------------------
21+
22+
23+
24+
Authentication
25+
++++++++++++++
26+
27+
This sample requires you to have authentication setup. Refer to the
28+
`Authentication Getting Started Guide`_ for instructions on setting up
29+
credentials for applications.
30+
31+
.. _Authentication Getting Started Guide:
32+
https://cloud.google.com/docs/authentication/getting-started
33+
34+
35+
36+
37+
Install Dependencies
38+
++++++++++++++++++++
39+
40+
#. Clone python-docs-samples and change directory to the sample directory you want to use.
41+
42+
.. code-block:: bash
43+
44+
$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
45+
46+
#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.
47+
48+
.. _Python Development Environment Setup Guide:
49+
https://cloud.google.com/python/setup
50+
51+
#. Create a virtualenv. Samples are compatible with Python 3.6+.
52+
53+
.. code-block:: bash
54+
55+
$ virtualenv env
56+
$ source env/bin/activate
57+
58+
#. Install the dependencies needed to run the samples.
59+
60+
.. code-block:: bash
61+
62+
$ pip install -r requirements.txt
63+
64+
.. _pip: https://pip.pypa.io/
65+
.. _virtualenv: https://virtualenv.pypa.io/
66+
67+
68+
69+
70+
71+
72+
Samples
73+
-------------------------------------------------------------------------------
74+
75+
76+
Quickstart
77+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
78+
79+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
80+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=pubsub/cloud-client/quickstart.py,pubsub/cloud-client/README.rst
81+
82+
83+
84+
85+
To run this sample:
86+
87+
.. code-block:: bash
88+
89+
$ python quickstart.py
90+
91+
92+
93+
94+
Publisher
95+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
96+
97+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
98+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=pubsub/cloud-client/publisher.py,pubsub/cloud-client/README.rst
99+
100+
101+
102+
103+
To run this sample:
104+
105+
.. code-block:: bash
106+
107+
$ python publisher.py
108+
109+
110+
usage: publisher.py [-h]
111+
project_id
112+
{list,create,delete,publish,publish-with-custom-attributes,publish-with-error-handler,publish-with-batch-settings,publish-with-retry-settings}
113+
...
114+
115+
This application demonstrates how to perform basic operations on topics
116+
with the Cloud Pub/Sub API.
117+
118+
For more information, see the README.md under /pubsub and the documentation
119+
at https://cloud.google.com/pubsub/docs.
120+
121+
positional arguments:
122+
project_id Your Google Cloud project ID
123+
{list,create,delete,publish,publish-with-custom-attributes,publish-with-error-handler,publish-with-batch-settings,publish-with-retry-settings}
124+
list Lists all Pub/Sub topics in the given project.
125+
create Create a new Pub/Sub topic.
126+
delete Deletes an existing Pub/Sub topic.
127+
publish Publishes multiple messages to a Pub/Sub topic.
128+
publish-with-custom-attributes
129+
Publishes multiple messages with custom attributes to
130+
a Pub/Sub topic.
131+
publish-with-error-handler
132+
Publishes multiple messages to a Pub/Sub topic with an
133+
error handler.
134+
publish-with-batch-settings
135+
Publishes multiple messages to a Pub/Sub topic with
136+
batch settings.
137+
publish-with-retry-settings
138+
Publishes messages with custom retry settings.
139+
140+
optional arguments:
141+
-h, --help show this help message and exit
142+
143+
144+
145+
146+
147+
Subscribers
148+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
149+
150+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
151+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=pubsub/cloud-client/subscriber.py,pubsub/cloud-client/README.rst
152+
153+
154+
155+
156+
To run this sample:
157+
158+
.. code-block:: bash
159+
160+
$ python subscriber.py
161+
162+
163+
usage: subscriber.py [-h]
164+
project_id
165+
{list-in-topic,list-in-project,create,create-with-dead-letter-policy,create-push,delete,update-push,update-dead-letter-policy,remove-dead-letter-policy,receive,receive-custom-attributes,receive-flow-control,receive-synchronously,receive-synchronously-with-lease,listen-for-errors,receive-messages-with-delivery-attempts}
166+
...
167+
168+
This application demonstrates how to perform basic operations on
169+
subscriptions with the Cloud Pub/Sub API.
170+
171+
For more information, see the README.md under /pubsub and the documentation
172+
at https://cloud.google.com/pubsub/docs.
173+
174+
positional arguments:
175+
project_id Your Google Cloud project ID
176+
{list-in-topic,list-in-project,create,create-with-dead-letter-policy,create-push,delete,update-push,update-dead-letter-policy,remove-dead-letter-policy,receive,receive-custom-attributes,receive-flow-control,receive-synchronously,receive-synchronously-with-lease,listen-for-errors,receive-messages-with-delivery-attempts}
177+
list-in-topic Lists all subscriptions for a given topic.
178+
list-in-project Lists all subscriptions in the current project.
179+
create Create a new pull subscription on the given topic.
180+
create-with-dead-letter-policy
181+
Create a subscription with dead letter policy.
182+
create-push Create a new push subscription on the given topic.
183+
delete Deletes an existing Pub/Sub topic.
184+
update-push Updates an existing Pub/Sub subscription's push
185+
endpoint URL. Note that certain properties of a
186+
subscription, such as its topic, are not modifiable.
187+
update-dead-letter-policy
188+
Update a subscription's dead letter policy.
189+
remove-dead-letter-policy
190+
Remove dead letter policy from a subscription.
191+
receive Receives messages from a pull subscription.
192+
receive-custom-attributes
193+
Receives messages from a pull subscription.
194+
receive-flow-control
195+
Receives messages from a pull subscription with flow
196+
control.
197+
receive-synchronously
198+
Pulling messages synchronously.
199+
receive-synchronously-with-lease
200+
Pulling messages synchronously with lease management
201+
listen-for-errors Receives messages and catches errors from a pull
202+
subscription.
203+
receive-messages-with-delivery-attempts
204+
205+
optional arguments:
206+
-h, --help show this help message and exit
207+
208+
209+
210+
211+
212+
Identity and Access Management
213+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
214+
215+
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
216+
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=pubsub/cloud-client/iam.py,pubsub/cloud-client/README.rst
217+
218+
219+
220+
221+
To run this sample:
222+
223+
.. code-block:: bash
224+
225+
$ python iam.py
226+
227+
228+
usage: iam.py [-h]
229+
project
230+
{get-topic-policy,get-subscription-policy,set-topic-policy,set-subscription-policy,check-topic-permissions,check-subscription-permissions}
231+
...
232+
233+
This application demonstrates how to perform basic operations on IAM
234+
policies with the Cloud Pub/Sub API.
235+
236+
For more information, see the README.md under /pubsub and the documentation
237+
at https://cloud.google.com/pubsub/docs.
238+
239+
positional arguments:
240+
project Your Google Cloud project ID
241+
{get-topic-policy,get-subscription-policy,set-topic-policy,set-subscription-policy,check-topic-permissions,check-subscription-permissions}
242+
get-topic-policy Prints the IAM policy for the given topic.
243+
get-subscription-policy
244+
Prints the IAM policy for the given subscription.
245+
set-topic-policy Sets the IAM policy for a topic.
246+
set-subscription-policy
247+
Sets the IAM policy for a topic.
248+
check-topic-permissions
249+
Checks to which permissions are available on the given
250+
topic.
251+
check-subscription-permissions
252+
Checks to which permissions are available on the given
253+
subscription.
254+
255+
optional arguments:
256+
-h, --help show this help message and exit
257+
258+
259+
260+
261+
262+
263+
264+
265+
266+
The client library
267+
-------------------------------------------------------------------------------
268+
269+
This sample uses the `Google Cloud Client Library for Python`_.
270+
You can read the documentation for more details on API usage and use GitHub
271+
to `browse the source`_ and `report issues`_.
272+
273+
.. _Google Cloud Client Library for Python:
274+
https://googlecloudplatform.github.io/google-cloud-python/
275+
.. _browse the source:
276+
https://github.com/GoogleCloudPlatform/google-cloud-python
277+
.. _report issues:
278+
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
279+
280+
281+
282+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

samples/snippets/README.rst.in

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file is used to generate README.rst
2+
3+
product:
4+
name: Google Cloud Pub/Sub
5+
short_name: Cloud Pub/Sub
6+
url: https://cloud.google.com/pubsub/docs
7+
description: >
8+
`Google Cloud Pub/Sub`_ is a fully-managed real-time messaging service that
9+
allows you to send and receive messages between independent applications.
10+
11+
setup:
12+
- auth
13+
- install_deps
14+
15+
samples:
16+
- name: Quickstart
17+
file: quickstart.py
18+
- name: Publisher
19+
file: publisher.py
20+
show_help: true
21+
- name: Subscribers
22+
file: subscriber.py
23+
show_help: true
24+
- name: Identity and Access Management
25+
file: iam.py
26+
show_help: true
27+
28+
cloud_client_library: true
29+
30+
folder: pubsub/cloud-client

0 commit comments

Comments
 (0)