forked from GoogleCloudPlatform/python-docs-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for retrieving a large file from Cloud Storage onto a dev…
…ice (GoogleCloudPlatform#1350)
- Loading branch information
Showing
7 changed files
with
948 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
.. This file is automatically generated. Do not edit this file directly. | ||
Google Cloud IoT Core 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=/README.rst | ||
|
||
|
||
This directory contains samples for Google Cloud IoT Core. `Google Cloud IoT Core`_ allows developers to easily integrate Publish and Subscribe functionality with devices and programmatically authorize devices. | ||
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``. | ||
|
||
|
||
|
||
|
||
.. _Google Cloud IoT Core: https://cloud.google.com/iot/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 | ||
++++++++++++++++++++ | ||
|
||
#. 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 2.7 and 3.4+. | ||
|
||
.. 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 | ||
------------------------------------------------------------------------------- | ||
|
||
Server | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
.. 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=/gcs_example_mqtt_device.py;/README.rst | ||
|
||
|
||
|
||
|
||
To run this sample: | ||
|
||
.. code-block:: bash | ||
$ python gcs_example_mqtt_device.py | ||
usage: gcs_example_mqtt_device.py [-h] --project_id PROJECT_ID --registry_id | ||
REGISTRY_ID --device_id DEVICE_ID | ||
--private_key_file PRIVATE_KEY_FILE | ||
--algorithm {RS256,ES256} | ||
[--cloud_region CLOUD_REGION] | ||
[--ca_certs CA_CERTS] | ||
[--num_messages NUM_MESSAGES] | ||
[--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME] | ||
[--mqtt_bridge_port MQTT_BRIDGE_PORT] | ||
Example Google Cloud IoT MQTT device connection code. | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
--project_id PROJECT_ID | ||
GCP cloud project name. | ||
--registry_id REGISTRY_ID | ||
Cloud IoT registry id | ||
--device_id DEVICE_ID | ||
Cloud IoT device id | ||
--private_key_file PRIVATE_KEY_FILE | ||
Path to private key file. | ||
--algorithm {RS256,ES256} | ||
Which encryption algorithm to use to generate the JWT. | ||
--cloud_region CLOUD_REGION | ||
GCP cloud region | ||
--ca_certs CA_CERTS CA root certificate. Get from | ||
https://pki.google.com/roots.pem | ||
--num_messages NUM_MESSAGES | ||
Number of messages to publish. | ||
--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME | ||
MQTT bridge hostname. | ||
--mqtt_bridge_port MQTT_BRIDGE_PORT | ||
MQTT bridge port. | ||
Device | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
.. 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=/gcs_send_to_device.py;/README.rst | ||
|
||
|
||
|
||
|
||
To run this sample: | ||
|
||
.. code-block:: bash | ||
$ python gcs_send_to_device.py | ||
usage: gcs_send_to_device.py [-h] --project_id PROJECT_ID --bucket_name | ||
BUCKET_NAME --gcs_file_name GCS_FILE_NAME | ||
--source_file_name SOURCE_FILE_NAME | ||
--destination_file_name DESTINATION_FILE_NAME | ||
--registry_id REGISTRY_ID --device_id DEVICE_ID | ||
[--service_account_json SERVICE_ACCOUNT_JSON] | ||
[--cloud_region CLOUD_REGION] | ||
Example of uploading a config (file) to Google Cloud Storage, then sending the | ||
bucket name and file name for the config to a Cloud IoT Core device. | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
--project_id PROJECT_ID | ||
GCP project name. | ||
--bucket_name BUCKET_NAME | ||
The name of the bucket containing the file. | ||
--gcs_file_name GCS_FILE_NAME | ||
The name of the file to be sent. | ||
--source_file_name SOURCE_FILE_NAME | ||
The name of file on the local file system. | ||
--destination_file_name DESTINATION_FILE_NAME | ||
The file to write to on the device. | ||
--registry_id REGISTRY_ID | ||
The registry for the device. | ||
--device_id DEVICE_ID | ||
The device to which to send the config update. | ||
--service_account_json SERVICE_ACCOUNT_JSON | ||
Path to service account json file. | ||
--cloud_region CLOUD_REGION | ||
Cloud region | ||
.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This file is used to generate README.rst | ||
|
||
product: | ||
name: Google Cloud IoT Core | ||
short_name: Cloud IoT Core | ||
url: https://cloud.google.com/iot/docs | ||
description: > | ||
`Google Cloud IoT Core`_ allows developers to easily integrate Publish and | ||
Subscribe functionality with devices and programmatically authorize | ||
devices. | ||
|
||
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``. | ||
|
||
setup: | ||
- auth | ||
- install_deps | ||
|
||
samples: | ||
- name: Server | ||
file: gcs_example_mqtt_device.py | ||
show_help: True | ||
- name: Device | ||
file: gcs_send_to_device.py | ||
show_help: True | ||
|
||
cloud_client_library: false |
Oops, something went wrong.