2021-05-08 22:25:31 +02:00
|
|
|
package bolt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ansible-semaphore/semaphore/db"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (d *BoltDb) CreateTemplate(template db.Template) (db.Template, error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
newTemplate, err := d.createObject(template.ProjectID, db.TemplateProps, template)
|
2021-05-08 22:25:31 +02:00
|
|
|
return newTemplate.(db.Template), err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) UpdateTemplate(template db.Template) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.updateObject(template.ProjectID, db.TemplateProps, template)
|
2021-05-08 22:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) GetTemplates(projectID int, params db.RetrieveQueryParams) (templates []db.Template, err error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
err = d.getObjects(projectID, db.TemplateProps, params, nil, &templates)
|
2021-05-08 22:25:31 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) GetTemplate(projectID int, templateID int) (template db.Template, err error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
err = d.getObject(projectID, db.TemplateProps, intObjectID(templateID), &template)
|
2021-05-08 22:25:31 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) DeleteTemplate(projectID int, templateID int) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.deleteObject(projectID, db.TemplateProps, intObjectID(templateID))
|
2021-05-08 22:25:31 +02:00
|
|
|
}
|