Skip to content

Commit b0e307c

Browse files
Jon Wayne Parrottplamut
Jon Wayne Parrott
authored andcommitted
Generate readmes for most service samples [(#599)](GoogleCloudPlatform/python-docs-samples#599)
1 parent a7b0cb5 commit b0e307c

File tree

3 files changed

+231
-17
lines changed

3 files changed

+231
-17
lines changed

samples/snippets/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

samples/snippets/README.rst

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
.. This file is automatically generated. Do not edit this file directly.
2+
3+
Google Cloud Pub/Sub Python Samples
4+
===============================================================================
5+
6+
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.
7+
8+
9+
10+
11+
.. _Google Cloud Pub/Sub: https://cloud.google.com/pubsub/docs
12+
13+
Setup
14+
-------------------------------------------------------------------------------
15+
16+
17+
Authentication
18+
++++++++++++++
19+
20+
Authentication is typically done through `Application Default Credentials`_,
21+
which means you do not have to change the code to authenticate as long as
22+
your environment has credentials. You have a few options for setting up
23+
authentication:
24+
25+
#. When running locally, use the `Google Cloud SDK`_
26+
27+
.. code-block:: bash
28+
29+
gcloud beta auth application-default login
30+
31+
32+
#. When running on App Engine or Compute Engine, credentials are already
33+
set-up. However, you may need to configure your Compute Engine instance
34+
with `additional scopes`_.
35+
36+
#. You can create a `Service Account key file`_. This file can be used to
37+
authenticate to Google Cloud Platform services from any environment. To use
38+
the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to
39+
the path to the key file, for example:
40+
41+
.. code-block:: bash
42+
43+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
44+
45+
.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
46+
.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using
47+
.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
48+
49+
Install Dependencies
50+
++++++++++++++++++++
51+
52+
#. Install `pip`_ and `virtualenv`_ if you do not already have them.
53+
54+
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
55+
56+
.. code-block:: bash
57+
58+
$ virtualenv env
59+
$ source env/bin/activate
60+
61+
#. Install the dependencies needed to run the samples.
62+
63+
.. code-block:: bash
64+
65+
$ pip install -r requirements.txt
66+
67+
.. _pip: https://pip.pypa.io/
68+
.. _virtualenv: https://virtualenv.pypa.io/
69+
70+
Samples
71+
-------------------------------------------------------------------------------
72+
73+
Quickstart
74+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
75+
76+
77+
78+
To run this sample:
79+
80+
.. code-block:: bash
81+
82+
$ python quickstart.py
83+
84+
85+
Publisher
86+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
87+
88+
89+
90+
To run this sample:
91+
92+
.. code-block:: bash
93+
94+
$ python publisher.py
95+
96+
usage: publisher.py [-h] {list,create,delete,publish} ...
97+
98+
This application demonstrates how to perform basic operations on topics
99+
with the Cloud Pub/Sub API.
100+
101+
For more information, see the README.md under /pubsub and the documentation
102+
at https://cloud.google.com/pubsub/docs.
103+
104+
positional arguments:
105+
{list,create,delete,publish}
106+
list Lists all Pub/Sub topics in the current project.
107+
create Create a new Pub/Sub topic.
108+
delete Deletes an existing Pub/Sub topic.
109+
publish Publishes a message to a Pub/Sub topic with the given
110+
data.
111+
112+
optional arguments:
113+
-h, --help show this help message and exit
114+
115+
116+
Subscribers
117+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118+
119+
120+
121+
To run this sample:
122+
123+
.. code-block:: bash
124+
125+
$ python subscriber.py
126+
127+
usage: subscriber.py [-h] {list,create,delete,receive} ...
128+
129+
This application demonstrates how to perform basic operations on
130+
subscriptions with the Cloud Pub/Sub API.
131+
132+
For more information, see the README.md under /pubsub and the documentation
133+
at https://cloud.google.com/pubsub/docs.
134+
135+
positional arguments:
136+
{list,create,delete,receive}
137+
list Lists all subscriptions for a given topic.
138+
create Create a new pull subscription on the given topic.
139+
delete Deletes an existing Pub/Sub topic.
140+
receive Receives a message from a pull subscription.
141+
142+
optional arguments:
143+
-h, --help show this help message and exit
144+
145+
146+
Identity and Access Management
147+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
148+
149+
150+
151+
To run this sample:
152+
153+
.. code-block:: bash
154+
155+
$ python iam.py
156+
157+
usage: iam.py [-h]
158+
{get-topic-policy,get-subscription-policy,set-topic-policy,set-subscription-policy,check-topic-permissions,check-subscription-permissions}
159+
...
160+
161+
This application demonstrates how to perform basic operations on IAM
162+
policies with the Cloud Pub/Sub API.
163+
164+
For more information, see the README.md under /pubsub and the documentation
165+
at https://cloud.google.com/pubsub/docs.
166+
167+
positional arguments:
168+
{get-topic-policy,get-subscription-policy,set-topic-policy,set-subscription-policy,check-topic-permissions,check-subscription-permissions}
169+
get-topic-policy Prints the IAM policy for the given topic.
170+
get-subscription-policy
171+
Prints the IAM policy for the given subscription.
172+
set-topic-policy Sets the IAM policy for a topic.
173+
set-subscription-policy
174+
Sets the IAM policy for a topic.
175+
check-topic-permissions
176+
Checks to which permissions are available on the given
177+
topic.
178+
check-subscription-permissions
179+
Checks to which permissions are available on the given
180+
subscription.
181+
182+
optional arguments:
183+
-h, --help show this help message and exit
184+
185+
186+
187+
188+
The client library
189+
-------------------------------------------------------------------------------
190+
191+
This sample uses the `Google Cloud Client Library for Python`_.
192+
You can read the documentation for more details on API usage and use GitHub
193+
to `browse the source`_ and `report issues`_.
194+
195+
.. Google Cloud Client Library for Python:
196+
https://googlecloudplatform.github.io/google-cloud-python/
197+
.. browse the source:
198+
https://github.com/GoogleCloudPlatform/google-cloud-python
199+
.. report issues:
200+
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
201+
202+
203+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

samples/snippets/README.rst.in

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

0 commit comments

Comments
 (0)