8000 Add the Python device and server files from the end-to-end-example (#… · johnmanong/python-docs-samples@2a35eed · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a35eed

Browse files
noerogJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
Add the Python device and server files from the end-to-end-example (GoogleCloudPlatform#1218)
1 parent c53d927 commit 2a35eed

File tree

6 files changed

+719
-0
lines changed

6 files changed

+719
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
.. This file is automatically generated. Do not edit this file directly.
2+
3+
Google Cloud IoT Core API Python Samples
4+
===============================================================================
5+
6+
This directory contains samples for Google Cloud IoT Core API. `Google Cloud IoT Core`_ allows developers to easily integrate Publish and Subscribe functionality with devices and programmatically manage device authorization.
7+
Before you run the sample, you must retrieve the Google root certificate. For example, `wget https://pki.goog/roots.pem` or `curl https://pki.goog/roots.pem > roots.pem`.
8+
9+
10+
11+
12+
.. _Google Cloud IoT Core API: https://cloud.google.com/iot/docs
13+
14+
Setup
15+
-------------------------------------------------------------------------------
16+
17+
18+
Authentication
19+
++++++++++++++
20+
21+
This sample requires you to have authentication setup. Refer to the
22+
`Authentication Getting Started Guide`_ for instructions on setting up
23+
credentials for applications.
24+
25+
.. _Authentication Getting Started Guide:
26+
https://cloud.google.com/docs/authentication/getting-started
27+
28+
Install Dependencies
29+
++++++++++++++++++++
30+
31+
#. 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.
32+
33+
.. _Python Development Environment Setup Guide:
34+
https://cloud.google.com/python/setup
35+
36+
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
37+
38+
.. code-block:: bash
39+
40+
$ virtualenv env
41+
$ source env/bin/activate
42+
43+
#. Install the dependencies needed to run the samples.
44+
45+
.. code-block:: bash
46+
47+
$ pip install -r requirements.txt
48+
49+
.. _pip: https://pip.pypa.io/
50+
.. _virtualenv: https://virtualenv.pypa.io/
51+
52+
Samples
53+
-------------------------------------------------------------------------------
54+
55+
Server
56+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57+
58+
59+
60+
To run this sample:
61+
62+
.. code-block:: bash
63+
64+
$ python cloudiot_pubsub_example_server.py
65+
66+
usage: cloudiot_pubsub_example_server.py [-h] --project_id PROJECT_ID
67+
--pubsub_subscription
68+
PUBSUB_SUBSCRIPTION
69+
[--service_account_json SERVICE_ACCOUNT_JSON]
70+
71+
Example of Google Cloud IoT registry and device management.
72+
73+
optional arguments:
74+
-h, --help show this help message and exit
75+
--project_id PROJECT_ID
76+
GCP cloud project name.
77+
--pubsub_subscription PUBSUB_SUBSCRIPTION
78+
Google Cloud Pub/Sub subscription name.
79+
--service_account_json SERVICE_ACCOUNT_JSON
80+
Path to service account json file.
81+
82+
83+
84+
Device
85+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
86+
87+
88+
89+
To run this sample:
90+
91+
.. code-block:: bash
92+
93+
$ python cloudiot_pubsub_example_mqtt_device.py
94+
95+
usage: cloudiot_pubsub_example_mqtt_device.py [-h] --project_id PROJECT_ID
96+
--registry_id REGISTRY_ID
97+
--device_id DEVICE_ID
98+
--private_key_file
99+
PRIVATE_KEY_FILE --algorithm
100+
{RS256,ES256}
101+
[--cloud_region CLOUD_REGION]
102+
[--ca_certs CA_CERTS]
103+
[--num_messages NUM_MESSAGES]
104+
[--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME]
105+
[--mqtt_bridge_port MQTT_BRIDGE_PORT]
106+
107+
Example Google Cloud IoT MQTT device connection code.
108+
109+
optional arguments:
110+
-h, --help show this help message and exit
111+
--project_id PROJECT_ID
112+
GCP cloud project name
113+
--registry_id REGISTRY_ID
114+
Cloud IoT registry id
115+
--device_id DEVICE_ID
116+
Cloud IoT device id
117+
--private_key_file PRIVATE_KEY_FILE
118+
Path to private key file.
119+
--algorithm {RS256,ES256}
120+
Which encryption algorithm to use to generate the JWT.
121+
--cloud_region CLOUD_REGION
122+
GCP cloud region
123+
--ca_certs CA_CERTS CA root certificate. Get from
124+
https://pki.google.com/roots.pem
125+
--num_messages NUM_MESSAGES
126+
Number of messages to publish.
127+
--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME
128+
MQTT bridge hostname.
129+
--mqtt_bridge_port MQTT_BRIDGE_PORT
130+
MQTT bridge port.
131+
132+
133+
134+
135+
136+
.. _Google Cloud SDK: https://cloud.google.com/sdk/
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 IoT Core API
5+
short_name: Cloud IoT Core
6+
url: https://cloud.google.com/iot/docs
7+
description: >
8+
`Google Cloud IoT Core`_ allows developers to easily integrate Publish and
9+
Subscribe functionality with devices and programmatically manage device
10+
authorization.
11+
12+
Before you run the sample, you must retrieve the Google root certificate.
13+
For example, `wget https://pki.goog/roots.pem` or
14+
`curl https://pki.goog/roots.pem > roots.pem`.
15+
16+
setup:
17+
- auth
18+
- install_deps
19+
20+
samples:
21+
- name: Server
22+
file: cloudiot_pubsub_example_server.py
23+
show_help: True
24+
- name: Device
25+
file: cloudiot_pubsub_example_mqtt_device.py
26+
show_help: True
27+
28+
cloud_client_library: false

0 commit comments

Comments
 (0)
0