- Added support for public Realtime API, including new routes for managing API keys and handling WebRTC connections. - Introduced RealtimeApiKey model and associated CRUD operations for admin management of API keys. - Implemented authentication mechanisms for API keys and client secrets. - Enhanced environment configuration with new secrets for Realtime API. - Created OpenAIRealtime session management and event processing for real-time interactions. - Updated schemas and settings to accommodate new features and ensure compatibility with existing systems.
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
"""add public Realtime API keys
|
|
|
|
Revision ID: 20260810_0018
|
|
Revises: 20260810_0017
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision: str = "20260810_0018"
|
|
down_revision: str | Sequence[str] | None = "20260810_0017"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"realtime_api_keys",
|
|
sa.Column("id", sa.String(length=40), nullable=False),
|
|
sa.Column("name", sa.String(length=128), nullable=False),
|
|
sa.Column("key_prefix", sa.String(length=32), nullable=False),
|
|
sa.Column("key_hash", sa.String(length=64), nullable=False),
|
|
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("last_used_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("revoked_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("now()"),
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"updated_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("now()"),
|
|
nullable=False,
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
"ix_realtime_api_keys_key_prefix",
|
|
"realtime_api_keys",
|
|
["key_prefix"],
|
|
unique=True,
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(
|
|
"ix_realtime_api_keys_key_prefix",
|
|
table_name="realtime_api_keys",
|
|
)
|
|
op.drop_table("realtime_api_keys")
|