def delete( self, public_id: PublicID, user: UserModel = None, permission: AccessControlPermission = AccessControlPermission.DELETE ) -> ObjectLinkModel: """ Delete a existing link by its PublicID. Args: public_id (int): PublicID of the link in the system. user: request user permission: acl permission Returns: ObjectLinkModel: The deleted link as its model. """ link: ObjectLinkModel = self.get(public_id=public_id) if user and permission: self.object_manager.get_object(public_id=link.primary, user=user, permission=permission) self.object_manager.get_object(public_id=link.secondary, user=user, permission=permission) delete_result = self._delete(self.collection, filter={'public_id': public_id}) if delete_result.deleted_count == 0: raise ManagerDeleteError(err='No link matched this public id') return link
def delete(self, public_id: Union[PublicID, int]) -> TypeModel: """ Delete a existing type by its PublicID. Args: public_id (int): PublicID of the type in the system. Returns: TypeModel: The deleted type as its model. """ raw_type: TypeModel = self.get(public_id=public_id) delete_result = self._delete(self.collection, filter={'public_id': public_id}) if delete_result.deleted_count == 0: raise ManagerDeleteError(err='No type matched this public id') return raw_type
def delete( self, public_id: Union[PublicID, int]) -> Union[CmdbMetaLog, CmdbObjectLog]: """ Delete a existing log by its PublicID. Args: public_id (int): PublicID of the log in the system. Returns: CmdbMetaLog: The deleted log as its model. """ raw_log: Union[CmdbMetaLog, CmdbObjectLog] = self.get(public_id=public_id) delete_result = self._delete(self.collection, filter={'public_id': public_id}) if delete_result.deleted_count == 0: raise ManagerDeleteError(err='No log matched this public id') return raw_log
def delete(self, user_id: PublicID, resource: str, *args, **kwargs): """ Delete a existing setting by the tuple of user_id and identifier. Args: user_id (int): PublicID of the user in the database. resource (str): Name/Identifier of the setting. Returns: UserSettingModel: The deleted setting as its model. """ setting: UserSettingModel = self.get_user_setting(user_id=user_id, resource=resource) delete_result = self._delete(self.collection, filter={ 'user_id': user_id, 'resource': resource }) if delete_result.deleted_count == 0: raise ManagerDeleteError(err='No user matched this public id') return setting