mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
3eb909c4b4
* add setup steps * refactoring * omitempty * cleanup * begin org * create org * setup org * setup org * merge * fixes * fixes * fixes * add project * add oidc application * fix app creation * add resourceOwner to writemodels * resource owner * cleanup * global org, iam project and iam member in setup * logs * logs * logs * cleanup * Update internal/v2/command/project.go Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> * check project state * add org domain commands * add org status changes and member commands * fixes * policies * login policy * fix iam project event * mapper * label policy * change to command * fix * fix * handle change event differently and lot of fixes * fixes * changedEvent handling Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
92 lines
2.5 KiB
Go
92 lines
2.5 KiB
Go
package org
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
"github.com/caos/zitadel/internal/v2/repository/policy"
|
|
)
|
|
|
|
var (
|
|
LabelPolicyAddedEventType = orgEventTypePrefix + policy.LabelPolicyAddedEventType
|
|
LabelPolicyChangedEventType = orgEventTypePrefix + policy.LabelPolicyChangedEventType
|
|
LabelPolicyRemovedEventType = orgEventTypePrefix + policy.LabelPolicyRemovedEventType
|
|
)
|
|
|
|
type LabelPolicyAddedEvent struct {
|
|
policy.LabelPolicyAddedEvent
|
|
}
|
|
|
|
func NewLabelPolicyAddedEvent(
|
|
ctx context.Context,
|
|
primaryColor,
|
|
secondaryColor string,
|
|
) *LabelPolicyAddedEvent {
|
|
return &LabelPolicyAddedEvent{
|
|
LabelPolicyAddedEvent: *policy.NewLabelPolicyAddedEvent(
|
|
eventstore.NewBaseEventForPush(ctx, LabelPolicyAddedEventType),
|
|
primaryColor,
|
|
secondaryColor),
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
type LabelPolicyChangedEvent struct {
|
|
policy.LabelPolicyChangedEvent
|
|
}
|
|
|
|
func NewLabelPolicyChangedEvent(
|
|
ctx context.Context,
|
|
changes []policy.LabelPolicyChanges,
|
|
) (*LabelPolicyChangedEvent, error) {
|
|
changedEvent, err := policy.NewLabelPolicyChangedEvent(
|
|
eventstore.NewBaseEventForPush(ctx, LabelPolicyChangedEventType),
|
|
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,
|
|
) *LabelPolicyRemovedEvent {
|
|
return &LabelPolicyRemovedEvent{
|
|
LabelPolicyRemovedEvent: *policy.NewLabelPolicyRemovedEvent(
|
|
eventstore.NewBaseEventForPush(ctx, LabelPolicyRemovedEventType),
|
|
),
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|