|
| 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 | +The following example runs the sample using the project ID `blue-jet-123` and the device name `my-python-device`: |
| 8 | + |
| 9 | + python cloudiot_http_example.py \ |
| 10 | + --registry_id=my-registry \ |
| 11 | + --project_id=blue-jet-123 \ |
| 12 | + --device_id=my-python-device \ |
| 13 | + --message_type=event \ |
| 14 | + --algorithm=RS256 \ |
| 15 | + --private_key_file=../rsa_private.pem |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +.. _Google Cloud IoT Core API: https://cloud.google.com/iot/docs |
| 21 | + |
| 22 | +Setup |
| 23 | +------------------------------------------------------------------------------- |
| 24 | + |
| 25 | + |
| 26 | +Install Dependencies |
| 27 | +++++++++++++++++++++ |
| 28 | + |
| 29 | +#. 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. |
| 30 | + |
| 31 | + .. _Python Development Environment Setup Guide: |
| 32 | + https://cloud.google.com/python/setup |
| 33 | + |
| 34 | +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. |
| 35 | + |
| 36 | + .. code-block:: bash |
| 37 | +
|
| 38 | + $ virtualenv env |
| 39 | + $ source env/bin/activate |
| 40 | +
|
| 41 | +#. Install the dependencies needed to run the samples. |
| 42 | + |
| 43 | + .. code-block:: bash |
| 44 | +
|
| 45 | + $ pip install -r requirements.txt |
| 46 | +
|
| 47 | +.. _pip: https://pip.pypa.io/ |
| 48 | +.. _virtualenv: https://virtualenv.pypa.io/ |
| 49 | + |
| 50 | +Samples |
| 51 | +------------------------------------------------------------------------------- |
| 52 | + |
| 53 | +HTTP Device Client Example |
| 54 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +To run this sample: |
| 59 | + |
| 60 | +.. code-block:: bash |
| 61 | +
|
| 62 | + $ python cloudiot_http_example.py |
| 63 | +
|
| 64 | + usage: cloudiot_http_example.py [-h] --project_id PROJECT_ID --registry_id |
| 65 | + REGISTRY_ID --device_id DEVICE_ID |
| 66 | + --private_key_file PRIVATE_KEY_FILE |
| 67 | + --algorithm {RS256,ES256} |
| 68 | + [--cloud_region CLOUD_REGION] |
| 69 | + [--ca_certs CA_CERTS] |
| 70 | + [--num_messages NUM_MESSAGES] --message_type |
| 71 | + {event,state} [--base_url BASE_URL] |
| 72 | + [--jwt_expires_minutes JWT_EXPIRES_MINUTES] |
| 73 | + |
| 74 | + Example Google Cloud IoT Core HTTP device connection code. |
| 75 | + |
| 76 | + optional arguments: |
| 77 | + -h, --help show this help message and exit |
| 78 | + --project_id PROJECT_ID |
| 79 | + GCP cloud project name |
| 80 | + --registry_id REGISTRY_ID |
| 81 | + Cloud IoT Core registry id |
| 82 | + --device_id DEVICE_ID |
| 83 | + Cloud IoT Core device id |
| 84 | + --private_key_file PRIVATE_KEY_FILE |
| 85 | + Path to private key file. |
| 86 | + --algorithm {RS256,ES256} |
| 87 | + The encryption algorithm to use to generate the JWT. |
| 88 | + --cloud_region CLOUD_REGION |
| 89 | + GCP cloud region |
| 90 | + --ca_certs CA_CERTS CA root from https://pki.google.com/roots.pem |
| 91 | + --num_messages NUM_MESSAGES |
| 92 | + Number of messages to publish. |
| 93 | + --message_type {event,state} |
| 94 | + Indicates whether the message to be published is a |
| 95 | + telemetry event or a device state message. |
| 96 | + --base_url BASE_URL Base URL for the Cloud IoT Core Device Service API |
| 97 | + --jwt_expires_minutes JWT_EXPIRES_MINUTES |
| 98 | + Expiration time, in minutes, for JWT tokens. |
| 99 | +
|
| 100 | +
|
| 101 | +
|
| 102 | +
|
| 103 | +.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
0 commit comments