From 5978f2bb8b66a6f8492790c954f1b350880a2cb2 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Wed, 13 Nov 2024 13:40:36 +0100 Subject: [PATCH 1/2] [no ci] doc: api.md --- api.md | 238 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 151 insertions(+), 87 deletions(-) diff --git a/api.md b/api.md index 145e450b..7103b5b9 100644 --- a/api.md +++ b/api.md @@ -1,6 +1,10 @@ -#### `GET /api` +# Olas-Operate API reference -Returns information of the operate daemon +## General + +### `GET /api` + +Returns information of the operate daemon.
Response @@ -19,35 +23,39 @@ Returns information of the operate daemon
--- -#### `GET /api/account` -Returns account status +## Account + +### `GET /api/account` + +Returns account status.
- Before setup + Response -```json -{ - "is_setup": false -} -``` +- Before setup: -
+ ```json + { + "is_setup": false + } + ``` -
- After setup +- After setup: + + ```json + { + "is_setup": true + } + ``` -```json -{ - "is_setup": true -} -```
--- -#### `POST /api/account` -Create a local user account +### `POST /api/account` + +Create a local user account.
Request @@ -63,29 +71,29 @@ Create a local user account
Response -```json -{ - "error": null -} -``` -
+- If account did not exist: -If account already exists + ```json + { + "error": null + } + ``` -
- Response +- If account already exists: + + ```json + { + "error": "Account already exists" + } + ``` -```json -{ - "error": "Account already exists" -} -```
--- -#### `PUT /api/account` -Update password +### `PUT /api/account` + +Update account password.
Request @@ -102,30 +110,30 @@ Update password
Response -```json -{ - "error": null -} -``` -
+- If old password is valid: -Old password is not valid + ```json + { + "error": null + } + ``` -
- Response +- If old password is not valid: + + ```json + { + "error": "Old password is not valid", + "traceback": "..." + } + ``` -```json -{ - "error": "Old password is not valid", - "traceback": "..." -} -```
--- -#### `POST /api/account/login` -Login and create a session +### `POST /api/account/login` + +Login and create a session.
Request @@ -141,15 +149,29 @@ Login and create a session
Response -```json -{ - "message": "Login successful" -} -``` +- If password is valid: + + ```json + { + "message": "Login successful" + } + ``` + +- If password is not valid: + + ```json + { + "error": "Password is not valid" + } + ``` +
--- -#### `GET /api/wallet` + +## Wallet + +### `GET /api/wallet` Returns a list of available wallets @@ -169,12 +191,14 @@ Returns a list of available wallets } ] ``` +
--- -#### `POST /api/wallet` -Creates a master key for given chain type. +### `POST /api/wallet` + +Creates a master wallet for given chain type. If a wallet already exists for a given chain type, it returns the already existing wallet without creating an additional one.
Request @@ -199,13 +223,15 @@ Creates a master key for given chain type. "safes": {}, "safe_nonce": null }, - "mnemonic": [...] + "mnemonic": ["polar", "mail", "tattoo", "write", "track", ... ] } ``` +
--- -#### `POST /api/wallet/safe` + +### `POST /api/wallet/safe` Creates a gnosis safe for given chain type. @@ -223,25 +249,40 @@ Creates a gnosis safe for given chain type.
Response -```json -{ - "address": "0xaaFd5cb31A611C5e5aa65ea8c6226EB4328175E3", - "safe_chains": [ - 2 - ], - "ledger_type": 0, - "safes": { - "2": "0xe56fb574ce2C66008d5c4C09980c4f36Ab81ff22" - }, - "safe_nonce": 110558881674480320952254000342160989674913430251157716140571305138121962898821 -} -``` +- If gnosis safe creation is successful: + + ```json + { + "address": "0xaaFd5cb31A611C5e5aa65ea8c6226EB4328175E3", + "safe_chains": [ + 2 + ], + "ledger_type": 0, + "safes": { + "2": "0xe56fb574ce2C66008d5c4C09980c4f36Ab81ff22" + }, + "safe_nonce": 110558881674480320952254000342160989674913430251157716140571305138121962898821 + } + ``` + +- If gnosis safe creation is not successful: + + ```json + { + "error": "Error message", + "traceback": "Traceback message" + } + ``` +
--- -#### `GET /api/services` -Returns the list of services +## Services + +### `GET /api/v2/services` + +Returns the list of existing services (service configurations).
Response @@ -377,7 +418,8 @@ Optionally you can add `deploy` parameter and set it to `true` for a full deploy
--- -#### `PUT /api/services` + +### `PUT /api/v2/services` Update a service @@ -444,7 +486,8 @@ Optionally you can add `deploy` parameter and set it to `true` for a full deploy
--- -#### `GET /api/services/{service}` + +### `GET /api/v2/services/{service}`
Response @@ -495,7 +538,10 @@ Optionally you can add `deploy` parameter and set it to `true` for a full deploy
--- -#### `POST /api/services/{service}/onchain/deploy` + +### `POST /api/services/{service}/onchain/deploy` + +**:warning: Deprecated** Deploy service on-chain @@ -516,7 +562,10 @@ Deploy service on-chain
--- -#### `POST /api/services/{service}/onchain/stop` + +### `POST /api/services/{service}/onchain/stop` + +**:warning: Deprecated** Stop service on-chain @@ -537,7 +586,10 @@ Stop service on-chain --- -#### `GET /api/services/{service}/deployment` + +### `GET /api/services/{service}/deployment` + +**:warning: Deprecated**
Response @@ -559,7 +611,10 @@ Stop service on-chain
--- -#### `POST /api/services/{service}/deployment/build` + +### `POST /api/services/{service}/deployment/build` + +**:warning: Deprecated** Build service locally @@ -580,7 +635,10 @@ Build service locally --- -#### `POST /api/services/{service}/deployment/start` + +### `POST /api/services/{service}/deployment/start` + +**:warning: Deprecated** Start agent @@ -601,7 +659,10 @@ Start agent --- -#### `POST /api/services/{service}/deployment/stop` + +### `POST /api/services/{service}/deployment/stop` + +**:warning: Deprecated** Stop agent @@ -609,7 +670,10 @@ Stop agent ``` --- -#### `POST /api/services/{service}/deployment/delete` + +### `POST /api/services/{service}/deployment/delete` + +**:warning: Deprecated** Delete local deployment From f0b2139a39ddcdaf9488d290062f7fe4208f0e40 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Wed, 13 Nov 2024 17:11:11 +0100 Subject: [PATCH 2/2] doc: update api.md --- api.md | 431 +++++++++++++++++++++++++++---------------------- operate/cli.py | 21 ++- 2 files changed, 256 insertions(+), 196 deletions(-) diff --git a/api.md b/api.md index 7103b5b9..4ed49d22 100644 --- a/api.md +++ b/api.md @@ -233,7 +233,7 @@ Creates a master wallet for given chain type. If a wallet already exists for a g ### `POST /api/wallet/safe` -Creates a gnosis safe for given chain type. +Creates a Gnosis safe for given chain type.
Request @@ -249,7 +249,7 @@ Creates a gnosis safe for given chain type.
Response -- If gnosis safe creation is successful: +- If Gnosis safe creation is successful: ```json { @@ -265,7 +265,7 @@ Creates a gnosis safe for given chain type. } ``` -- If gnosis safe creation is not successful: +- If Gnosis safe creation is not successful: ```json { @@ -282,7 +282,7 @@ Creates a gnosis safe for given chain type. ### `GET /api/v2/services` -Returns the list of existing services (service configurations). +Returns the list of existing service configurations.
Response @@ -290,128 +290,64 @@ Returns the list of existing services (service configurations). ```json [ { - "hash": "bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq", - "keys": [ - { - "ledger": 0, - "address": "0x6Db941e0e82feA3c02Ba83B20e3fB5Ea6ee539cf", - "private_key": "0x34f58dcc11acec007644e49921fd81b9c8a959f651d6d66a42242a1b2dbaf4be" - } - ], - "ledger_config": { - "rpc": "http://localhost:8545", - "type": 0, - "chain": 2 - }, - "chain_data": { - "instances": [ - "0x6Db941e0e82feA3c02Ba83B20e3fB5Ea6ee539cf" - ], - "token": 380, - "multisig": "0x7F3e460Cf596E783ca490791643C0055Fa2034AC", - "staked": false, - "on_chain_state": 6, - "user_params": { - "nft": "bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq", - "agent_id": 14, - "threshold": 1, - "use_staking": false, - "cost_of_bond": 10000000000000000, - "olas_cost_of_bond": 10000000000000000000, - "olas_required_to_stake": 10000000000000000000, - "fund_requirements": { - "agent": 0.1, - "safe": 0.5 - } - } - }, - "path": "/Users/virajpatel/valory/olas-operate-app/.operate/services/bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq", - "service_path": "/Users/virajpatel/valory/olas-operate-app/.operate/services/bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq/trader_omen_gnosis", - "name": "valory/trader_omen_gnosis" - } + "chain_configs": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", + "hash_history": {"1731487112": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u"}, + "home_chain_id": "100", + "keys": [...], + "name": "valory/trader_omen_gnosis", + "service_config_id": "sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39", + "service_path": "/home/user/.operate/services/sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39/trader_omen_gnosis", + "version": 4 + }, + ... ] ```
--- -#### `POST /api/services` -Create a service using the service template +#### `POST /api/v2/services` + +Create a service configuration using a template.
Request ```json -{ - "name": "Trader Agent", - "description": "Trader agent for omen prediction markets", - "hash": "bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq", - "image": "https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75", - "configuration": { - "nft": "bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq", - "rpc": "http://localhost:8545", - "agent_id": 14, - "threshold": 1, - "use_staking": false, - "cost_of_bond": 10000000000000000, - "olas_cost_of_bond": 10000000000000000000, - "olas_required_to_stake": 10000000000000000000, - "fund_requirements": { - "agent": 0.1, - "safe": 0.5 - } + { + "configurations": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", + "image": "https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75", + "home_chain_id": "100", + "name": "valory/trader_omen_gnosis", + "service_version": "v0.18.4" } -} ```
-Optionally you can add `deploy` parameter and set it to `true` for a full deployment in a single request. -
Response ```json { - "hash": "bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq", - "keys": [ - { - "ledger": 0, - "address": "0x10EB940024913dfCAE95D21E04Ba662cdfB79fF0", - "private_key": "0x00000000000000000000000000000000000000000000000000000000000000000" - } - ], - "ledger_config": { - "rpc": "http: //localhost:8545", - "type": 0, - "chain": 2 - }, - "chain_data": { - "instances": [ - "0x10EB940024913dfCAE95D21E04Ba662cdfB79fF0" - ], - "token": 382, - "multisig": "0xf21d8A424e83BBa2588306D1C574FE695AD410b5", - "staked": false, - "on_chain_state": 4, - "user_params": { - "nft": "bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq", - "agent_id": 14, - "threshold": 1, - "use_staking": false, - "cost_of_bond": 10000000000000000, - "olas_cost_of_bond": 10000000000000000000, - "olas_required_to_stake": 10000000000000000000, - "fund_requirements": { - "agent": 0.1, - "safe": 0.5 - } - } - }, - "path": "~/.operate/services/bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq", - "service_path": "~/.operate/services/bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq/trader_omen_gnosis", - "name": "valory/trader_omen_gnosis" + "chain_configs": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", + "hash_history": {"1731487112": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u"}, + "home_chain_id": "100", + "keys": [...], + "name": "valory/trader_omen_gnosis", + "service_config_id": "sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39", + "service_path": "/home/user/.operate/services/sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39/trader_omen_gnosis", + "version": 4 } ``` @@ -421,124 +357,239 @@ Optionally you can add `deploy` parameter and set it to `true` for a full deploy ### `PUT /api/v2/services` -Update a service +Update all the service configurations whose Service Public ID match the Service Public ID in the provided hash.
Request ```json -{ - "old_service_hash": "bafybeiha6dxygx2ntgjxhs6zzymgqk3s5biy3ozeqw6zuhr6yxgjlebfmq", - "new_service_hash": "bafybeicxdpkuk5z5zfbkso7v5pywf4v7chxvluyht7dtgalg6dnhl7ejoe", -} + { + "configurations": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeibpseosblmaw6sk6zsnic2kfxfsijrnfluuhkwboyqhx7ma7zw2me", + "image": "https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75", + "home_chain_id": "100", + "name": "valory/trader_omen_gnosis", + "service_version": "v0.19.0" + } ```
-Optionally you can add `deploy` parameter and set it to `true` for a full deployment in a single request. -
Response +The response contains an array of the services which have been updated (an empty array if no service matches the Service Public ID in the provided hash). + ```json -{ - "hash": "bafybeicxdpkuk5z5zfbkso7v5pywf4v7chxvluyht7dtgalg6dnhl7ejoe", - "keys": [ - { - "ledger": 0, - "address": "0x10EB940024913dfCAE95D21E04Ba662cdfB79fF0", - "private_key": "0x00000000000000000000000000000000000000000000000000000000000000000" - } - ], - "ledger_config": { - "rpc": "http: //localhost:8545", - "type": 0, - "chain": 2 - }, - "chain_data": { - "instances": [ - "0x10EB940024913dfCAE95D21E04Ba662cdfB79fF0" - ], - "token": 382, - "multisig": "0xf21d8A424e83BBa2588306D1C574FE695AD410b5", - "staked": false, - "on_chain_state": 4, - "user_params": { - "nft": "bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq", - "agent_id": 14, - "threshold": 1, - "use_staking": false, - "cost_of_bond": 10000000000000000, - "olas_cost_of_bond": 10000000000000000000, - "olas_required_to_stake": 10000000000000000000, - "fund_requirements": { - "agent": 0.1, - "safe": 0.5 - } - } +[ + { + "chain_configs": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", + "hash_history": {"1731487112": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", "1731490000": "bafybeibpseosblmaw6sk6zsnic2kfxfsijrnfluuhkwboyqhx7ma7zw2me"}, + "home_chain_id": "100", + "keys": [...], + "name": "valory/trader_omen_gnosis", + "service_config_id": "sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39", + "service_path": "/home/user/.operate/services/sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39/trader_omen_gnosis", + "version": 4 }, - "path": "~/.operate/services/bafybeicxdpkuk5z5zfbkso7v5pywf4v7chxvluyht7dtgalg6dnhl7ejoe", - "service_path": "~/.operate/services/bafybeicxdpkuk5z5zfbkso7v5pywf4v7chxvluyht7dtgalg6dnhl7ejoe/trader_omen_gnosis", - "name": "valory/trader_omen_gnosis" -} + ... +] ```
--- -### `GET /api/v2/services/{service}` +#### `POST /api/v2/services/stop` (alias `GET /stop_all_services`) + +Stop all running deployments. + +
+ Response + +- If the operation was successful: + + ```json + { + "message": "Services stopped." + } + ``` + +- If the operation was not successful: + + ```json + { + "error": "Error message", + "traceback": "Traceback message" + } + ``` + +
+ +--- + +## Service + +### `GET /api/v2/service/{service_config_id}` + +Returns the service configuration `service_config_id`. + +
+ Response + +- If service configuration `service_config_id` exists: + + ```json + { + "chain_configs": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", + "hash_history": {"1731487112": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u"}, + "home_chain_id": "100", + "keys": [...], + "name": "valory/trader_omen_gnosis", + "service_config_id": "sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39", + "service_path": "/home/user/.operate/services/sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39/trader_omen_gnosis", + "version": 4 + } + + ``` + +- If service configuration `service_config_id` does not exist: + + ```json + { + "error": "Service foo not found" + } + ``` + +
+ +--- + +### `POST /api/v2/service/{service_config_id}` + +Deploy service with service configuration `service_config_id` on-chain and run local deployment. This endpoint executes the following tasks: + +1. Stops any running service. +2. Ensures that the service is deployed on-chain on all the configured chains. +3. Ensures that the the service is staked on all the configured chains. +4. Runs the service locally. +5. Starts funding job. +6. Starts healthcheck job. + +
Response +The response contains the updated service configuration following the on-chain operations, including service Gnosis safe, on-chain token, etc. + ```json { - "hash": "{service}", - "keys": [ - { - "ledger": 0, - "address": "0x10EB940024913dfCAE95D21E04Ba662cdfB79fF0", - "private_key": "0x00000000000000000000000000000000000000000000000000000000000000000" - } - ], - "ledger_config": { - "rpc": "http: //localhost:8545", - "type": 0, - "chain": 2 - }, - "chain_data": { - "instances": [ - "0x10EB940024913dfCAE95D21E04Ba662cdfB79fF0" - ], - "token": 382, - "multisig": "0xf21d8A424e83BBa2588306D1C574FE695AD410b5", - "staked": false, - "on_chain_state": 4, - "user_params": { - "nft": "bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq", - "agent_id": 14, - "threshold": 1, - "use_staking": false, - "cost_of_bond": 10000000000000000, - "olas_cost_of_bond": 10000000000000000000, - "olas_required_to_stake": 10000000000000000000, - "fund_requirements": { - "agent": 0.1, - "safe": 0.5 - } - } - }, - "path": "~/.operate/services/{service}", - "service_path": "~/.operate/services/{service}/trader_omen_gnosis", - "name": "valory/trader_omen_gnosis" + "chain_configs": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", + "hash_history": {"1731487112": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u"}, + "home_chain_id": "100", + "keys": [...], + "name": "valory/trader_omen_gnosis", + "service_config_id": "sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39", + "service_path": "/home/user/.operate/services/sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39/trader_omen_gnosis" } + +``` + +
+ +--- + +### `PUT /api/v2/service/{service_config_id}` + +Update service configuration `service_config_id` with the provided template. + +
+ Request + +```json + { + "configurations": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeibpseosblmaw6sk6zsnic2kfxfsijrnfluuhkwboyqhx7ma7zw2me", + "image": "https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75", + "home_chain_id": "100", + "name": "valory/trader_omen_gnosis", + "service_version": "v0.19.0" + } +``` + +
+ +
+ Response + +- If the update is successful, the response contains the updated service configuration: + + ```json + { + "chain_configs": {...}, + "description": "Trader agent for omen prediction markets", + "env_variables": {...}, + "hash": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", + "hash_history": {"1731487112": "bafybeidicxsruh3r4a2xarawzan6ocwyvpn3ofv42po5kxf7x6ck7kn22u", "1731490000": "bafybeibpseosblmaw6sk6zsnic2kfxfsijrnfluuhkwboyqhx7ma7zw2me"}, + "home_chain_id": "100", + "keys": [...], + "name": "valory/trader_omen_gnosis", + "service_config_id": "sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39", + "service_path": "/home/user/.operate/services/sc-85a7a12a-8c6b-46b8-919a-b8a3b8e3ad39/trader_omen_gnosis" + } + + ``` + +- If the update is not successful: + + ```json + { + "error": "Error message", + "traceback": "Traceback message" + } + ``` + +
+ +--- + +### `POST /api/service/{service_config_id}/stop` + +Stop service with service configuration `service_configuration_id`. + +
+ Response + +```json + { + "nodes": { + "agent": [], + "tendermint": [] + }, + "status": 1 + } ```
--- +## Unused endpoints + ### `POST /api/services/{service}/onchain/deploy` **:warning: Deprecated** @@ -711,5 +762,3 @@ Delete local deployment
--> - - diff --git a/operate/cli.py b/operate/cli.py index ad558430..eee71f2b 100644 --- a/operate/cli.py +++ b/operate/cli.py @@ -303,12 +303,23 @@ async def _kill_server(request: Request) -> JSONResponse: """Kill backend server from inside.""" os.kill(os.getpid(), signal.SIGINT) + @app.post("/api/v2/services/stop") @app.get("/stop_all_services") async def _stop_all_services(request: Request) -> JSONResponse: """Kill backend server from inside.""" - logger.info("Stopping services on demand...") - pause_all_services() - logger.info("Stopping services on demand done.") + + # No authentication required to stop services. + + try: + logger.info("Stopping services on demand...") + pause_all_services() + logger.info("Stopping services on demand done.") + return JSONResponse(content={"message": "Services stopped."}) + except Exception as e: # pylint: disable=broad-except + return JSONResponse( + content={"error": str(e), "traceback": traceback.format_exc()}, + status_code=500, + ) @app.get("/api") @with_retries @@ -732,8 +743,8 @@ async def _update_all_services(request: Request) -> JSONResponse: @with_retries async def _stop_service_locally(request: Request) -> JSONResponse: """Stop a service deployment.""" - if operate.password is None: - return USER_NOT_LOGGED_IN_ERROR + + # No authentication required to stop services. service_config_id = request.path_params["service_config_id"] manager = operate.service_manager()