model

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthExternalIDValidationID validation.ID = "Auth.ExternalID"
	AuthTenantIDValidationID   validation.ID = "Auth.TenantID"
	AuthTypeValidationID       validation.ID = "Auth.Type"
	AuthPropertiesValidationID validation.ID = "Auth.Properties"
	AuthStatusValidationID     validation.ID = "Auth.Status"
)

Validation IDs for the Auth model fields that require validation.

View Source
const (
	RegionalSystemRegionValidationID validation.ID = "RegionalSystem.Region"
	SystemStatusValidationID         validation.ID = "RegionalSystem.Status"
	RegionalSystemLabelsValidationID validation.ID = "RegionalSystem.Labels"
)

Validation IDs for the System model fields that are validated individually.

View Source
const (
	SystemExternalIDValidationID validation.ID = "System.ExternalID"
	SystemTypeValidationID       validation.ID = "System.Type"
)
View Source
const (
	TenantIDValidationID         = "Tenant.ID"
	TenantOwnerTypeValidationID  = "Tenant.OwnerType"
	TenantUserGroupsValidationID = "Tenant.UserGroups"
	TenantLabelsValidationID     = "Tenant.Labels"
)

Variables

View Source
var ErrInvalidTransition = errors.New("invalid tenant status transition")
View Source
var ErrSystemNotLoaded = errors.New("system for regional system is not loaded")

Functions

This section is empty.

Types

type Auth added in v1.2.0

type Auth struct {
	ExternalID   string            `gorm:"column:id;primaryKey" validationID:"Auth.ExternalID"`
	TenantID     string            `gorm:"column:tenant_id;not null" validationID:"Auth.TenantID"`
	Type         string            `gorm:"column:type;not null" validationID:"Auth.Type"`
	Properties   map[string]string `gorm:"column:properties;type:jsonb;serializer:json" validationID:"Auth.Properties"`
	Status       string            `gorm:"column:status;not null" validationID:"Auth.Status"`
	ErrorMessage string            `gorm:"column:error_message"`
	UpdatedAt    time.Time         `gorm:"column:updated_at;autoUpdateTime"`
	CreatedAt    time.Time         `gorm:"column:created_at;autoCreateTime"`
}

Auth represents an auth method associated with a tenant.

func (*Auth) PaginationKey added in v1.2.0

func (a *Auth) PaginationKey() map[repository.QueryField]any

PaginationKey returns a map representing the pagination key for the Auth model.

func (*Auth) TableName added in v1.2.0

func (a *Auth) TableName() string

TableName specifies the database table name for the Auth model.

func (*Auth) ToProto added in v1.2.0

func (a *Auth) ToProto() *pb.Auth

ToProto converts the Auth model to its protobuf representation.

func (*Auth) Validations added in v1.3.0

func (a *Auth) Validations() []validation.Field

Validations returns the validation fields for the Auth model.

type AuthStatusConstraint added in v1.3.0

type AuthStatusConstraint struct{}

AuthStatusConstraint validates the Auth.Status field.

func (AuthStatusConstraint) Validate added in v1.3.0

func (c AuthStatusConstraint) Validate(value any) error

Validate checks if the provided value is a valid Auth status. Auth status must be one of the defined enum values in pb.AuthStatus.

type RegionalSystem added in v1.7.0

type RegionalSystem struct {
	SystemID      uuid.UUID         `gorm:"type:uuid;column:system_id;primaryKey"`
	Region        string            `gorm:"column:region;primaryKey" validationID:"RegionalSystem.Region"`
	Status        string            `gorm:"column:status" validationID:"RegionalSystem.Status"`
	L2KeyID       string            `gorm:"column:l2key_id" validationID:"RegionalSystem.L2KeyID"`
	HasL1KeyClaim *bool             `gorm:"column:has_l1_key_claim"` // claim status of related L1 key
	Labels        map[string]string `gorm:"column:labels;type:jsonb;serializer:json" validationID:"RegionalSystem.Labels"`
	UpdatedAt     time.Time         `gorm:"column:updated_at;autoUpdateTime"`
	CreatedAt     time.Time         `gorm:"column:created_at;autoCreateTime"`

	System *System `gorm:"foreignKey:SystemID;references:ID"`
}

RegionalSystem represents a customer-exposed "tenant" of any kind.

func (*RegionalSystem) HasActiveL1KeyClaim added in v1.7.0

func (s *RegionalSystem) HasActiveL1KeyClaim() bool

HasActiveL1KeyClaim returns true if the System has active L1KeyClaim.

func (*RegionalSystem) IsAvailable added in v1.7.0

func (s *RegionalSystem) IsAvailable() bool

IsAvailable returns true if the System status is STATUS_AVAILABLE.

