🔧 fix(schemas.py): import ApiKeyRead from api_key module to fix missing import error
🔧 fix(models/__init__.py): add ApiKey to __all__ list to fix missing import error ✨ feat(models/api_key.py): add ApiKey model and its related classes to support API key functionality
This commit is contained in:
parent
48965a8ba8
commit
130dc7ead6
3 changed files with 37 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from langflow.services.database.models.api_key import ApiKeyRead
|
||||
from langflow.services.database.models.flow import FlowCreate, FlowRead
|
||||
from pydantic import BaseModel, Field, validator
|
||||
import json
|
||||
|
|
@ -134,3 +135,9 @@ class ComponentListCreate(BaseModel):
|
|||
|
||||
class ComponentListRead(BaseModel):
|
||||
flows: List[FlowRead]
|
||||
|
||||
|
||||
class ApiKeyResponse(BaseModel):
|
||||
total_count: int
|
||||
user_id: str
|
||||
api_keys: List[ApiKeyRead]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from .flow import Flow
|
||||
from .user import User
|
||||
from .token import Token
|
||||
from .api_key import ApiKey
|
||||
|
||||
__all__ = ["Flow", "User", "Token"]
|
||||
__all__ = ["Flow", "User", "Token", "ApiKey"]
|
||||
|
|
|
|||
28
src/backend/langflow/services/database/models/api_key.py
Normal file
28
src/backend/langflow/services/database/models/api_key.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from sqlmodel import Field
|
||||
from uuid import UUID, uuid4
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from langflow.services.database.models.base import SQLModelSerializable, SQLModel
|
||||
|
||||
|
||||
class ApiKeyBase(SQLModelSerializable):
|
||||
api_key: str = Field(index=True, unique=True)
|
||||
name: str = Field()
|
||||
create_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
last_used_at: Optional[datetime] = Field()
|
||||
|
||||
|
||||
class ApiKey(ApiKeyBase, table=True):
|
||||
id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True)
|
||||
|
||||
|
||||
class ApiKeyCreate(SQLModel):
|
||||
name: str = Field()
|
||||
|
||||
|
||||
class ApiKeyRead(SQLModel):
|
||||
id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True)
|
||||
api_key: str = Field(index=True, unique=True)
|
||||
name: str = Field()
|
||||
create_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
last_used_at: Optional[datetime] = Field()
|
||||
Loading…
Add table
Add a link
Reference in a new issue