forked from dstackai/dstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (44 loc) · 1.63 KB
/
main.py
File metadata and controls
56 lines (44 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import logging
from fastapi import FastAPI
from app.utils import configure_logging
from dstack.plugins.builtin.rest_plugin import (
FleetSpecRequest,
FleetSpecResponse,
GatewaySpecRequest,
GatewaySpecResponse,
RunSpecRequest,
RunSpecResponse,
VolumeSpecRequest,
VolumeSpecResponse,
)
configure_logging()
logger = logging.getLogger(__name__)
app = FastAPI()
@app.post("/apply_policies/on_run_apply")
async def on_run_apply(request: RunSpecRequest) -> RunSpecResponse:
logger.info(
f"Received run spec request from user {request.user} and project {request.project}"
)
response = RunSpecResponse(spec=request.spec, error=None)
return response
@app.post("/apply_policies/on_fleet_apply")
async def on_fleet_apply(request: FleetSpecRequest) -> FleetSpecResponse:
logger.info(
f"Received fleet spec request from user {request.user} and project {request.project}"
)
response = FleetSpecResponse(request.spec, error=None)
return response
@app.post("/apply_policies/on_volume_apply")
async def on_volume_apply(request: VolumeSpecRequest) -> VolumeSpecResponse:
logger.info(
f"Received volume spec request from user {request.user} and project {request.project}"
)
response = VolumeSpecResponse(request.spec, error=None)
return response
@app.post("/apply_policies/on_gateway_apply")
async def on_gateway_apply(request: GatewaySpecRequest) -> GatewaySpecResponse:
logger.info(
f"Received gateway spec request from user {request.user} and project {request.project}"
)
response = GatewaySpecResponse(request.spec, error=None)
return response