code: func deleteDeviceProfile(dp models.DeviceProfile, w http.ResponseWriter) error {
  	// Check if the device profile is still in use by devices
  	d, err := dbClient.GetDevicesByProfileId(dp.Id)
  
  	// XXX ErrNotFound should always be returned but this is not consistent in the implementations
  	if err == db.ErrNotFound {
  		err = nil
  		d = []models.Device{}
  	} else if err != nil {
  		http.Error(w, err.Error(), http.StatusServiceUnavailable)
  		return err
  	}
  	if len(d) > 0 {
  		err = errors.New("Can't delete device profile, the profile is still in use by a device")
  		http.Error(w, err.Error(), http.StatusConflict)
  		return err
  	}
  
  	// Check if the device profile is still in use by provision watchers
  	pw, err := dbClient.GetProvisionWatchersByProfileId(dp.Id)
  	if err != nil {
  		http.Error(w, err.Error(), http.StatusServiceUnavailable)
  		return err
  	}
  	if len(pw) > 0 {
  		err = errors.New("Cant delete device profile, the profile is still in use by a provision watcher")
  		http.Error(w, err.Error(), http.StatusConflict)
  		return err
  	}
  
  	// Delete the profile
  	if err := dbClient.DeleteDeviceProfileById(dp.Id); err != nil {
  		http.Error(w, err.Error(), http.StatusServiceUnavailable)
  		return err
  	}
  
  	return nil
  }
docs: // Delete the device profile
  // Make sure there are no devices still using it
  // Delete the associated commands