func (*RegionalSystem) PaginationKey added in v1.7.0

func (s *RegionalSystem) PaginationKey() map[repository.QueryField]any

PaginationKey returns the fields used for pagination.

func (*RegionalSystem) TableName added in v1.7.0

func (s *RegionalSystem) TableName() string

TableName returns the table name of the System entity.

func (*RegionalSystem) ToProto added in v1.7.0

func (s *RegionalSystem) ToProto() (*systemgrpc.System, error)

ToProto converts the System to its gRPC representation.

func (*RegionalSystem) Validations added in v1.7.0

func (s *RegionalSystem) Validations() []validation.Field

Validations returns the validation fields for the System model.

type RegionalSystemStatusConstraint added in v1.7.0

type RegionalSystemStatusConstraint struct{}

RegionalSystemStatusConstraint validates that the system status is one of the allowed statuses.

func (RegionalSystemStatusConstraint) Validate added in v1.7.0

func (c RegionalSystemStatusConstraint) Validate(value any) error

Validate checks if the provided system status is valid.

type System

type System struct {
	ID         uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey"`
	ExternalID string    `gorm:"column:external_id;uniqueIndex:ext_type" validationID:"System.ExternalID"`
	TenantID   *string   `gorm:"column:tenant_id"` // related tenant id; optional
	Type       string    `gorm:"column:type;uniqueIndex:ext_type" validationID:"System.Type"`
	UpdatedAt  time.Time `gorm:"column:updated_at;autoUpdateTime"`
	CreatedAt  time.Time `gorm:"column:created_at;autoCreateTime"`
}

func NewSystem added in v1.7.0

func NewSystem(externalID, systemType string) *System

func (*System) IsLinkedToTenant

func (s *System) IsLinkedToTenant() bool

func (*System) LinkTenant added in v1.7.0

func (s *System) LinkTenant(tenantID string)

func (*System) PaginationKey

func (s *System) PaginationKey() map[repository.QueryField]any

PaginationKey returns the fields used for pagination.

func (*System) TableName

func (s *System) TableName() string

TableName returns the table name of the GlobalSystem entity.

func (*System) Validations added in v1.3.0

func (s *System) Validations() []validation.Field

type Tenant

type Tenant struct {
	ID              string            `gorm:"column:id;primaryKey" validationID:"Tenant.ID"`
	Name            string            `gorm:"column:name" validationID:"Tenant.Name"`
	Region          string            `gorm:"column:region" validationID:"Tenant.Region"`
	OwnerID         string            `gorm:"column:owner_id" validationID:"Tenant.OwnerID"`
	OwnerType       string            `gorm:"column:owner_type" validationID:"Tenant.OwnerType"`
	Status          TenantStatus      `gorm:"column:status"`
	StatusUpdatedAt time.Time         `gorm:"column:status_updated_at"`
	Role            string            `gorm:"column:role" validationID:"Tenant.Role"`
	Labels          map[string]string `gorm:"column:labels;type:jsonb;serializer:json" validationID:"Tenant.Labels"`
	UserGroups      []string          `gorm:"column:user_groups;serializer:json" validationID:"Tenant.UserGroups"`
	UpdatedAt       time.Time         `gorm:"column:updated_at;autoUpdateTime"`
	CreatedAt       time.Time         `gorm:"column:created_at;autoCreateTime"`
}

Tenant represents the customer-managed key (CMK) tenant entity.

func (*Tenant) PaginationKey

func (t *Tenant) PaginationKey() map[repository.QueryField]any

PaginationKey returns the fields used for pagination.

func (*Tenant) SetStatus

func (t *Tenant) SetStatus(status TenantStatus)

func (*Tenant) TableName

func (t *Tenant) TableName() string

TableName returns the table name of the tenant entity.

func (*Tenant) ToProto

func (t *Tenant) ToProto() *tenantgrpc.Tenant

func (*Tenant) Validations added in v1.3.0

func (t *Tenant) Validations() []validation.Field

Validations returns the validation fields for the Tenant Model.

type TenantRoleConstraint added in v1.3.0

type TenantRoleConstraint struct{}

TenantRoleConstraint validates the Tenant.Role field.

func (TenantRoleConstraint) Validate added in v1.3.0

func (t TenantRoleConstraint) Validate(value any) error

Validate checks if the provided value is a valid Tenant role. Tenant role must be one of the defined enum values in tenant proto Role.

type TenantStatus

type TenantStatus string

TenantStatus represents the status of the tenant.

func (TenantStatus) IsActive

func (ts TenantStatus) IsActive() bool

IsActive checks if Status is active.

func (TenantStatus) ValidateTransition

func (ts TenantStatus) ValidateTransition(to pb.Status) error

ValidateTransition checks if the transition from the current status to the target status is valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL