2020-11-06 13:47:27 +01:00
|
|
|
package iam
|
|
|
|
|
2020-11-06 22:09:19 +01:00
|
|
|
import (
|
2020-11-17 13:44:37 +01:00
|
|
|
"context"
|
2020-11-06 22:09:19 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
2021-01-04 14:52:13 +01:00
|
|
|
"github.com/caos/zitadel/internal/v2/domain"
|
2020-11-06 22:09:19 +01:00
|
|
|
)
|
2020-11-06 13:47:27 +01:00
|
|
|
|
2020-11-12 22:50:01 +01:00
|
|
|
const (
|
2021-01-04 14:52:13 +01:00
|
|
|
iamEventTypePrefix = eventstore.EventType("iam.")
|
2020-11-12 22:50:01 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
AggregateType = "iam"
|
|
|
|
AggregateVersion = "v1"
|
|
|
|
)
|
|
|
|
|
2020-11-06 13:47:27 +01:00
|
|
|
type Aggregate struct {
|
|
|
|
eventstore.Aggregate
|
|
|
|
}
|
2020-11-12 22:50:01 +01:00
|
|
|
|
|
|
|
func NewAggregate(
|
|
|
|
id,
|
|
|
|
resourceOwner string,
|
|
|
|
previousSequence uint64,
|
|
|
|
) *Aggregate {
|
|
|
|
|
|
|
|
return &Aggregate{
|
2020-11-18 21:22:15 +01:00
|
|
|
Aggregate: *eventstore.NewAggregate(
|
|
|
|
id,
|
|
|
|
AggregateType,
|
|
|
|
resourceOwner,
|
|
|
|
AggregateVersion,
|
|
|
|
previousSequence,
|
|
|
|
),
|
2020-11-12 22:50:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (a *Aggregate) PushStepStarted(ctx context.Context, step domain.Step) *Aggregate {
|
2020-11-25 20:04:32 +01:00
|
|
|
a.Aggregate = *a.PushEvents(NewSetupStepStartedEvent(ctx, step))
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (a *Aggregate) PushStepDone(ctx context.Context, step domain.Step) *Aggregate {
|
2020-11-25 20:04:32 +01:00
|
|
|
a.Aggregate = *a.PushEvents(NewSetupStepDoneEvent(ctx, step))
|
|
|
|
return a
|
|
|
|
}
|