Files
zitadel/backend/v3/domain/instance_domain.go

77 lines
2.9 KiB
Go
Raw Normal View History

2025-07-16 09:26:46 +02:00
package domain
import (
"context"
2025-07-16 18:36:21 +02:00
"time"
2025-07-16 09:26:46 +02:00
"github.com/zitadel/zitadel/backend/v3/storage/database"
)
type InstanceDomain struct {
InstanceID string `json:"instanceId,omitempty" db:"instance_id"`
Domain string `json:"domain,omitempty" db:"domain"`
IsPrimary bool `json:"isPrimary,omitempty" db:"is_primary"`
Type DomainType `json:"type,omitempty" db:"type"`
2025-07-16 09:26:46 +02:00
2025-07-23 11:37:55 +02:00
CreatedAt time.Time `json:"createdAt,omitzero" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt,omitzero" db:"updated_at"`
2025-07-16 09:26:46 +02:00
}
type AddInstanceDomain struct {
InstanceID string `json:"instanceId,omitempty" db:"instance_id"`
Domain string `json:"domain,omitempty" db:"domain"`
IsPrimary bool `json:"isPrimary,omitempty" db:"is_primary"`
IsGenerated bool `json:"isGenerated,omitempty" db:"is_generated"`
Type DomainType `json:"type,omitempty" db:"type"`
2025-07-16 18:36:21 +02:00
// CreatedAt is the time when the domain was added.
// It is set by the repository and should not be set by the caller.
CreatedAt *time.Time `json:"createdAt,omitzero" db:"created_at"`
2025-07-16 18:36:21 +02:00
// UpdatedAt is the time when the domain was last updated.
// It is set by the repository and should not be set by the caller.
UpdatedAt *time.Time `json:"updatedAt,omitzero" db:"updated_at"`
2025-07-16 09:26:46 +02:00
}
type instanceDomainColumns interface {
domainColumns
// IsGeneratedColumn returns the column for the is generated field.
2025-07-22 19:09:56 +02:00
// `qualified` indicates if the column should be qualified with the table name.
IsGeneratedColumn(qualified bool) database.Column
// TypeColumn returns the column for the type field.
// `qualified` indicates if the column should be qualified with the table name.
TypeColumn(qualified bool) database.Column
2025-07-16 09:26:46 +02:00
}
type instanceDomainConditions interface {
domainConditions
// TypeCondition returns a filter for the type field.
TypeCondition(typ DomainType) database.Condition
2025-07-16 09:26:46 +02:00
}
type instanceDomainChanges interface {
domainChanges
// SetType sets the type column.
SetType(typ DomainType) database.Change
2025-07-16 09:26:46 +02:00
}
type InstanceDomainRepository interface {
instanceDomainColumns
instanceDomainConditions
instanceDomainChanges
2025-07-17 15:32:50 +02:00
// Get returns a single domain based on the criteria.
// If no domain is found, it returns an error of type [database.ErrNotFound].
// If multiple domains are found, it returns an error of type [database.ErrMultipleRows].
Get(ctx context.Context, opts ...database.QueryOption) (*InstanceDomain, error)
// List returns a list of domains based on the criteria.
// If no domains are found, it returns an empty slice.
List(ctx context.Context, opts ...database.QueryOption) ([]*InstanceDomain, error)
2025-07-16 09:26:46 +02:00
// Add adds a new domain to the instance.
Add(ctx context.Context, domain *AddInstanceDomain) error
// Update updates an existing domain in the instance.
2025-07-16 18:36:21 +02:00
Update(ctx context.Context, condition database.Condition, changes ...database.Change) (int64, error)
2025-07-16 09:26:46 +02:00
// Remove removes a domain from the instance.
2025-07-16 18:36:21 +02:00
Remove(ctx context.Context, condition database.Condition) (int64, error)
2025-07-16 09:26:46 +02:00
}