API: return resource ID when deleting datasource with UID and library element (#41342)
* API: return resource ID when deleting datasource and library element * keep status codes consistent * fix element ID * add test * improve response struct * update endpoints documentation * LibraryElementIDResponse -> DeleteLibraryElementResponse
This commit is contained in:
@@ -169,8 +169,9 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn
|
||||
}
|
||||
|
||||
// deleteLibraryElement deletes a library element.
|
||||
func (l *LibraryElementService) deleteLibraryElement(c context.Context, signedInUser *models.SignedInUser, uid string) error {
|
||||
return l.SQLStore.WithTransactionalDbSession(c, func(session *sqlstore.DBSession) error {
|
||||
func (l *LibraryElementService) deleteLibraryElement(c context.Context, signedInUser *models.SignedInUser, uid string) (int64, error) {
|
||||
var elementID int64
|
||||
err := l.SQLStore.WithTransactionalDbSession(c, func(session *sqlstore.DBSession) error {
|
||||
element, err := getLibraryElement(l.SQLStore.Dialect, session, uid, signedInUser.OrgId)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -198,8 +199,10 @@ func (l *LibraryElementService) deleteLibraryElement(c context.Context, signedIn
|
||||
return ErrLibraryElementNotFound
|
||||
}
|
||||
|
||||
elementID = element.ID
|
||||
return nil
|
||||
})
|
||||
return elementID, err
|
||||
}
|
||||
|
||||
// getLibraryElements gets a Library Element where param == value
|
||||
|
||||
Reference in New Issue
Block a user