【问题标题】:Google Cloud IOT, block communication via APIGoogle Cloud IOT,通过 API 阻止通信
【发布时间】:2018-06-22 01:17:09
【问题描述】:

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

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

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

那么这是如何实现的呢?

【问题讨论】:

    标签: 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()
    

    【讨论】:

      猜你喜欢
      • 2022-09-27
      • 2020-03-27
      • 2023-03-20
      • 2021-04-08
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 2018-06-30
      • 1970-01-01
      相关资源
      最近更新 更多