mirror of https://github.com/portainer/portainer
35 lines
1012 B
Go
35 lines
1012 B
Go
package webhooks
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/request"
|
|
"github.com/portainer/libhttp/response"
|
|
portainer "github.com/portainer/portainer/api"
|
|
)
|
|
|
|
// @summary Delete a webhook
|
|
// @description **Access policy**: authenticated
|
|
// @security ApiKeyAuth
|
|
// @security jwt
|
|
// @tags webhooks
|
|
// @param id path int true "Webhook id"
|
|
// @success 202 "Webhook deleted"
|
|
// @failure 400
|
|
// @failure 500
|
|
// @router /webhooks/{id} [delete]
|
|
func (handler *Handler) webhookDelete(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
id, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid webhook id", err}
|
|
}
|
|
|
|
err = handler.DataStore.Webhook().DeleteWebhook(portainer.WebhookID(id))
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to remove the webhook from the database", err}
|
|
}
|
|
|
|
return response.Empty(w)
|
|
}
|