resources.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Copyright (C) 2025 AIDC-AI
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. """
  13. Resource discovery API schemas
  14. """
  15. from typing import List, Optional
  16. from pydantic import BaseModel, Field
  17. class WorkflowInfo(BaseModel):
  18. """Workflow information"""
  19. name: str = Field(..., description="Workflow filename")
  20. display_name: str = Field(..., description="Display name with source info")
  21. source: str = Field(..., description="Source (runninghub or selfhost)")
  22. path: str = Field(..., description="Full path to workflow file")
  23. key: str = Field(..., description="Workflow key (source/name)")
  24. workflow_id: Optional[str] = Field(None, description="RunningHub workflow ID (if applicable)")
  25. class WorkflowListResponse(BaseModel):
  26. """Workflow list response"""
  27. success: bool = True
  28. message: str = "Success"
  29. workflows: List[WorkflowInfo] = Field(..., description="List of available workflows")
  30. class TemplateInfo(BaseModel):
  31. """Template information"""
  32. name: str = Field(..., description="Template filename")
  33. display_name: str = Field(..., description="Display name")
  34. size: str = Field(..., description="Size (e.g., 1080x1920)")
  35. width: int = Field(..., description="Width in pixels")
  36. height: int = Field(..., description="Height in pixels")
  37. orientation: str = Field(..., description="Orientation (portrait/landscape/square)")
  38. path: str = Field(..., description="Full path to template file")
  39. key: str = Field(..., description="Template key (size/name)")
  40. class TemplateListResponse(BaseModel):
  41. """Template list response"""
  42. success: bool = True
  43. message: str = "Success"
  44. templates: List[TemplateInfo] = Field(..., description="List of available templates")
  45. class BGMInfo(BaseModel):
  46. """BGM information"""
  47. name: str = Field(..., description="BGM filename")
  48. path: str = Field(..., description="Full path to BGM file")
  49. source: str = Field(..., description="Source (default or custom)")
  50. class BGMListResponse(BaseModel):
  51. """BGM list response"""
  52. success: bool = True
  53. message: str = "Success"
  54. bgm_files: List[BGMInfo] = Field(..., description="List of available BGM files")