-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added new requirements and endpoints
- Loading branch information
Showing
26 changed files
with
1,129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vscode | ||
__pycache__ | ||
.python-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# TDP Server | ||
|
||
`tdp-server` provides a server to interact with [`tdp-lib`](https://github.com/tOSIT-IO/tdp-lib). | ||
|
||
## Requirements | ||
|
||
The server is made with Python. The following is required: | ||
|
||
- [Python](https://www.python.org/) `3.9.5` | ||
- [Poetry](https://python-poetry.org/) `1.7.1` | ||
- [tdp-lib](https://github.com/tOSIT-IO/tdp-lib) and its dependencies as the server imports classes from it. | ||
|
||
## Installation | ||
|
||
Install the `tdp-server` dependencies in the pyproject.toml as follows: | ||
|
||
```bash | ||
poetry install | ||
``` | ||
|
||
## Usage | ||
|
||
Start the server as follows: | ||
|
||
```bash | ||
uvicorn tdp_server.main:app --reload | ||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[tool.poetry] | ||
name = "tdp-server" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["SteBaum <stephan.baum@edu.dsti.institute>"] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.9" | ||
uvicorn = "^0.24.0.post1" | ||
fastapi = "^0.104.1" | ||
pydantic = "^2.5.1" | ||
sqlalchemy = "^2.0.23" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from fastapi import APIRouter | ||
from tdp_server.api.v1.endpoints import ( | ||
components, | ||
services, | ||
deployments, | ||
operations, | ||
planification, | ||
status, | ||
variables, | ||
) | ||
|
||
|
||
api_router = APIRouter() | ||
|
||
api_router.include_router(services.router, prefix="/services", tags=["services"]) | ||
api_router.include_router( | ||
components.router, prefix="/services/{service_id}/components", tags=["components"] | ||
) | ||
api_router.include_router( | ||
deployments.router, prefix="/deployments", tags=["deployments"] | ||
) | ||
api_router.include_router(variables.router, prefix="/variables", tags=["variables"]) | ||
api_router.include_router(operations.router, prefix="/operations", tags=["operations"]) | ||
api_router.include_router(status.router, prefix="/status", tags=["status"]) | ||
api_router.include_router( | ||
planification.router, prefix="/planification", tags=["planification"] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
COMMON_RESPONSES = { | ||
401: { | ||
"description": "Unauthenticated", | ||
"content": { | ||
"application/json": { | ||
"example": {"detail": "Error during authentication validation (reason)"} | ||
} | ||
}, | ||
}, | ||
403: { | ||
"description": "Not enough privileges", | ||
"headers": { | ||
"WWW-Authenticate": { | ||
"schema": {"type": "string"}, | ||
"description": "Authentication method to use", | ||
} | ||
}, | ||
"content": { | ||
"application/json": {"example": {"detail": "Not enough permissions"}} | ||
}, | ||
}, | ||
} | ||
|
||
SERVICE_ID_DOES_NOT_EXIST_ERROR = { | ||
400: { | ||
"description": "Service id does not exist", | ||
"content": { | ||
"application/json": {"example": {"detail": "{service_id} does not exist"}} | ||
}, | ||
} | ||
} | ||
|
||
COMPONENT_ID_DOES_NOT_EXIST_ERROR = { | ||
400: { | ||
"description": "Component id does not exist", | ||
"content": { | ||
"application/json": {"example": {"detail": "{component_id} does not exist"}} | ||
}, | ||
} | ||
} | ||
|
||
COMMON_DEPLOYMENT_ARGS = { | ||
409: { | ||
"description": "Another deployment is still running, only one deployment at a time is allowed", | ||
"content": { | ||
"application/json": { | ||
"example": {"detail": "another deployment is still running"} | ||
} | ||
}, | ||
} | ||
} | ||
|
||
IMPORT_FILE_DOES_NOT_EXIST = { | ||
400: { | ||
"description": "File does not exist", | ||
"content": {"application/json": {"example": {"detail": "File does not exist"}}}, | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from fastapi import APIRouter | ||
|
||
from tdp_server.api.v1 import dependencies | ||
from tdp_server.schemas.components import Component, ComponentUpdateResponse | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get( | ||
"/{component_id}", | ||
response_model=Component, | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.COMPONENT_ID_DOES_NOT_EXIST_ERROR, | ||
}, | ||
) | ||
def get_component(): | ||
pass | ||
|
||
|
||
@router.put( | ||
"/{component_id}", | ||
response_model=ComponentUpdateResponse, | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.COMPONENT_ID_DOES_NOT_EXIST_ERROR, | ||
}, | ||
) | ||
def put_component(): | ||
pass | ||
|
||
|
||
@router.patch( | ||
"/{component_id}", | ||
response_model=ComponentUpdateResponse, | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.COMPONENT_ID_DOES_NOT_EXIST_ERROR, | ||
}, | ||
) | ||
def patch_component(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from fastapi import APIRouter | ||
from typing import List | ||
|
||
from tdp_server.api.v1 import dependencies | ||
from tdp_server.schemas.deployments import ( | ||
DeploymentLog, | ||
DeploymentLogWithOperations, | ||
DeployStatus, | ||
) | ||
from tdp_server.schemas.operations import OperationLog | ||
|
||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get( | ||
"/", | ||
response_model=List[DeploymentLog], | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def get_deployments(): | ||
pass | ||
|
||
|
||
@router.get( | ||
"/{deployement_id}", | ||
response_model=DeploymentLogWithOperations, | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def get_deployment(): | ||
pass | ||
|
||
|
||
@router.get( | ||
"/{deployement_id}/operation/{operation}", | ||
response_model=OperationLog, | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def get_deployment_operation(): | ||
pass | ||
|
||
|
||
@router.get( | ||
"/status", | ||
response_model=DeployStatus, | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def get_deployment_status(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/dag", | ||
response_model=DeploymentLog, | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.COMMON_DEPLOYMENT_ARGS, | ||
}, | ||
) | ||
def post_dag(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/operations", | ||
response_model=DeploymentLog, | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.COMMON_DEPLOYMENT_ARGS, | ||
}, | ||
) | ||
def post_operations(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/resumption", | ||
response_model=DeploymentLog, | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.COMMON_DEPLOYMENT_ARGS, | ||
}, | ||
) | ||
def post_resumumption(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/reconfiguration", | ||
response_model=DeploymentLog, | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.COMMON_DEPLOYMENT_ARGS, | ||
}, | ||
) | ||
def post_reconfiguration(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from fastapi import APIRouter | ||
|
||
from tdp_server.api.v1 import dependencies | ||
from tdp_server.schemas.operations import Operation | ||
|
||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get( | ||
"/", | ||
response_model=Operation, | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def get_operations(): | ||
pass | ||
|
||
|
||
@router.get( | ||
"/dag", | ||
response_model=Operation, | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def get_dag_operations(): | ||
pass | ||
|
||
|
||
@router.get( | ||
"/other", | ||
response_model=Operation, | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def get_other_operations(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from fastapi import APIRouter | ||
from typing import List | ||
|
||
from tdp_server.api.v1 import dependencies | ||
from tdp_server.schemas.operations import Operation | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.post( | ||
"/dag", | ||
response_model=List[Operation], | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def post_plan_dag(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/operations", | ||
response_model=List[Operation], | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def post_plan_operations(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/resumption", | ||
response_model=List[Operation], | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def post_plan_resumption(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/reconfiguration", | ||
response_model=List[Operation], | ||
responses={**dependencies.COMMON_RESPONSES}, | ||
) | ||
def post_plan_reconfiguration(): | ||
pass | ||
|
||
|
||
@router.post( | ||
"/importation", | ||
response_model=List[Operation], | ||
responses={ | ||
**dependencies.COMMON_RESPONSES, | ||
**dependencies.IMPORT_FILE_DOES_NOT_EXIST, | ||
}, | ||
) | ||
def post_importation(): | ||
pass |
Oops, something went wrong.