package entity

import (
	"time"
)

//go:generate ../../tools/bin/goqueryset -in entity.go

var Models = []interface{}{
	&UserdebugAuth{}, &UserdebugAuthRecord{}, &UserdebugFeatureConfig{},
}

// gen:qs
type UserdebugAuth struct {
	Updatable
	ClusterID ID        `gorm:"not null"`
	CreatedBy ID        `gorm:"not null"`
	AuthCode  string    `gorm:"type:TEXT;not null"`
	Status    string    `gorm:"not null;type:ENUM('normal', 'revoked')"`
	ExpiresAt time.Time `gorm:"expires_at;type:TIMESTAMP"`
}

// gen:qs
type UserdebugAuthRecord struct {
	Base
	ClusterID     ID             `gorm:"not null"`
	UserID        ID             `gorm:"not null"`
	AuthID        ID             `gorm:"not null"` // Authorization ID
	Auth          *UserdebugAuth `gorm:"foreignkey:AuthID"`
	AuthOperation string         `gorm:"not null;type:ENUM('authorize', 'revoke', 'query')"`
	TimeSpan      int            `gorm:"type:int(11)"`
}

// gen:qs
type UserdebugFeatureConfig struct {
	Base
	OrganizationID ID     `gorm:"not null"`
	FeatureKey     string `gorm:"type:TEXT;not null"`
	Status         string `gorm:"not null;type:ENUM('enabled', 'disabled')"`
}

// gen:qs
type UserAlert struct {
	Updatable

	ProjectID ID `gorm:"not null"`
	UserID    ID `gorm:"not null"`
}
