Created
July 11, 2018 00:04
-
-
Save gguuss/051e9a12d68fc5330fbc010a2e0c2085 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def updateConfig(project_id, region, registry_id, device_id, data): | |
"""Push the data to the given device as configuration.""" | |
config_data_json = json.dumps(data) | |
body = { | |
'version_to_update': 0, | |
'binary_data': base64.b64encode( | |
config_data_json.encode('utf-8')).decode('ascii') | |
} | |
device_name = ('projects/{}/locations/{}/registries/{}/' | |
'devices/{}'.format( | |
project_id, | |
region, | |
registry_id, | |
device_id)) | |
request = service.projects().locations().registries().devices( | |
).modifyCloudToDeviceConfig(name=device_name, body=body) | |
update_config_mutex.acquire() | |
try: | |
request.execute() | |
except HttpError as e: | |
print('Error executing ModifyCloudToDeviceConfig: {}'.format(e)) | |
finally: | |
update_config_mutex.release() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment