我试图使用库存API将儿童设备设置为累积设备,不幸的是没有成功。
我已经尝试了以下内容:
GId gid = new GId(deviceId);
ManagedObjectRepresentation deviceRepresentation = inventoryApi.get(gid);
ManagedObjectReferenceCollectionRepresentation childDevices = new ManagedObjectReferenceCollectionRepresentation();
ManagedObjectReferenceRepresentation morr = new ManagedObjectReferenceRepresentation();
morr.setManagedObject(mo);
List<ManagedObjectReferenceRepresentation> references = new ArrayList<ManagedObjectReferenceRepresentation>();
references.add(morr);
childDevices.setReferences(references);
deviceRepresentation.setChildDevices(childDevices);
deviceRepresentation.setLastUpdatedDateTime(null);
inventoryApi.update(deviceRepresentation);
没有错误的错误,但是在那之后,当我查看库存时,设备都没有设置ChildDevices,托管对象都没有设置设备。我做错了什么?
儿童设备和资产设置为专用端点,而不是通过更改托管对象中的孩子列表。有关详细信息
在您的情况下使用Java-Client,您可以这样做:
GId parentID = new GId(deviceId);
GId childId = new GId(childDeviceId);
ManagedObject managedObjectApi = inventoryApi.getManagedObjectApi(parentID);
managedObjectApi.addChildDevice(childId);