def update_type(self, data: (CmdbType, dict)):
        if isinstance(data, CmdbType):
            update_type = data
        elif isinstance(data, dict):
            update_type = CmdbType(**data)
        else:
            raise WrongInputFormatError(CmdbType, data,
                                        "Possible data: dict or CmdbType")

        ack = self._update(collection=CmdbType.COLLECTION,
                           public_id=update_type.get_public_id(),
                           data=update_type.to_database())
        if self._event_queue:
            event = Event("cmdb.core.objecttype.updated",
                          {"id": update_type.get_public_id()})
            self._event_queue.put(event)
        return ack
 def insert_type(self, data: (CmdbType, dict)):
     if isinstance(data, CmdbType):
         new_type = data
     elif isinstance(data, dict):
         new_type = CmdbType(**data)
     else:
         raise WrongInputFormatError(CmdbType, data,
                                     "Possible data: dict or CmdbType")
     try:
         ack = self._insert(collection=CmdbType.COLLECTION,
                            data=new_type.to_database())
         LOGGER.debug(f"Inserted new type with ack {ack}")
         if self._event_queue:
             event = Event("cmdb.core.objecttype.added",
                           {"id": new_type.get_public_id()})
             self._event_queue.put(event)
     except PublicIDAlreadyExists:
         raise TypeAlreadyExists(type_id=new_type.get_public_id())
     except (CMDBError, InsertError):
         raise TypeInsertError(new_type.get_public_id())
     return ack