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:
Agnès Toulet
2021-11-05 15:06:14 +01:00
committed by GitHub
parent e0ad74a815
commit 3a6b8535b1
7 changed files with 34 additions and 8 deletions
+5 -2
View File
@@ -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