Skip to content

Commit

Permalink
samples: add samples from pubsub/cloud-client (#134)
Browse files Browse the repository at this point in the history
* 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. [(#540)](GoogleCloudPlatform/python-docs-samples#540)

* Auto-update dependencies. [(#542)](GoogleCloudPlatform/python-docs-samples#542)

* Move to google-cloud [(#544)](GoogleCloudPlatform/python-docs-samples#544)

* Add new "quickstart" samples [(#547)](GoogleCloudPlatform/python-docs-samples#547)

* Quickstart tests [(#569)](GoogleCloudPlatform/python-docs-samples#569)

* Add tests for quickstarts
* Update secrets

* Generate readmes for most service samples [(#599)](GoogleCloudPlatform/python-docs-samples#599)

* Update samples to support latest Google Cloud Python [(#656)](GoogleCloudPlatform/python-docs-samples#656)

* Auto-update dependencies. [(#715)](GoogleCloudPlatform/python-docs-samples#715)

* Fix pubusb tests

Change-Id: I7dfe60b0f1240dc58a664968fd97ca5a8fa1109d

* Auto-update dependencies. [(#825)](GoogleCloudPlatform/python-docs-samples#825)

* Auto-update dependencies. [(#876)](GoogleCloudPlatform/python-docs-samples#876)

* Fix reference to our testing tools

* Re-generate all readmes

* Auto-update dependencies. [(#922)](GoogleCloudPlatform/python-docs-samples#922)

* Auto-update dependencies.

* Fix pubsub iam samples

* Fix README rst links [(#962)](GoogleCloudPlatform/python-docs-samples#962)

* Fix README rst links

* Update all READMEs

* Auto-update dependencies. [(#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. [(#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 [(#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. [(#1097)](GoogleCloudPlatform/python-docs-samples#1097)

* Update all generated readme auth instructions [(#1121)](GoogleCloudPlatform/python-docs-samples#1121)

Change-Id: I03b5eaef8b17ac3dc3c0339fd2c7447bd3e11bd2

* Added Link to Python Setup Guide [(#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. [(#1138)](GoogleCloudPlatform/python-docs-samples#1138)

* Fix a few more lint issues

Change-Id: I0d420f3053f391fa225e4b8179e45fd1138f5c65

* Add Snippet for Listing All Subscriptions in a Project [(#1169)](GoogleCloudPlatform/python-docs-samples#1169)

* Auto-update dependencies. [(#1186)](GoogleCloudPlatform/python-docs-samples#1186)

* Auto-update dependencies. [(#1234)](GoogleCloudPlatform/python-docs-samples#1234)

* Auto-update dependencies.

* Drop pytest-logcapture as it's no longer needed

Change-Id: Ia8b9e8aaf248e9770db6bc4842a4532df8383893

* Auto-update dependencies. [(#1239)](GoogleCloudPlatform/python-docs-samples#1239)

* Added "Open in Cloud Shell" buttons to README files [(#1254)](GoogleCloudPlatform/python-docs-samples#1254)

* Auto-update dependencies. [(#1263)](GoogleCloudPlatform/python-docs-samples#1263)

* Auto-update dependencies. [(#1272)](GoogleCloudPlatform/python-docs-samples#1272)

* Auto-update dependencies.

* Update requirements.txt

* Auto-update dependencies. [(#1282)](GoogleCloudPlatform/python-docs-samples#1282)

* Auto-update dependencies.

* Fix storage acl sample

Change-Id: I413bea899fdde4c4859e4070a9da25845b81f7cf

* Add listen for errors sample. [(#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 [(#1321)](GoogleCloudPlatform/python-docs-samples#1321)

* Add tests for creating push subscription. [(#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. [(#1331)](GoogleCloudPlatform/python-docs-samples#1331)

* Update API version and body. [(#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. [(#1335)](GoogleCloudPlatform/python-docs-samples#1335)

* Change update_subscription to change endpoint URL. [(#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. [(#1359)](GoogleCloudPlatform/python-docs-samples#1359)

* Auto-update dependencies. [(#1389)](GoogleCloudPlatform/python-docs-samples#1389)

* Added sample for publishing/receiving messages with custom attributes [(#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. [(#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` |

---

### Release Notes

<details>
<summary>googleapis/python-pubsub</summary>

### [`v1.6.0`](https://togithub.com/googleapis/python-pubsub/blob/master/CHANGELOG.md#&#8203;160-httpswwwgithubcomgoogleapispython-pubsubcomparev150v160-2020-06-09)

[Compare Source](https://togithub.com/googleapis/python-pubsub/compare/v1.5.0...v1.6.0)

##### Features

-   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))

##### Bug Fixes

-   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))

##### Documentation

-   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))

##### Internal / Testing Changes

-   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>

---

### Renovate configuration

: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]>
  • Loading branch information
24 people authored Jun 26, 2020
1 parent 73e06c1 commit e204b86
Show file tree
Hide file tree
Showing 19 changed files with 2,829 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Code owners file.
# This file controls who is tagged for review for any given pull request.
#
# For syntax help see:
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax


# The python-samples-owners team is the default owner for anything not
# explicitly taken by someone else.

/samples/ @anguillanneuf @hongalex @googleapis/python-samples-owners
1 change: 1 addition & 0 deletions samples/AUTHORING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md
1 change: 1 addition & 0 deletions samples/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/CONTRIBUTING.md
282 changes: 282 additions & 0 deletions samples/snippets/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@

.. This file is automatically generated. Do not edit this file directly.
Google Cloud Pub/Sub Python Samples
===============================================================================

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
: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


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.




.. _Google Cloud Pub/Sub: https://cloud.google.com/pubsub/docs


Setup
-------------------------------------------------------------------------------



Authentication
++++++++++++++

This sample requires you to have authentication setup. Refer to the
`Authentication Getting Started Guide`_ for instructions on setting up
credentials for applications.

.. _Authentication Getting Started Guide:
https://cloud.google.com/docs/authentication/getting-started




Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

.. code-block:: bash
$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
#. 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.

.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 3.6+.

.. code-block:: bash
$ virtualenv env
$ source env/bin/activate
#. Install the dependencies needed to run the samples.

.. code-block:: bash
$ pip install -r requirements.txt
.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/






Samples
-------------------------------------------------------------------------------


Quickstart
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
: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




To run this sample:

.. code-block:: bash
$ python quickstart.py
Publisher
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
: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




To run this sample:

.. code-block:: bash
$ python publisher.py
usage: publisher.py [-h]
project_id
{list,create,delete,publish,publish-with-custom-attributes,publish-with-error-handler,publish-with-batch-settings,publish-with-retry-settings}
...
This application demonstrates how to perform basic operations on topics
with the Cloud Pub/Sub API.
For more information, see the README.md under /pubsub and the documentation
at https://cloud.google.com/pubsub/docs.
positional arguments:
project_id Your Google Cloud project ID
{list,create,delete,publish,publish-with-custom-attributes,publish-with-error-handler,publish-with-batch-settings,publish-with-retry-settings}
list Lists all Pub/Sub topics in the given project.
create Create a new Pub/Sub topic.
delete Deletes an existing Pub/Sub topic.
publish Publishes multiple messages to a Pub/Sub topic.
publish-with-custom-attributes
Publishes multiple messages with custom attributes to
a Pub/Sub topic.
publish-with-error-handler
Publishes multiple messages to a Pub/Sub topic with an
error handler.
publish-with-batch-settings
Publishes multiple messages to a Pub/Sub topic with
batch settings.
publish-with-retry-settings
Publishes messages with custom retry settings.
optional arguments:
-h, --help show this help message and exit
Subscribers
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
: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




To run this sample:

.. code-block:: bash
$ python subscriber.py
usage: subscriber.py [-h]
project_id
{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}
...
This application demonstrates how to perform basic operations on
subscriptions with the Cloud Pub/Sub API.
For more information, see the README.md under /pubsub and the documentation
at https://cloud.google.com/pubsub/docs.
positional arguments:
project_id Your Google Cloud project ID
{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}
list-in-topic Lists all subscriptions for a given topic.
list-in-project Lists all subscriptions in the current project.
create Create a new pull subscription on the given topic.
create-with-dead-letter-policy
Create a subscription with dead letter policy.
create-push Create a new push subscription on the given topic.
delete Deletes an existing Pub/Sub topic.
update-push Updates an existing Pub/Sub subscription's push
endpoint URL. Note that certain properties of a
subscription, such as its topic, are not modifiable.
update-dead-letter-policy
Update a subscription's dead letter policy.
remove-dead-letter-policy
Remove dead letter policy from a subscription.
receive Receives messages from a pull subscription.
receive-custom-attributes
Receives messages from a pull subscription.
receive-flow-control
Receives messages from a pull subscription with flow
control.
receive-synchronously
Pulling messages synchronously.
receive-synchronously-with-lease
Pulling messages synchronously with lease management
listen-for-errors Receives messages and catches errors from a pull
subscription.
receive-messages-with-delivery-attempts
optional arguments:
-h, --help show this help message and exit
Identity and Access Management
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
: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




To run this sample:

.. code-block:: bash
$ python iam.py
usage: iam.py [-h]
project
{get-topic-policy,get-subscription-policy,set-topic-policy,set-subscription-policy,check-topic-permissions,check-subscription-permissions}
...
This application demonstrates how to perform basic operations on IAM
policies with the Cloud Pub/Sub API.
For more information, see the README.md under /pubsub and the documentation
at https://cloud.google.com/pubsub/docs.
positional arguments:
project Your Google Cloud project ID
{get-topic-policy,get-subscription-policy,set-topic-policy,set-subscription-policy,check-topic-permissions,check-subscription-permissions}
get-topic-policy Prints the IAM policy for the given topic.
get-subscription-policy
Prints the IAM policy for the given subscription.
set-topic-policy Sets the IAM policy for a topic.
set-subscription-policy
Sets the IAM policy for a topic.
check-topic-permissions
Checks to which permissions are available on the given
topic.
check-subscription-permissions
Checks to which permissions are available on the given
subscription.
optional arguments:
-h, --help show this help message and exit
The client library
-------------------------------------------------------------------------------

This sample uses the `Google Cloud Client Library for Python`_.
You can read the documentation for more details on API usage and use GitHub
to `browse the source`_ and `report issues`_.

.. _Google Cloud Client Library for Python:
https://googlecloudplatform.github.io/google-cloud-python/
.. _browse the source:
https://github.com/GoogleCloudPlatform/google-cloud-python
.. _report issues:
https://github.com/GoogleCloudPlatform/google-cloud-python/issues



.. _Google Cloud SDK: https://cloud.google.com/sdk/
30 changes: 30 additions & 0 deletions samples/snippets/README.rst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is used to generate README.rst

product:
name: Google Cloud Pub/Sub
short_name: Cloud Pub/Sub
url: https://cloud.google.com/pubsub/docs
description: >
`Google Cloud Pub/Sub`_ is a fully-managed real-time messaging service that
allows you to send and receive messages between independent applications.

setup:
- auth
- install_deps

samples:
- name: Quickstart
file: quickstart.py
- name: Publisher
file: publisher.py
show_help: true
- name: Subscribers
file: subscriber.py
show_help: true
- name: Identity and Access Management
file: iam.py
show_help: true

cloud_client_library: true

folder: pubsub/cloud-client
Loading

0 comments on commit e204b86

Please sign in to comment.