2021-05-08 19:25:00 +02:00
|
|
|
package bolt
|
|
|
|
|
2021-05-08 22:25:31 +02:00
|
|
|
import (
|
|
|
|
"github.com/ansible-semaphore/semaphore/db"
|
|
|
|
)
|
2021-05-08 19:25:00 +02:00
|
|
|
|
|
|
|
func (d *BoltDb) GetAccessKey(projectID int, accessKeyID int) (db.AccessKey, error) {
|
|
|
|
var key db.AccessKey
|
2021-05-13 21:45:54 +02:00
|
|
|
err := d.getObject(projectID, db.AccessKeyProps, intObjectID(accessKeyID), &key)
|
2021-05-08 19:25:00 +02:00
|
|
|
return key, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) GetAccessKeys(projectID int, params db.RetrieveQueryParams) ([]db.AccessKey, error) {
|
|
|
|
var keys []db.AccessKey
|
2021-05-13 21:45:54 +02:00
|
|
|
err := d.getObjects(projectID, db.AccessKeyProps, params, nil, &keys)
|
2021-05-08 19:25:00 +02:00
|
|
|
return keys, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) UpdateAccessKey(key db.AccessKey) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.updateObject(*key.ProjectID, db.AccessKeyProps, key)
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-08 22:25:31 +02:00
|
|
|
func (d *BoltDb) CreateAccessKey(key db.AccessKey) (db.AccessKey, error) {
|
2021-05-14 13:47:32 +02:00
|
|
|
newKey, err := d.createObject(*key.ProjectID, db.AccessKeyProps, key)
|
2021-05-08 22:25:31 +02:00
|
|
|
return newKey.(db.AccessKey), err
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) DeleteAccessKey(projectID int, accessKeyID int) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.deleteObject(projectID, db.AccessKeyProps, intObjectID(accessKeyID))
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) DeleteAccessKeySoft(projectID int, accessKeyID int) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.deleteObjectSoft(projectID, db.AccessKeyProps, intObjectID(accessKeyID))
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-08 22:25:31 +02:00
|
|
|
func (d *BoltDb) GetGlobalAccessKey(accessKeyID int) (key db.AccessKey, err error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
err = d.getObject(0, db.GlobalAccessKeyProps, intObjectID(accessKeyID), &key)
|
2021-05-08 22:25:31 +02:00
|
|
|
return
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-08 22:25:31 +02:00
|
|
|
func (d *BoltDb) GetGlobalAccessKeys(params db.RetrieveQueryParams) (keys []db.AccessKey, err error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
err = d.getObjects(0, db.GlobalAccessKeyProps, params, nil, &keys)
|
2021-05-08 22:25:31 +02:00
|
|
|
return
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) UpdateGlobalAccessKey(key db.AccessKey) error {
|
2021-05-14 13:47:32 +02:00
|
|
|
return d.updateObject(0, db.GlobalAccessKeyProps, key)
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-08 22:25:31 +02:00
|
|
|
func (d *BoltDb) CreateGlobalAccessKey(key db.AccessKey) (db.AccessKey, error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
newKey, err := d.createObject(0, db.GlobalAccessKeyProps, key)
|
2021-05-08 22:25:31 +02:00
|
|
|
return newKey.(db.AccessKey), err
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) DeleteGlobalAccessKey(accessKeyID int) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.deleteObject(0, db.GlobalAccessKeyProps, intObjectID(accessKeyID))
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) DeleteGlobalAccessKeySoft(accessKeyID int) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.deleteObjectSoft(0, db.GlobalAccessKeyProps, intObjectID(accessKeyID))
|
2021-05-08 19:25:00 +02:00
|
|
|
}
|