Add batch
This commit is contained in:
12
main.py
12
main.py
@@ -1,8 +1,9 @@
|
||||
import os
|
||||
import io
|
||||
import json
|
||||
from typing import *
|
||||
from urllib.request import Request
|
||||
from fastapi import FastAPI, File, UploadFile
|
||||
import pip
|
||||
from pydantic import BaseModel
|
||||
from starlette.responses import FileResponse, JSONResponse
|
||||
from fastapi import FastAPI, Response, status
|
||||
@@ -95,6 +96,15 @@ async def fastapi_get_current_operaiton_id(network: str) -> int:
|
||||
def fastapi_sync_with_server(network: str, operationid: int) -> ChangeSet:
|
||||
return sync_with_server(network, operationid)
|
||||
|
||||
@app.post("/batch/")
|
||||
def fastapi_execute_batch_commands(network: str, request: Request) -> ChangeSet:
|
||||
jsTxt = request.json()
|
||||
joOps = json.loads(jsTxt)['operations']
|
||||
cs:ChangeSet = ChangeSet({})
|
||||
for js in joOps:
|
||||
cs.add(js)
|
||||
return api.execute_batch_commands(network, cs)
|
||||
|
||||
# node
|
||||
@app.get("/getnodes/")
|
||||
async def fastapi_get_nodes(network: str) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user