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

Commit

Permalink
Adds region to examples [(#1378)](GoogleCloudPlatform/python-docs-sam…
Browse files Browse the repository at this point in the history
  • Loading branch information
gguuss authored Mar 19, 2018
1 parent a653948 commit 267b4c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
8 changes: 3 additions & 5 deletions samples/api-client/manager/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
21 changes: 10 additions & 11 deletions samples/api-client/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 267b4c3

Please sign in to comment.