186 lines
4.4 KiB
Go
Raw Normal View History

package instance
2020-11-25 20:04:32 +01:00
import (
"context"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/idpconfig"
2020-11-25 20:04:32 +01:00
)
const (
IDPConfigAddedEventType eventstore.EventType = "iam.idp.config.added"
IDPConfigChangedEventType eventstore.EventType = "iam.idp.config.changed"
IDPConfigRemovedEventType eventstore.EventType = "iam.idp.config.removed"
IDPConfigDeactivatedEventType eventstore.EventType = "iam.idp.config.deactivated"
IDPConfigReactivatedEventType eventstore.EventType = "iam.idp.config.reactivated"
)
type IDPConfigAddedEvent struct {
idpconfig.IDPConfigAddedEvent
2020-11-25 20:04:32 +01:00
}
func NewIDPConfigAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
configID,
2020-11-25 20:04:32 +01:00
name string,
configType domain.IDPConfigType,
stylingType domain.IDPConfigStylingType,
autoRegister bool,
2020-11-25 20:04:32 +01:00
) *IDPConfigAddedEvent {
return &IDPConfigAddedEvent{
IDPConfigAddedEvent: *idpconfig.NewIDPConfigAddedEvent(
eventstore.NewBaseEventForPush(
2020-11-25 20:04:32 +01:00
ctx,
aggregate,
2020-11-25 20:04:32 +01:00
IDPConfigAddedEventType,
),
configID,
name,
configType,
stylingType,
autoRegister,
2020-11-25 20:04:32 +01:00
),
}
}
func IDPConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e, err := idpconfig.IDPConfigAddedEventMapper(event)
2020-11-26 13:14:07 +01:00
if err != nil {
return nil, err
}
return &IDPConfigAddedEvent{IDPConfigAddedEvent: *e.(*idpconfig.IDPConfigAddedEvent)}, nil
2020-11-26 13:14:07 +01:00
}
2020-11-25 20:04:32 +01:00
type IDPConfigChangedEvent struct {
idpconfig.IDPConfigChangedEvent
2020-11-25 20:04:32 +01:00
}
func NewIDPConfigChangedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
configID,
oldName string,
changes []idpconfig.IDPConfigChanges,
) (*IDPConfigChangedEvent, error) {
changeEvent, err := idpconfig.NewIDPConfigChangedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
IDPConfigChangedEventType),
configID,
oldName,
changes,
)
if err != nil {
return nil, err
2020-11-25 20:04:32 +01:00
}
return &IDPConfigChangedEvent{IDPConfigChangedEvent: *changeEvent}, nil
2020-11-25 20:04:32 +01:00
}
func IDPConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e, err := idpconfig.IDPConfigChangedEventMapper(event)
2020-11-26 13:14:07 +01:00
if err != nil {
return nil, err
}
return &IDPConfigChangedEvent{IDPConfigChangedEvent: *e.(*idpconfig.IDPConfigChangedEvent)}, nil
2020-11-26 13:14:07 +01:00
}
2020-11-25 20:04:32 +01:00
type IDPConfigRemovedEvent struct {
idpconfig.IDPConfigRemovedEvent
2020-11-25 20:04:32 +01:00
}
func NewIDPConfigRemovedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
configID,
name string,
2020-11-25 20:04:32 +01:00
) *IDPConfigRemovedEvent {
return &IDPConfigRemovedEvent{
IDPConfigRemovedEvent: *idpconfig.NewIDPConfigRemovedEvent(
eventstore.NewBaseEventForPush(
2020-11-25 20:04:32 +01:00
ctx,
aggregate,
2020-11-25 20:04:32 +01:00
IDPConfigRemovedEventType,
),
configID,
name,
2020-11-25 20:04:32 +01:00
),
}
}
func IDPConfigRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e, err := idpconfig.IDPConfigRemovedEventMapper(event)
2020-11-26 13:14:07 +01:00
if err != nil {
return nil, err
}
return &IDPConfigRemovedEvent{IDPConfigRemovedEvent: *e.(*idpconfig.IDPConfigRemovedEvent)}, nil
2020-11-26 13:14:07 +01:00
}
2020-11-25 20:04:32 +01:00
type IDPConfigDeactivatedEvent struct {
idpconfig.IDPConfigDeactivatedEvent
2020-11-25 20:04:32 +01:00
}
func NewIDPConfigDeactivatedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
2020-11-25 20:04:32 +01:00
configID string,
) *IDPConfigDeactivatedEvent {
return &IDPConfigDeactivatedEvent{
IDPConfigDeactivatedEvent: *idpconfig.NewIDPConfigDeactivatedEvent(
2020-11-25 20:04:32 +01:00
eventstore.NewBaseEventForPush(
ctx,
aggregate,
2020-11-25 20:04:32 +01:00
IDPConfigDeactivatedEventType,
),
configID,
),
}
}
func IDPConfigDeactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e, err := idpconfig.IDPConfigDeactivatedEventMapper(event)
2020-11-26 13:14:07 +01:00
if err != nil {
return nil, err
}
return &IDPConfigDeactivatedEvent{IDPConfigDeactivatedEvent: *e.(*idpconfig.IDPConfigDeactivatedEvent)}, nil
2020-11-26 13:14:07 +01:00
}
2020-11-25 20:04:32 +01:00
type IDPConfigReactivatedEvent struct {
idpconfig.IDPConfigReactivatedEvent
2020-11-25 20:04:32 +01:00
}
func NewIDPConfigReactivatedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
2020-11-25 20:04:32 +01:00
configID string,
) *IDPConfigReactivatedEvent {
return &IDPConfigReactivatedEvent{
IDPConfigReactivatedEvent: *idpconfig.NewIDPConfigReactivatedEvent(
2020-11-25 20:04:32 +01:00
eventstore.NewBaseEventForPush(
ctx,
aggregate,
2020-11-25 20:04:32 +01:00
IDPConfigReactivatedEventType,
),
configID,
),
}
}
2020-11-26 13:14:07 +01:00
func IDPConfigReactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e, err := idpconfig.IDPConfigReactivatedEventMapper(event)
2020-11-26 13:14:07 +01:00
if err != nil {
return nil, err
}
return &IDPConfigReactivatedEvent{IDPConfigReactivatedEvent: *e.(*idpconfig.IDPConfigReactivatedEvent)}, nil
2020-11-26 13:14:07 +01:00
}