【问题标题】:Google Cloud IOT, block communication via APIGoogle Cloud IOT,通过 API 阻止通信
【发布时间】:2018-06-22 01:17:09
【问题描述】:
【问题讨论】:
标签:
google-cloud-platform
google-cloud-iot
【解决方案1】:
an example snippet for patching a device 可能对您有帮助。
您可以更新设备以阻止通信,而不是在补丁正文中发送 EC 值。
在 Python 中,您可以这样做:
client = get_client(service_account_json)
registry_path = 'projects/{}/locations/{}/registries/{}'.format(
project_id, cloud_region, registry_id)
patch = {
'blocked': 'True'
}
device_name = '{}/devices/{}'.format(registry_path, device_id)
return client.projects().locations().registries().devices().patch(
name=device_name, updateMask='blocked', body=patch).execute()