|
| 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/ |
0 commit comments