2020-09-18 11:26:28 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
2020-12-18 15:47:45 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
2020-09-18 11:26:28 +00:00
|
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
|
|
"github.com/caos/zitadel/internal/iam/repository/view"
|
|
|
|
iam_es_model "github.com/caos/zitadel/internal/iam/repository/view/model"
|
|
|
|
global_view "github.com/caos/zitadel/internal/view/repository"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
idpConfigTable = "auth.idp_configs"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) IDPConfigByID(idpID string) (*iam_es_model.IDPConfigView, error) {
|
|
|
|
return view.IDPByID(v.Db, idpConfigTable, idpID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) GetIDPConfigsByAggregateID(aggregateID string) ([]*iam_es_model.IDPConfigView, error) {
|
|
|
|
return view.GetIDPConfigsByAggregateID(v.Db, idpConfigTable, aggregateID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) SearchIDPConfigs(request *iam_model.IDPConfigSearchRequest) ([]*iam_es_model.IDPConfigView, uint64, error) {
|
|
|
|
return view.SearchIDPs(v.Db, idpConfigTable, request)
|
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) PutIDPConfig(idp *iam_es_model.IDPConfigView, event *models.Event) error {
|
2020-09-18 11:26:28 +00:00
|
|
|
err := view.PutIDP(v.Db, idpConfigTable, idp)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-12-18 15:47:45 +00:00
|
|
|
return v.ProcessedIDPConfigSequence(event)
|
2020-09-18 11:26:28 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) DeleteIDPConfig(idpID string, event *models.Event) error {
|
2020-09-18 11:26:28 +00:00
|
|
|
err := view.DeleteIDP(v.Db, idpConfigTable, idpID)
|
|
|
|
if err != nil && !errors.IsNotFound(err) {
|
|
|
|
return err
|
|
|
|
}
|
2020-12-18 15:47:45 +00:00
|
|
|
return v.ProcessedIDPConfigSequence(event)
|
2020-09-18 11:26:28 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) GetLatestIDPConfigSequence(aggregateType string) (*global_view.CurrentSequence, error) {
|
|
|
|
return v.latestSequence(idpConfigTable, aggregateType)
|
2020-09-18 11:26:28 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) ProcessedIDPConfigSequence(event *models.Event) error {
|
|
|
|
return v.saveCurrentSequence(idpConfigTable, event)
|
2020-12-02 07:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) UpdateIDPConfigSpoolerRunTimestamp() error {
|
|
|
|
return v.updateSpoolerRunSequence(idpConfigTable)
|
2020-09-18 11:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) GetLatestIDPConfigFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
|
|
|
return v.latestFailedEvent(idpConfigTable, sequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedIDPConfigFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|