2018-06-11 13:13:19 +00:00
|
|
|
package teammemberships
|
|
|
|
|
|
|
|
import (
|
2018-09-10 10:01:38 +00:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api"
|
|
|
|
"github.com/portainer/portainer/api/http/security"
|
2018-06-11 13:13:19 +00:00
|
|
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Handler is the HTTP handler used to handle team membership operations.
|
|
|
|
type Handler struct {
|
|
|
|
*mux.Router
|
2020-05-20 05:23:15 +00:00
|
|
|
DataStore portainer.DataStore
|
|
|
|
AuthorizationService *portainer.AuthorizationService
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewHandler creates a handler to manage team membership operations.
|
|
|
|
func NewHandler(bouncer *security.RequestBouncer) *Handler {
|
|
|
|
h := &Handler{
|
|
|
|
Router: mux.NewRouter(),
|
|
|
|
}
|
|
|
|
h.Handle("/team_memberships",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.teamMembershipCreate))).Methods(http.MethodPost)
|
2018-06-11 13:13:19 +00:00
|
|
|
h.Handle("/team_memberships",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.teamMembershipList))).Methods(http.MethodGet)
|
2018-06-11 13:13:19 +00:00
|
|
|
h.Handle("/team_memberships/{id}",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.teamMembershipUpdate))).Methods(http.MethodPut)
|
2018-06-11 13:13:19 +00:00
|
|
|
h.Handle("/team_memberships/{id}",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.teamMembershipDelete))).Methods(http.MethodDelete)
|
2018-06-11 13:13:19 +00:00
|
|
|
|
|
|
|
return h
|
|
|
|
}
|