2023-11-06 19:36:16 +08:00
|
|
|
import enum
|
|
|
|
|
2024-02-06 13:21:13 +08:00
|
|
|
from extensions.ext_database import db
|
2024-08-13 14:44:10 +08:00
|
|
|
|
|
|
|
from .types import StringUUID
|
2024-02-06 13:21:13 +08:00
|
|
|
|
2023-11-06 19:36:16 +08:00
|
|
|
|
|
|
|
class APIBasedExtensionPoint(enum.Enum):
|
2024-09-10 17:08:06 +08:00
|
|
|
APP_EXTERNAL_DATA_TOOL_QUERY = "app.external_data_tool.query"
|
|
|
|
PING = "ping"
|
|
|
|
APP_MODERATION_INPUT = "app.moderation.input"
|
|
|
|
APP_MODERATION_OUTPUT = "app.moderation.output"
|
2023-11-06 19:36:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
class APIBasedExtension(db.Model):
|
2024-09-10 17:08:06 +08:00
|
|
|
__tablename__ = "api_based_extensions"
|
2023-11-06 19:36:16 +08:00
|
|
|
__table_args__ = (
|
2024-09-10 17:08:06 +08:00
|
|
|
db.PrimaryKeyConstraint("id", name="api_based_extension_pkey"),
|
|
|
|
db.Index("api_based_extension_tenant_idx", "tenant_id"),
|
2023-11-06 19:36:16 +08:00
|
|
|
)
|
|
|
|
|
2024-09-10 17:08:06 +08:00
|
|
|
id = db.Column(StringUUID, server_default=db.text("uuid_generate_v4()"))
|
2024-04-29 11:58:17 +08:00
|
|
|
tenant_id = db.Column(StringUUID, nullable=False)
|
2023-11-06 19:36:16 +08:00
|
|
|
name = db.Column(db.String(255), nullable=False)
|
|
|
|
api_endpoint = db.Column(db.String(255), nullable=False)
|
|
|
|
api_key = db.Column(db.Text, nullable=False)
|
2024-09-10 17:08:06 +08:00
|
|
|
created_at = db.Column(db.DateTime, nullable=False, server_default=db.text("CURRENT_TIMESTAMP(0)"))
|