Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed Mar 27, 2024
1 parent d5dce30 commit 78037a2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
22 changes: 22 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,28 @@ Stop service on-chain

</details>

---
#### `GET /api/services/{service}/deployment`

<details>
<summary>Response</summary>

```json
{
"status": 1,
"nodes": {
"agent": [
"traderomengnosis_abci_0"
],
"tendermint": [
"traderomengnosis_tm_0"
]
}
}
```

</details>

---
#### `POST /api/services/{service}/deployment/build`

Expand Down
34 changes: 22 additions & 12 deletions operate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def create_app( # pylint: disable=too-many-locals, unused-argument, too-many-st
def with_retries(f: t.Callable) -> t.Callable:
"""Retries decorator."""

async def _call(request: Request) -> t.Dict:
async def _call(request: Request) -> JSONResponse:
"""Call the endpoint."""
logger.info(f"Calling `{f.__name__}` with retries enabled")
retries = 0
Expand All @@ -155,7 +155,7 @@ async def _call(request: Request) -> t.Dict:

@app.get("/api")
@with_retries
async def _get_api(request: Request) -> t.Dict:
async def _get_api(request: Request) -> JSONResponse:
"""Get API info."""
return JSONResponse(content=operate.json)

Expand Down Expand Up @@ -299,13 +299,13 @@ async def _create_safe(request: Request) -> t.List[t.Dict]:

@app.get("/api/services")
@with_retries
async def _get_services(request: Request) -> t.List[t.Dict]:
async def _get_services(request: Request) -> JSONResponse:
"""Get available services."""
return JSONResponse(content=operate.service_manager().json)

@app.post("/api/services")
@with_retries
async def _create_services(request: Request) -> t.Dict:
async def _create_services(request: Request) -> JSONResponse:
"""Create a service."""
if operate.password is None:
return USER_NOT_LOGGED_IN_ERROR
Expand All @@ -328,7 +328,7 @@ async def _create_services(request: Request) -> t.Dict:

@app.put("/api/services")
@with_retries
async def _update_services(request: Request) -> t.Dict:
async def _update_services(request: Request) -> JSONResponse:
"""Create a service."""
if operate.password is None:
return USER_NOT_LOGGED_IN_ERROR
Expand All @@ -346,7 +346,7 @@ async def _update_services(request: Request) -> t.Dict:

@app.get("/api/services/{service}")
@with_retries
async def _get_service(request: Request) -> t.Dict:
async def _get_service(request: Request) -> JSONResponse:
"""Create a service."""
return JSONResponse(
content=(
Expand All @@ -360,7 +360,7 @@ async def _get_service(request: Request) -> t.Dict:

@app.post("/api/services/{service}/onchain/deploy")
@with_retries
async def _deploy_service_onchain(request: Request) -> t.Dict:
async def _deploy_service_onchain(request: Request) -> JSONResponse:
"""Create a service."""
if operate.password is None:
return USER_NOT_LOGGED_IN_ERROR
Expand All @@ -380,7 +380,7 @@ async def _deploy_service_onchain(request: Request) -> t.Dict:

@app.post("/api/services/{service}/onchain/stop")
@with_retries
async def _stop_service_onchain(request: Request) -> t.Dict:
async def _stop_service_onchain(request: Request) -> JSONResponse:
"""Create a service."""
if operate.password is None:
return USER_NOT_LOGGED_IN_ERROR
Expand All @@ -401,9 +401,19 @@ async def _stop_service_onchain(request: Request) -> t.Dict:
)
)

@app.get("/api/services/{service}/deployment")
@with_retries
async def _get_service_deployment(request: Request) -> JSONResponse:
"""Create a service."""
return JSONResponse(
content=operate.service_manager.create_or_load(
request.path_params["service"],
).deployment.json
)

@app.post("/api/services/{service}/deployment/build")
@with_retries
async def _build_service_locally(request: Request) -> t.Dict:
async def _build_service_locally(request: Request) -> JSONResponse:
"""Create a service."""
deployment = (
operate.service_manager()
Expand All @@ -417,7 +427,7 @@ async def _build_service_locally(request: Request) -> t.Dict:

@app.post("/api/services/{service}/deployment/start")
@with_retries
async def _start_service_locally(request: Request) -> t.Dict:
async def _start_service_locally(request: Request) -> JSONResponse:
"""Create a service."""
deployment = (
operate.service_manager()
Expand All @@ -432,7 +442,7 @@ async def _start_service_locally(request: Request) -> t.Dict:

@app.post("/api/services/{service}/deployment/stop")
@with_retries
async def _stop_service_locally(request: Request) -> t.Dict:
async def _stop_service_locally(request: Request) -> JSONResponse:
"""Create a service."""
deployment = (
operate.service_manager()
Expand All @@ -446,7 +456,7 @@ async def _stop_service_locally(request: Request) -> t.Dict:

@app.post("/api/services/{service}/deployment/delete")
@with_retries
async def _delete_service_locally(request: Request) -> t.Dict:
async def _delete_service_locally(request: Request) -> JSONResponse:
"""Create a service."""
deployment = (
operate.service_manager()
Expand Down

0 comments on commit 78037a2

Please sign in to comment.