tenant

package
v0.0.0-...-991afdd Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameRequired   = errors.New("tenant name is required")
	ErrNameTooShort   = errors.New("tenant name must be at least 2 characters")
	ErrNameTooLong    = errors.New("tenant name must not exceed 100 characters")
	ErrSlugRequired   = errors.New("tenant slug is required")
	ErrSlugInvalid    = errors.New("tenant slug must contain only lowercase letters, numbers, and hyphens")
	ErrTenantNotFound = errors.New("tenant not found")
	ErrTenantExists   = errors.New("tenant already exists")
	ErrTenantInactive = errors.New("tenant is inactive")
)

Functions

This section is empty.

Types

type Repository

type Repository interface {
	Create(ctx context.Context, tenant *Tenant) error
	GetByID(ctx context.Context, id string) (*Tenant, error)
	GetBySlug(ctx context.Context, slug string) (*Tenant, error)
	Update(ctx context.Context, tenant *Tenant) error
	Delete(ctx context.Context, id string) error
	List(ctx context.Context, limit int) ([]*Tenant, error)
	ListByStatus(ctx context.Context, status Status, limit int) ([]*Tenant, error)
}

Repository defines data access for tenants Note: Tenant operations do NOT require tenantID parameter since tenants are the top-level entity in our multi-tenant architecture

type Status

type Status string

Status represents the tenant's current status

const (
	StatusActive    Status = "active"
	StatusInactive  Status = "inactive"
	StatusSuspended Status = "suspended"
)

type Tenant

type Tenant struct {
	ID        string
	Name      string // Display name (e.g., "Acme Corporation")
	Slug      string // URL-friendly identifier (e.g., "acme-corp")
	Status    Status
	CreatedAt time.Time
	UpdatedAt time.Time

	// CWE-359: IP address tracking for GDPR compliance (90-day expiration)
	CreatedFromIPAddress    string    // Encrypted IP address
	CreatedFromIPTimestamp  time.Time // For 90-day expiration tracking
	ModifiedFromIPAddress   string    // Encrypted IP address
	ModifiedFromIPTimestamp time.Time // For 90-day expiration tracking
}

Tenant represents a tenant in the system Each tenant is a separate customer/organization

func (*Tenant) IsActive

func (t *Tenant) IsActive() bool

IsActive returns true if the tenant is active

func (*Tenant) Validate

func (t *Tenant) Validate() error

Validate validates the tenant entity

Jump to

Keyboard shortcuts

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