0

I'd like to block communication with a device in a registry in Google Cloud IOT.

The gcloud command that is used to block communication: https://cloud.google.com/iot/docs/gcloud-examples#block_or_allow_communication_from_a_device

The Patch API doesn't make it clear how one can block communication of a device using the API

So how is this achieved?

7hacker
  • 1,928
  • 3
  • 19
  • 32

1 Answers1

0

There is an example snippet for patching a device available that may be helpful for you.

Instead of sending a EC value in the patch body, you could update the device to have communication blocked.

In Python, you would do this as:

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()
class
  • 8,621
  • 29
  • 30