コード例 #1
0
    def delete_type(self, public_id: int):
        """Delete a type by the public id
        Also removes the id from the category type list if existing
        """
        try:
            ack = self._delete(TypeModel.COLLECTION, public_id)
        except Exception as err:
            raise ObjectManagerDeleteError(err=err)

        if ack:
            try:
                category = self.get_category_by(types=public_id)
                category.types.remove(public_id)
                self.update_category(category=category)
            # If no category with this ID
            except ObjectManagerGetError:
                pass
            except ObjectManagerUpdateError as err:
                LOGGER.error(err.message)
        if self._event_queue:
            event = Event("cmdb.core.objecttype.deleted", {"id": public_id})
            self._event_queue.put(event)
        return ack
コード例 #2
0
 def delete_link(self, public_id: int):
     try:
         ack = self._delete(CmdbLink.COLLECTION, public_id)
     except (CMDBError, Exception) as err:
         raise ObjectManagerDeleteError(err)
     return ack
コード例 #3
0
 def delete_collection_template(self, public_id: int) -> bool:
     try:
         return self._delete(CmdbCollectionTemplate.COLLECTION, public_id)
     except (CMDBError, Exception) as err:
         raise ObjectManagerDeleteError(err)
コード例 #4
0
 def delete_category(self, public_id: int):
     """Remove a category from the database"""
     try:
         return self._delete(CategoryModel.COLLECTION, public_id)
     except Exception as err:
         raise ObjectManagerDeleteError(err=err)