2023-05-02 22:05:18 +00:00
|
|
|
package role
|
|
|
|
|
|
|
|
import (
|
|
|
|
portainer "github.com/portainer/portainer/api"
|
2023-06-20 20:51:34 +00:00
|
|
|
"github.com/portainer/portainer/api/dataservices"
|
2023-05-02 22:05:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ServiceTx struct {
|
2023-06-22 21:28:07 +00:00
|
|
|
dataservices.BaseDataServiceTx[portainer.Role, portainer.RoleID]
|
2023-05-02 22:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateRole creates a new Role.
|
|
|
|
func (service ServiceTx) Create(role *portainer.Role) error {
|
2023-06-22 21:28:07 +00:00
|
|
|
return service.Tx.CreateObject(
|
2023-05-02 22:05:18 +00:00
|
|
|
BucketName,
|
|
|
|
func(id uint64) (int, interface{}) {
|
|
|
|
role.ID = portainer.RoleID(id)
|
|
|
|
return int(role.ID), role
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|