Create a new app with the given name and organization ID. Args: app_name (str): The name of the app to create. project_id (str): The ID of the project. Returns: AppDB: The created app. Raises: ValueError: If an app with the same name already exists
(
app_name: str,
template_key: Optional[str] = None,
project_id: Optional[str] = None,
)
| 597 | |
| 598 | |
| 599 | async def create_app_and_envs( |
| 600 | app_name: str, |
| 601 | template_key: Optional[str] = None, |
| 602 | project_id: Optional[str] = None, |
| 603 | ) -> AppDB: |
| 604 | """ |
| 605 | Create a new app with the given name and organization ID. |
| 606 | |
| 607 | Args: |
| 608 | app_name (str): The name of the app to create. |
| 609 | project_id (str): The ID of the project. |
| 610 | |
| 611 | Returns: |
| 612 | AppDB: The created app. |
| 613 | |
| 614 | Raises: |
| 615 | ValueError: If an app with the same name already exists. |
| 616 | """ |
| 617 | |
| 618 | app = await fetch_app_by_name_and_parameters( |
| 619 | app_name=app_name, project_id=project_id |
| 620 | ) |
| 621 | if app is not None: |
| 622 | raise ValueError("App with the same name already exists") |
| 623 | |
| 624 | app_type = await get_app_type( |
| 625 | template_key=template_key, |
| 626 | ) |
| 627 | |
| 628 | async with engine.core_session() as session: |
| 629 | app = AppDB( |
| 630 | app_name=app_name, project_id=uuid.UUID(project_id), app_type=app_type |
| 631 | ) |
| 632 | |
| 633 | session.add(app) |
| 634 | await session.commit() |
| 635 | await session.refresh(app) |
| 636 | |
| 637 | await initialize_environments(session=session, app_db=app) |
| 638 | return app |
| 639 | |
| 640 | |
| 641 | async def update_app(app_id: str, values_to_update: dict) -> None: |
nothing calls this directly
no test coverage detected