def updateAttributes(self, object_id=None, object_name=None, object_subname=None, **kwargs):
assert not (object_id is None and object_name is None and object_subname is None), "At least one identifier must be set"
if object_id is None:
if object_subname is None:
object_id = self.getObjectIdByName(object_name)
else:
object_id = self.getObjectIdByName(object_name, object_subname)
else:
self.getObjectId(object_id)
self._validateAttributes(kwargs, checkMandatoryAttrs=False)
for k in kwargs:
if self.attributeExists(object_id, k):
self._connection.execute(md.InventoryObjectAttributes.update().where(and_(md.InventoryObjectAttributes.c.class_id == self._classId, md.InventoryObjectAttributes.c.object_id == object_id, md.InventoryObjectAttributes.c.attr_key == k)).values(attr_value=str(kwargs[k])))
else:
self._connection.execute(md.InventoryObjectAttributes.insert().values(object_id=object_id, class_id=self._classId, attr_key=str(k), attr_value=str(kwargs[k])))
评论列表
文章目录