From 267b4c32cb16d5d42acb2567220cc046136f9866 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Mon, 19 Mar 2018 15:50:38 -0700 Subject: [PATCH] Adds region to examples [(#1378)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1378) --- samples/api-client/manager/README.rst | 8 +++----- samples/api-client/manager/manager.py | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/samples/api-client/manager/README.rst b/samples/api-client/manager/README.rst index 75ce31c1..bdbdb768 100644 --- a/samples/api-client/manager/README.rst +++ b/samples/api-client/manager/README.rst @@ -88,11 +88,9 @@ To run this sample: python manager.py \ --project_id=my-project-id \ - --pubsub_topic=projects/my-project-id/topics/my-topic-id \ - --ec_public_key_file=../ec_public.pem \ - --rsa_certificate_file=../rsa_cert.pem \ - --service_account_json=$HOME/service_account.json - list + --cloud_region=us-central1 \ + --service_account_json=$HOME/service_account.json \ + list-registries positional arguments: {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} diff --git a/samples/api-client/manager/manager.py b/samples/api-client/manager/manager.py index 931daab9..190f83a6 100644 --- a/samples/api-client/manager/manager.py +++ b/samples/api-client/manager/manager.py @@ -23,11 +23,9 @@ python manager.py \\ --project_id=my-project-id \\ - --pubsub_topic=projects/my-project-id/topics/my-topic-id \\ - --ec_public_key_file=../ec_public.pem \\ - --rsa_certificate_file=../rsa_cert.pem \\ - --service_account_json=$HOME/service_account.json - list + --cloud_region=us-central1 \\ + --service_account_json=$HOME/service_account.json \\ + list-registries """ import argparse @@ -501,16 +499,13 @@ def parse_command_line_args(): description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - # Required arguments + # Optional arguments + parser.add_argument( + '--cloud_region', default='us-central1', help='GCP cloud region') parser.add_argument( '--pubsub_topic', - required=True, help=('Google Cloud Pub/Sub topic. ' 'Format is projects/project_id/topics/topic-id')) - - # Optional arguments - parser.add_argument( - '--cloud_region', default='us-central1', help='GCP cloud region') parser.add_argument( '--config', default=None, @@ -597,11 +592,15 @@ def run_create(args): args.cloud_region, args.registry_id, args.device_id) elif args.command == 'create-registry': + if (args.pubsub_topic is None): + sys.exit('Error: specify --pubsub_topic') open_registry( args.service_account_json, args.project_id, args.cloud_region, args.pubsub_topic, args.registry_id) elif args.command == 'create-topic': + if (args.pubsub_topic is None): + sys.exit('Error: specify --pubsub_topic') create_iot_topic(args.project_id, args.pubsub_topic)