0

我想阻止与 Google Cloud IOT 注册表中的设备进行通信。

用于阻止通信的 gcloud 命令:https ://cloud.google.com/iot/docs/gcloud-examples#block_or_allow_communication_from_a_device

Patch API没有明确说明如何使用 API 阻止设备通信

那么这是如何实现的呢?

4

1 回答 1

0

一个用于修补可用设备的示例片段可能对您有所帮助。

您可以更新设备以阻止通信,而不是在补丁正文中发送 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()
于 2018-06-20T23:33:55.800 回答