Реестр устройства не может быть обновлен, и нет возможности скопировать одно устройство из одного реестра в другой. Итак, лучший подход к этому зависит от вашего варианта использования.
Я создал небольшой Python скрипт, который может переносить устройства, я протестировал его на некоторых из моих, и он, кажется, работает правильно для всех их свойств .
from google.cloud import iot_v1
def move_device(project_id, cloud_region, registry_source, registry_target, device_id):
# Instantiate client
client = iot_v1.DeviceManagerClient()
# Source device path to get its information, and deleting it
source_device_path = client.device_path(project_id, cloud_region, registry_source, device_id)
# Get device
device = client.get_device(source_device_path)
# Clean values for new device
device.name = ''
device.config.cloud_update_time.seconds= 0
device.config.cloud_update_time.nanos= 0
device.config.version = 0
device.num_id = 0
# Create the device in the new registry
client.create_device(client.registry_path(project_id, cloud_region, registry_target), device)
# Uncomment to delete the original device registry
# client.delete_device(source_device_path)
if __name__ == "__main__":
project_id='my-project'
cloud_region='my-region'
registry_source='my-registry-source'
registry_target='my-registry-target'
device_id='my-device'
move_device(project_id, cloud_region, registry_source, registry_target, device_id)
Этот скрипт использует библиотеку google-cloud-iot , которую можно установить с помощью pip.
pip install google-cloud-iot
Я взял идею из документация , надеюсь, она у вас работает.