2023-02-20 19:11:18 +00:00
|
|
|
package endpointgroup
|
|
|
|
|
|
|
|
import (
|
|
|
|
portainer "github.com/portainer/portainer/api"
|
2023-06-20 20:51:34 +00:00
|
|
|
"github.com/portainer/portainer/api/dataservices"
|
2023-02-20 19:11:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ServiceTx struct {
|
2023-06-22 21:28:07 +00:00
|
|
|
dataservices.BaseDataServiceTx[portainer.EndpointGroup, portainer.EndpointGroupID]
|
2023-02-20 19:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateEndpointGroup assign an ID to a new environment(endpoint) group and saves it.
|
|
|
|
func (service ServiceTx) Create(endpointGroup *portainer.EndpointGroup) error {
|
2023-06-22 21:28:07 +00:00
|
|
|
return service.Tx.CreateObject(
|
2023-02-20 19:11:18 +00:00
|
|
|
BucketName,
|
|
|
|
func(id uint64) (int, interface{}) {
|
|
|
|
endpointGroup.ID = portainer.EndpointGroupID(id)
|
|
|
|
return int(endpointGroup.ID), endpointGroup
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|