Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions iot/api-client/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def delete_registry(
return 'Registry deleted'
except HttpError:
print('Error, registry not deleted')
return 'Registry not deleted'
raise
# [END iot_delete_registry]


Expand Down Expand Up @@ -391,10 +391,10 @@ def create_registry(
return response
except HttpError:
print('Error, registry not created')
return ""
raise
except AlreadyExists:
print('Error, registry already exists')
return ""
raise
# [END iot_create_registry]


Expand Down Expand Up @@ -422,12 +422,12 @@ def open_registry(
# registry_id = 'your-registry-id'
print('Creating registry')

response = create_registry(
service_account_json, project_id, cloud_region,
pubsub_topic, registry_id)

if response == '':
# Device registry already exists
try:
response = create_registry(
service_account_json, project_id, cloud_region,
pubsub_topic, registry_id)
except AlreadyExists:
# Device registry already exists. We just re-use the existing one.
print(
'Registry {} already exists - looking it up instead.'.format(
registry_id))
Expand Down
2 changes: 2 additions & 0 deletions iot/api-client/manager/manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']

pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id)

# This format is used in the `clean_up_registries()` below.
registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time()))


Expand Down