Skip to content

Commit ae0fb45

Browse files
authored
Adds region to examples (GoogleCloudPlatform#1378)
1 parent 2922602 commit ae0fb45

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

iot/api-client/http_example/README.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
.. This file is automatically generated. Do not edit this file directly.
22
3-
Google Cloud IoT Core API Python Samples
3+
Google Cloud IoT Core Python Samples
44
===============================================================================
55

66
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
77
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=iot/api-client/http_example/README.rst
88

99

10-
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.
11-
The following example runs the sample using the project ID `blue-jet-123` and the device name `my-python-device`:
10+
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 manage device authorization.
11+
The following example runs the sample using the project ID ``blue-jet-123`` and the device name ``my-python-device``::
1212

1313
python cloudiot_http_example.py \
1414
--registry_id=my-registry \
15+
--cloud_region=us-central1 \
1516
--project_id=blue-jet-123 \
1617
--device_id=my-python-device \
1718
--message_type=event \
@@ -21,7 +22,7 @@ The following example runs the sample using the project ID `blue-jet-123` and th
2122

2223

2324

24-
.. _Google Cloud IoT Core API: https://cloud.google.com/iot/docs
25+
.. _Google Cloud IoT Core: https://cloud.google.com/iot/docs
2526

2627
Setup
2728
-------------------------------------------------------------------------------

iot/api-client/http_example/README.rst.in

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ product:
1414

1515
python cloudiot_http_example.py \
1616
--registry_id=my-registry \
17+
--cloud_region=us-central1 \
1718
--project_id=blue-jet-123 \
1819
--device_id=my-python-device \
1920
--message_type=event \

iot/api-client/manager/README.rst

+3-5
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ To run this sample:
8888
8989
python manager.py \
9090
--project_id=my-project-id \
91-
--pubsub_topic=projects/my-project-id/topics/my-topic-id \
92-
--ec_public_key_file=../ec_public.pem \
93-
--rsa_certificate_file=../rsa_cert.pem \
94-
--service_account_json=$HOME/service_account.json
95-
list
91+
--cloud_region=us-central1 \
92+
--service_account_json=$HOME/service_account.json \
93+
list-registries
9694
9795
positional arguments:
9896
{create-es256,create-registry,create-rsa256,create-topic,create-unauth,delete-device,delete-registry,get,get-config-versions,get-iam-permissions,get-registry,get-state,list,list-registries,patch-es256,patch-rs256,set-config,set-iam-permissions}

iot/api-client/manager/manager.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
2424
python manager.py \\
2525
--project_id=my-project-id \\
26-
--pubsub_topic=projects/my-project-id/topics/my-topic-id \\
27-
--ec_public_key_file=../ec_public.pem \\
28-
--rsa_certificate_file=../rsa_cert.pem \\
29-
--service_account_json=$HOME/service_account.json
30-
list
26+
--cloud_region=us-central1 \\
27+
--service_account_json=$HOME/service_account.json \\
28+
list-registries
3129
"""
3230

3331
import argparse
@@ -501,16 +499,13 @@ def parse_command_line_args():
501499
description=__doc__,
502500
formatter_class=argparse.RawDescriptionHelpFormatter)
503501

504-
# Required arguments
502+
# Optional arguments
503+
parser.add_argument(
504+
'--cloud_region', default='us-central1', help='GCP cloud region')
505505
parser.add_argument(
506506
'--pubsub_topic',
507-
required=True,
508507
help=('Google Cloud Pub/Sub topic. '
509508
'Format is projects/project_id/topics/topic-id'))
510-
511-
# Optional arguments
512-
parser.add_argument(
513-
'--cloud_region', default='us-central1', help='GCP cloud region')
514509
parser.add_argument(
515510
'--config',
516511
default=None,
@@ -597,11 +592,15 @@ def run_create(args):
597592
args.cloud_region, args.registry_id, args.device_id)
598593

599594
elif args.command == 'create-registry':
595+
if (args.pubsub_topic is None):
596+
sys.exit('Error: specify --pubsub_topic')
600597
open_registry(
601598
args.service_account_json, args.project_id,
602599
args.cloud_region, args.pubsub_topic, args.registry_id)
603600

604601
elif args.command == 'create-topic':
602+
if (args.pubsub_topic is None):
603+
sys.exit('Error: specify --pubsub_topic')
605604
create_iot_topic(args.project_id, args.pubsub_topic)
606605

607606

iot/api-client/mqtt_example/README.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
.. This file is automatically generated. Do not edit this file directly.
22
3-
Google Cloud IoT Core API Python Samples
3+
Google Cloud IoT Core Python Samples
44
===============================================================================
55

66
.. image:: https://gstatic.com/cloudssh/images/open-btn.png
77
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=iot/api-client/mqtt_example/README.rst
88

99

10-
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.
11-
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`.
12-
The following example runs the sample using the project ID `blue-jet-123` and the device name `my-python-device`:
10+
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 manage device authorization.
11+
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``.
12+
The following example runs the sample using the project ID ``blue-jet-123`` and the device name ``my-python-device``::
1313

1414
python cloudiot_mqtt_example.py \
1515
--registry_id=my-registry \
16+
--cloud_region=us-central1 \
1617
--project_id=blue-jet-123 \
1718
--device_id=my-python-device \
1819
--algorithm=RS256 \
@@ -21,7 +22,7 @@ The following example runs the sample using the project ID `blue-jet-123` and th
2122

2223

2324

24-
.. _Google Cloud IoT Core API: https://cloud.google.com/iot/docs
25+
.. _Google Cloud IoT Core: https://cloud.google.com/iot/docs
2526

2627
Setup
2728
-------------------------------------------------------------------------------

iot/api-client/mqtt_example/README.rst.in

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ product:
1818

1919
python cloudiot_mqtt_example.py \
2020
--registry_id=my-registry \
21+
--cloud_region=us-central1 \
2122
--project_id=blue-jet-123 \
2223
--device_id=my-python-device \
2324
--algorithm=RS256 \

0 commit comments

Comments
 (0)