Initial QSfera import
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
## КуСфера Wrapper
|
||||
|
||||
A tool that wraps the КуСфера binary and provides a way to re-configure the running КуСфера instance.
|
||||
|
||||
When run, **ocwrapper** starts an API server that exposes some endpoints to re-configure the КуСфера server.
|
||||
|
||||
### Usage
|
||||
|
||||
1. Build
|
||||
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
2. Run
|
||||
|
||||
```bash
|
||||
./bin/ocwrapper serve --bin=<path-to-qsfera-binary>
|
||||
```
|
||||
|
||||
To check other available options:
|
||||
|
||||
```bash
|
||||
./bin/ocwrapper serve --help
|
||||
```
|
||||
|
||||
```bash
|
||||
--url string КуСфера server url (default "https://localhost:9200")
|
||||
--retry string Number of retries to start КуСфера server (default "5")
|
||||
-p, --port string Wrapper API server port (default "5200")
|
||||
--admin-username string admin username for КуСфера server
|
||||
--admin-password string admin password for КуСфера server
|
||||
```
|
||||
|
||||
Access the API server at `http://localhost:5200`.
|
||||
|
||||
Also, see `./bin/ocwrapper help` for more information.
|
||||
|
||||
### API
|
||||
|
||||
**ocwrapper** exposes two endpoints:
|
||||
|
||||
1. `PUT /config`
|
||||
|
||||
Updates the configuration of the running КуСфера instance.
|
||||
Body of the request should be a JSON object with the following structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"ENV_KEY1": "value1",
|
||||
"ENV_KEY2": "value2"
|
||||
}
|
||||
```
|
||||
|
||||
Returns:
|
||||
|
||||
- `200 OK` - КуСфера is successfully reconfigured
|
||||
- `400 Bad Request` - request body is not a valid JSON object
|
||||
- `500 Internal Server Error` - КуСфера server is not running
|
||||
|
||||
2. `DELETE /rollback`
|
||||
|
||||
Rolls back the configuration to the starting point.
|
||||
|
||||
Returns:
|
||||
|
||||
- `200 OK` - rollback is successful
|
||||
- `500 Internal Server Error` - КуСфера server is not running
|
||||
|
||||
3. `POST /command`
|
||||
|
||||
Executes the provided command on the КуСфера server. The body of the request should be a JSON object with the following structure:
|
||||
|
||||
```yml
|
||||
{
|
||||
"command": "<qsfera-command>", # without the КуСфера binary. e.g. "list"
|
||||
}
|
||||
```
|
||||
|
||||
If the command requires user input, the body of the request should be a JSON object with the following structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "<qsfera-command>",
|
||||
"inputs": ["value1"]
|
||||
}
|
||||
```
|
||||
|
||||
Returns:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "OK",
|
||||
"exitCode": 0,
|
||||
"message": "<command output>"
|
||||
}
|
||||
OR
|
||||
{
|
||||
"status": "ERROR",
|
||||
"exitCode": <error-exit-code>,
|
||||
"message": "<command output>"
|
||||
}
|
||||
```
|
||||
|
||||
- `200 OK` - command is successfully executed
|
||||
- `400 Bad Request` - request body is not a valid JSON object
|
||||
- `500 Internal Server Error`
|
||||
|
||||
4. `POST /start`
|
||||
|
||||
Starts the КуСфера server.
|
||||
|
||||
Returns:
|
||||
|
||||
- `200 OK` - КуСфера server is started
|
||||
- `409 Conflict` - КуСфера server is already running
|
||||
- `500 Internal Server Error` - Unable to start КуСфера server
|
||||
|
||||
5. `POST /stop`
|
||||
|
||||
Stops the КуСфера server.
|
||||
|
||||
Returns:
|
||||
|
||||
- `200 OK` - КуСфера server is stopped
|
||||
- `500 Internal Server Error` - Unable to stop КуСфера server
|
||||
Reference in New Issue
Block a user