2020-10-20 17:10:23 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
2020-12-18 15:47:45 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
2020-10-20 17:10:23 +00:00
|
|
|
"github.com/caos/zitadel/internal/iam/repository/view"
|
|
|
|
"github.com/caos/zitadel/internal/iam/repository/view/model"
|
|
|
|
global_view "github.com/caos/zitadel/internal/view/repository"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
labelPolicyTable = "adminapi.label_policies"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) LabelPolicyByAggregateID(aggregateID string) (*model.LabelPolicyView, error) {
|
|
|
|
return view.GetLabelPolicyByAggregateID(v.Db, labelPolicyTable, aggregateID)
|
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) PutLabelPolicy(policy *model.LabelPolicyView, event *models.Event) error {
|
2020-10-20 17:10:23 +00:00
|
|
|
err := view.PutLabelPolicy(v.Db, labelPolicyTable, policy)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-12-18 15:47:45 +00:00
|
|
|
return v.ProcessedLabelPolicySequence(event)
|
2020-10-20 17:10:23 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) GetLatestLabelPolicySequence(aggregateType string) (*global_view.CurrentSequence, error) {
|
|
|
|
return v.latestSequence(labelPolicyTable, aggregateType)
|
2020-10-20 17:10:23 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) ProcessedLabelPolicySequence(event *models.Event) error {
|
|
|
|
return v.saveCurrentSequence(labelPolicyTable, event)
|
2020-12-02 07:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) UpdateLabelPolicySpoolerRunTimestamp() error {
|
|
|
|
return v.updateSpoolerRunSequence(labelPolicyTable)
|
2020-10-20 17:10:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) GetLatestLabelPolicyFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
|
|
|
return v.latestFailedEvent(labelPolicyTable, sequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedLabelPolicyFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|