2020-11-12 21:50:01 +00:00
|
|
|
package iam
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
2020-11-30 05:40:56 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
2020-11-12 21:50:01 +00:00
|
|
|
"github.com/caos/zitadel/internal/v2/repository/policy"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
OrgIAMPolicyAddedEventType = iamEventTypePrefix + policy.OrgIAMPolicyAddedEventType
|
|
|
|
)
|
|
|
|
|
|
|
|
type OrgIAMPolicyReadModel struct{ policy.OrgIAMPolicyReadModel }
|
|
|
|
|
2020-11-25 13:12:44 +00:00
|
|
|
func (rm *OrgIAMPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
|
2020-11-12 21:50:01 +00:00
|
|
|
for _, event := range events {
|
|
|
|
switch e := event.(type) {
|
|
|
|
case *OrgIAMPolicyAddedEvent:
|
|
|
|
rm.ReadModel.AppendEvents(&e.OrgIAMPolicyAddedEvent)
|
|
|
|
case *policy.OrgIAMPolicyAddedEvent:
|
|
|
|
rm.ReadModel.AppendEvents(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type OrgIAMPolicyAddedEvent struct {
|
|
|
|
policy.OrgIAMPolicyAddedEvent
|
|
|
|
}
|
2020-11-30 05:40:56 +00:00
|
|
|
|
|
|
|
func OrgIAMPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.OrgIAMPolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &OrgIAMPolicyAddedEvent{OrgIAMPolicyAddedEvent: *e.(*policy.OrgIAMPolicyAddedEvent)}, nil
|
|
|
|
}
|