mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
# Which Problems Are Solved This PR implements the endpoints listed in https://github.com/zitadel/zitadel/issues/10444 . # How the Problems Are Solved The implementation follows the same pattern as the Instance one. The `Add` and `Remove` are implementing the `Commander` interface, while `List` Domains endpoints are implementing the `Querier` interace. The PR adds also some forgotten calls to the relational logic for the Instance API. The commits are identifiable by the label `instance:` prepended to them. This is the complete list: bafce01b0 , 6fe7257ab , e27bc9c34 , 8133ede73 , fde667953 , a3e1135ed , ee1a6f9c1 # Additional Context - Closes #10444 --------- Co-authored-by: Elio Bischof <[email protected]> Co-authored-by: Lebogang Phoshoko <[email protected]> Co-authored-by: Wim Van Laer <[email protected]> Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Gayathri Vijayan <[email protected]>
87 lines
3.6 KiB
Go
87 lines
3.6 KiB
Go
package domain
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"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 indicates if the domain is the primary domain of the instance.
|
|
// It is only set for custom domains.
|
|
IsPrimary *bool `json:"isPrimary,omitempty" db:"is_primary"`
|
|
// IsGenerated indicates if the domain is a generated domain.
|
|
// It is only set for custom domains.
|
|
IsGenerated *bool `json:"isGenerated,omitempty" db:"is_generated"`
|
|
Type DomainType `json:"type,omitempty" db:"type"`
|
|
|
|
CreatedAt time.Time `json:"createdAt,omitzero" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updatedAt,omitzero" db:"updated_at"`
|
|
}
|
|
|
|
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"`
|
|
|
|
// 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"`
|
|
// 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"`
|
|
}
|
|
|
|
type instanceDomainColumns interface {
|
|
domainColumns
|
|
// IsGeneratedColumn returns the column for the is generated field.
|
|
IsGeneratedColumn() database.Column
|
|
// TypeColumn returns the column for the type field.
|
|
TypeColumn() database.Column
|
|
}
|
|
|
|
type instanceDomainConditions interface {
|
|
domainConditions
|
|
// PrimaryKeyCondition returns a filter on the primary key fields.
|
|
PrimaryKeyCondition(domain string) database.Condition
|
|
// TypeCondition returns a filter for the type field.
|
|
TypeCondition(typ DomainType) database.Condition
|
|
// IsGeneratedCondition returns a filter for the is_generated field
|
|
IsGeneratedCondition(isGenerated bool) database.Condition
|
|
}
|
|
|
|
type instanceDomainChanges interface {
|
|
domainChanges
|
|
// SetType sets the type column.
|
|
SetType(typ DomainType) database.Change
|
|
}
|
|
|
|
//go:generate mockgen -typed -package domainmock -destination ./mock/instance_domain.mock.go . InstanceDomainRepository
|
|
type InstanceDomainRepository interface {
|
|
Repository
|
|
|
|
instanceDomainColumns
|
|
instanceDomainConditions
|
|
instanceDomainChanges
|
|
|
|
// 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, client database.QueryExecutor, 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, client database.QueryExecutor, opts ...database.QueryOption) ([]*InstanceDomain, error)
|
|
|
|
// Add adds a new domain to the instance.
|
|
Add(ctx context.Context, client database.QueryExecutor, domain *AddInstanceDomain) error
|
|
// Update updates an existing domain in the instance.
|
|
Update(ctx context.Context, client database.QueryExecutor, condition database.Condition, changes ...database.Change) (int64, error)
|
|
// Remove removes a domain from the instance.
|
|
Remove(ctx context.Context, client database.QueryExecutor, condition database.Condition) (int64, error)
|
|
}
|