-
Notifications
You must be signed in to change notification settings - Fork 2
setup_server_api
Here you will find the documentation of the setup_server microservice of the EatUp project.
All the logic to handle the status of the project. Implemented as a finite state machine.
GET /api/v1/status
Get the status of the project.
Examples
fetch("/api/v1/api/v1/status", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
"not_created"fetch("/api/v1/api/v1/status", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
"created"fetch("/api/v1/api/v1/status", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
"installed" POST /api/v1/create
Creates the project. It can only be called if the project is not created.
Examples
fetch("/api/v1/api/v1/create", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
fetch("/api/v1/api/v1/create", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Project already created POST /api/v1/install
Installs the project. Creates the database. It can only be called if the project is created.
Examples
fetch("/api/v1/api/v1/install", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(
{
"db_usr": "XXXXXX",
"db_usr_passwd": "YYYYYY",
"server_port": ZZZZZZ
}
)
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
fetch("/api/v1/api/v1/install", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Project not createdfetch("/api/v1/api/v1/install", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Project already installed POST /api/v1/uninstall
Uninstalls the project. Can be called at any time.
Logic to handle the microservices of the project.
GET /api/v1/microservices
Get the state of all microservices.
Examples
fetch("/api/v1/microservices/api/v1/microservices", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
[
{
"id": null,
"name": "YYYYYY",
"state": "ZZZZZZ"
"ip": null,
"port": null
},
...
]fetch("/api/v1/microservices/api/v1/microservices", {
method: "GET",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
[
{
"id": "XXXXXX",
"name": "YYYYYY",
"state": "ZZZZZZ"
"ip": "AAAAAA",
"port": BBBBBB
},
...
] POST /api/v1/microservices/start/:microservice_name
Starts a microservice.
| Name | Example | Description |
|---|---|---|
microservice_name |
.../eatup_db/... |
The name of the microservice to start. |
Examples
fetch("/api/v1/microservices/api/v1/microservices/start/eatup_db", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Invalid action start for eatup_dbfetch("/api/v1/microservices/api/v1/microservices/start/eatup_db", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
fetch("/api/v1/microservices/api/v1/microservices/start/eatup_db", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Invalid action start for eatup_dbfetch("/api/v1/microservices/api/v1/microservices/start/eatup_server", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Invalid action start for eatup_serverfetch("/api/v1/microservices/api/v1/microservices/start/invalid_microservice", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
This container does not exist or belong to this project. POST /api/v1/microservices/stop/:microservice_name
Stops a microservice.
| Name | Example | Description |
|---|---|---|
microservice_name |
.../eatup_db/... |
The name of the microservice to stop. |
Examples
fetch("/api/v1/microservices/api/v1/microservices/stop/eatup_db", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Invalid action stop for eatup_dbfetch("/api/v1/microservices/api/v1/microservices/stop/eatup_db", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
200
fetch("/api/v1/microservices/api/v1/microservices/stop/eatup_server", {
method: "POST",
})
.then(response => response.json()) // If valid
//.then(response => response.text()) // If invalid
.then(json => console.log(json));
.catch(error => console.error(error));Response:
409
Invalid action stop for eatup_serverThis section contains the documentation for the special requests
GET /
Ping request to check if the server is up
OPTIONS /*
CORS preflight request.
This are the meanings of the symbols used in this document
| Element | Meaning |
|---|---|
XXXXXX |
Some value that would be replaced for something else in the real situation. |
... |
More parameters can be added to the request |
| Code | Meaning | Description |
|---|---|---|
200 |
200 OK | The request was successful. |
204 |
204 No Content | The request was successful, but there is no content to return. Used for CORS preflight requests. |
404 |
404 Not Found | The resource does not exist. |
409 |
409 Conflict | Something is not right with the request. |
500 |
500 Internal Server Error | Something went wrong on the server. Please contact with the administrator. |
501 |
501 Not Implemented | The endpoint is not implemented yet. |
This are the available states of a microservice
| Element | Meaning |
|---|---|
Created |
The microservice has been created, but not started. |
Running |
The microservice is running. |
Restarting |
The microservice is restarting. |
Exited |
The microservice has exited. |
Paused |
The microservice is paused. |
Dead |
The microservice is dead. |
NotFound |
The microservice container does not exist. |
Made with ❤️ using api_docs_generator v0.7.0.