Skip to content

Commit

Permalink
Removes START / END blocks for snippets.
Browse files Browse the repository at this point in the history
  • Loading branch information
gguuss committed Sep 8, 2017
1 parent cfa07e8 commit 158906d
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions iot/api-client/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def get_client(service_account_json, api_key):
"""Returns an authorized API client by discovering the IoT API using the
provided API key and creating a service object using the service account
credentials JSON."""
# [START authorize]
api_scopes = ['https://www.googleapis.com/auth/cloud-platform']
api_version = 'v1beta1'
discovery_api = 'https://cloudiot.googleapis.com/$discovery/rest'
Expand All @@ -82,15 +81,13 @@ def get_client(service_account_json, api_key):
api_version,
discoveryServiceUrl=discovery_url,
credentials=scoped_credentials)
# [END authorize]


def create_rs256_device(
service_account_json, api_key, project_id, cloud_region, registry_id,
device_id, certificate_file):
"""Create a new device with the given id, using RS256 for
authentication."""
# [START create_rs256_device]
registry_name = 'projects/{}/locations/{}/registries/{}'.format(
project_id, cloud_region, registry_id)

Expand All @@ -111,15 +108,13 @@ def create_rs256_device(

devices = client.projects().locations().registries().devices()
return devices.create(parent=registry_name, body=device_template).execute()
# [END create_rs256_device]


def create_es256_device(
service_account_json, api_key, project_id, cloud_region, registry_id,
device_id, public_key_file):
"""Create a new device with the given id, using ES256 for
authentication."""
# [START create_rs256_device]
registry_name = 'projects/{}/locations/{}/registries/{}'.format(
project_id, cloud_region, registry_id)

Expand All @@ -140,14 +135,12 @@ def create_es256_device(

devices = client.projects().locations().registries().devices()
return devices.create(parent=registry_name, body=device_template).execute()
# [END create_rs256_device]


def create_unauth_device(
service_account_json, api_key, project_id, cloud_region, registry_id,
device_id):
"""Create a new device without authentication."""
# [START create_noauth_device]
registry_name = 'projects/{}/locations/{}/registries/{}'.format(
project_id, cloud_region, registry_id)

Expand All @@ -158,14 +151,12 @@ def create_unauth_device(

devices = client.projects().locations().registries().devices()
return devices.create(parent=registry_name, body=device_template).execute()
# [END create_noauth_device]


def delete_device(
service_account_json, api_key, project_id, cloud_region, registry_id,
device_id):
"""Delete the device with the given id."""
# [START delete_device]
print('Delete device')
client = get_client(service_account_json, api_key)
registry_name = 'projects/{}/locations/{}/registries/{}'.format(
Expand All @@ -175,28 +166,24 @@ def delete_device(

devices = client.projects().locations().registries().devices()
return devices.delete(name=device_name).execute()
# [END delete_device]


def delete_registry(
service_account_json, api_key, project_id, cloud_region, registry_id):
"""Deletes the specified registry."""
# [START delete_registry]
print('Delete registry')
client = get_client(service_account_json, api_key)
registry_name = 'projects/{}/locations/{}/registries/{}'.format(
project_id, cloud_region, registry_id)

registries = client.projects().locations().registries()
return registries.delete(name=registry_name).execute()
# [END delete_registry]


def get_device(
service_account_json, api_key, project_id, cloud_region, registry_id,
device_id):
"""Retrieve the device with the given id."""
# [START delete_device]
print('Getting device')
client = get_client(service_account_json, api_key)
registry_name = 'projects/{}/locations/{}/registries/{}'.format(
Expand All @@ -223,13 +210,11 @@ def get_device(
'cloudUpdateTime')))

return device
# [END delete_device]


def list_devices(
service_account_json, api_key, project_id, cloud_region, registry_id):
"""List all devices in the registry."""
# [START list_devices]
print('Listing devices')
registry_path = 'projects/{}/locations/{}/registries/{}'.format(
project_id, cloud_region, registry_id)
Expand All @@ -243,7 +228,6 @@ def list_devices(
device.get('id')))

return devices
# [list_devices]


def open_registry(
Expand Down

0 comments on commit 158906d

Please sign in to comment.