package model

import "github.com/lib/pq" //pq.StringArray

type ApiKey_PG struct {
	ID                 int64          `gorm:"column:id;primaryKey;autoIncrement" json:"id,omitempty"`
	Name               *string        `gorm:"column:name;not null;unique;index:idx_apikey_name" json:"name,omitempty"`
	ApiType            *string        `gorm:"column:apitype;not null;index:idx_apikey_apitype" json:"type,omitempty"`
	ApiKey             *string        `gorm:"column:apikey;not null;index:idx_apikey_apikey" json:"apikey,omitempty"`
	Active             *bool          `gorm:"column:active;default:true" json:"active,omitempty"`
	Endpoint           *string        `gorm:"column:endpoint" json:"endpoint,omitempty"`
	ResourceNmae       *string        `gorm:"column:resource_name" json:"resource_name,omitempty"`
	DeploymentName     *string        `gorm:"column:deployment_name" json:"deployment_name,omitempty"`
	ApiSecret          *string        `gorm:"column:api_secret" json:"api_secret,omitempty"`
	ModelPrefix        *string        `gorm:"column:model_prefix" json:"model_prefix,omitempty"`
	ModelAlias         *string        `gorm:"column:model_alias" json:"model_alias,omitempty"`
	Parameters         *string        `gorm:"column:parameters" json:"parameters,omitempty"`
	SupportModelsArray pq.StringArray `gorm:"column:support_models;type:text[]" json:"support_models_array,omitempty"`
	SupportModels      *string        `gorm:"-" json:"support_models,omitempty"`
	CreatedAt          int64          `gorm:"column:created_at;autoUpdateTime" json:"created_at,omitempty"`
	UpdatedAt          int64          `gorm:"column:updated_at;autoCreateTime" json:"updated_at,omitempty"`
}

func (ApiKey_PG) TableName() string {
	return "apikeys"
}

type ApiKey struct {
	ID                 int64    `gorm:"column:id;primaryKey;autoIncrement" json:"id,omitempty"`
	Name               *string  `gorm:"column:name;not null;unique;index:idx_apikey_name" json:"name,omitempty"`
	ApiType            *string  `gorm:"column:apitype;not null;index:idx_apikey_apitype" json:"type,omitempty"`
	ApiKey             *string  `gorm:"column:apikey;not null;index:idx_apikey_apikey" json:"apikey,omitempty"`
	Active             *bool    `gorm:"column:active;default:true" json:"active,omitempty"`
	Endpoint           *string  `gorm:"column:endpoint" json:"endpoint,omitempty"`
	ResourceNmae       *string  `gorm:"column:resource_name" json:"resource_name,omitempty"`
	DeploymentName     *string  `gorm:"column:deployment_name" json:"deployment_name,omitempty"`
	AccessKey          *string  `gorm:"column:access_key" json:"access_key,omitempty"`
	SecretKey          *string  `gorm:"column:secret_key" json:"secret_key,omitempty"`
	ModelPrefix        *string  `gorm:"column:model_prefix" json:"model_prefix,omitempty"`
	ModelAlias         *string  `gorm:"column:model_alias" json:"model_alias,omitempty"`
	Parameters         *string  `gorm:"column:parameters" json:"parameters,omitempty"`
	SupportModels      *string  `gorm:"column:support_models;type:json" json:"support_models,omitempty"`
	SupportModelsArray []string `gorm:"-" json:"support_models_array,omitempty"`
	CreatedAt          int64    `gorm:"column:created_at;autoUpdateTime" json:"created_at,omitempty"`
	UpdatedAt          int64    `gorm:"column:updated_at;autoCreateTime" json:"updated_at,omitempty"`
}

func (ApiKey) TableName() string {
	return "apikeys"
}
