8000 Adds region to examples [(#1378)](https://github.com/GoogleCloudPlatf… · googleapis/python-iot@267b4c3 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit 267b4c3

Browse files
authored
Adds region to examples [(#1378)](GoogleCloudPlatform/python-docs-samples#1378)
1 parent a653948 commit 267b4c3

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

samples/api-client/manager/README.rst

Lines changed: 3 additions & 5 deletions
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}

samples/api-client/manager/manager.py

Lines changed: 10 additions & 11 deletions
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

0 commit comments

Comments
 (0)
0