2020-11-12 21:50:01 +00:00
|
|
|
package org
|
|
|
|
|
|
|
|
import (
|
2021-01-18 10:24:15 +00:00
|
|
|
"context"
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2021-01-18 10:24:15 +00:00
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
2020-11-12 21:50:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2021-01-04 13:52:13 +00:00
|
|
|
LabelPolicyAddedEventType = orgEventTypePrefix + policy.LabelPolicyAddedEventType
|
|
|
|
LabelPolicyChangedEventType = orgEventTypePrefix + policy.LabelPolicyChangedEventType
|
2021-01-18 10:24:15 +00:00
|
|
|
LabelPolicyRemovedEventType = orgEventTypePrefix + policy.LabelPolicyRemovedEventType
|
2020-11-12 21:50:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type LabelPolicyAddedEvent struct {
|
2021-01-04 13:52:13 +00:00
|
|
|
policy.LabelPolicyAddedEvent
|
2020-11-12 21:50:01 +00:00
|
|
|
}
|
|
|
|
|
2021-01-18 10:24:15 +00:00
|
|
|
func NewLabelPolicyAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
primaryColor,
|
|
|
|
secondaryColor string,
|
2021-03-25 13:41:07 +00:00
|
|
|
hideLoginNameSuffix bool,
|
2021-01-18 10:24:15 +00:00
|
|
|
) *LabelPolicyAddedEvent {
|
|
|
|
return &LabelPolicyAddedEvent{
|
|
|
|
LabelPolicyAddedEvent: *policy.NewLabelPolicyAddedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
LabelPolicyAddedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
primaryColor,
|
2021-03-25 13:41:07 +00:00
|
|
|
secondaryColor,
|
|
|
|
hideLoginNameSuffix),
|
2021-01-18 10:24:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func LabelPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.LabelPolicyAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &LabelPolicyAddedEvent{LabelPolicyAddedEvent: *e.(*policy.LabelPolicyAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:50:01 +00:00
|
|
|
type LabelPolicyChangedEvent struct {
|
2021-01-04 13:52:13 +00:00
|
|
|
policy.LabelPolicyChangedEvent
|
2020-11-12 21:50:01 +00:00
|
|
|
}
|
2021-01-18 10:24:15 +00:00
|
|
|
|
|
|
|
func NewLabelPolicyChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
changes []policy.LabelPolicyChanges,
|
|
|
|
) (*LabelPolicyChangedEvent, error) {
|
|
|
|
changedEvent, err := policy.NewLabelPolicyChangedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
LabelPolicyChangedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &LabelPolicyChangedEvent{LabelPolicyChangedEvent: *changedEvent}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func LabelPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.LabelPolicyChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &LabelPolicyChangedEvent{LabelPolicyChangedEvent: *e.(*policy.LabelPolicyChangedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type LabelPolicyRemovedEvent struct {
|
|
|
|
policy.LabelPolicyRemovedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLabelPolicyRemovedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-18 10:24:15 +00:00
|
|
|
) *LabelPolicyRemovedEvent {
|
|
|
|
return &LabelPolicyRemovedEvent{
|
|
|
|
LabelPolicyRemovedEvent: *policy.NewLabelPolicyRemovedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
LabelPolicyRemovedEventType),
|
2021-01-18 10:24:15 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func LabelPolicyRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
e, err := policy.LabelPolicyRemovedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &LabelPolicyRemovedEvent{LabelPolicyRemovedEvent: *e.(*policy.LabelPolicyRemovedEvent)}, nil
|
|
|
|
}
|