-
Notifications
You must be signed in to change notification settings - Fork 43
Mission: Relational Database Backend
ID | Short Name |
---|---|
|
|
This experience showcases simple database interaction in a Cloud environment. The example application exposes an HTTP API, which provides “CRUD” endpoints to manipulate data through Create, Read, Update, and Delete operations. The API consumes and provides JSON documents which contain information about the request to be processed and the response returned from the system.
User would like to implement a relational (or SQL) database API connection with endpoints exposed over HTTP.
The purpose of this experience is to demonstrate how a developer can quickly implement a CRUD application using the Obsidian platform. The application is using a database to store the managed items. The API has been designed to be simple and intuitive. Additionally, this experience demonstrates how an application can locate and use a relational database.
The experience is built upon an application to manage fruits. The user experience is delivered using a web page proposing the CRUD operations (create / retrieve / update and delete). The user can also use the service endpoint directly.
While this experience does not showcase a fully matured RESTful model (level 3), it uses HTTP verbs and status.
-
The user has accessed to an OpenShift instance, and is logged in (using
oc login …
) -
The user has selected a project in which the application is going to be deployed. This project has been given the following permissions
$ oc policy add-role-to-user admin ${USERNAME} -n $PROJECT_NAME $ oc policy add-role-to-user view -n ${NAME} -z default
-
The user’s project has a PostGreSQL database installed (and running). The user has been given the credential (as OpenShift secrets). As example, creating the database can be done as follows:
oc new-app \ -p POSTGRESQL_USER=luke \ -p POSTGRESQL_PASSWORD=secret \ -p POSTGRESQL_DATABASE=my_data \ -p DATABASE_SERVICE_NAME=my-database \ --name=my-database \ --template=postgresql-ephemeral Deploying secret can be done as follows: oc create -f credentials-secret.yml
-
The user deploys the application using the deployment instructions.
mvn fabric8:deploy -Popenshift
-
The user can access the application using a web page provided by the application
The API manages a set of “fruits”. A “fruit” has at least a name (“apple”) and an id (“1”). It may also contain other attributes. The used database is a PostGreSQL database exposed under the “my-database” service. The database name should be “my_data”.
GET /api/fruits with at least one fruit |
List the fruits. Json Array containing names and ids: [{“name”: “apple”, “id”: 1}]` |
200 - OK with the list |
GET /api/fruits with no fruits |
Empty JSON array: |
200 - OK with the empty list |
POST /api/fruits |
Create a new fruit. The payload is given in JSON. It must include the “name” but not the “id” |
201 - OK with the fruit representation as JSON (name, id…) |
POST /api/fruits - with illegal or empty payload |
Does nothing - return an HTTP error |
If the payload was JSON - 422 (for instance, if the id is set) If the payload was not JSON or empty 415 |
GET /api/fruits/:id |
Returns the JSON for a single fruit: |
200 - OK with a single resource |
PUT /api/fruits/:id with a valid id and payload |
Edit the fruit. The name can be changed, or another attribute. The id cannot be changed |
200 - OK with the updated representation |
PUT /api/fruits/:id with an unknown ID |
Does nothing - return an HTTP error |
404 - Not found |
PUT /api/fruits/:id with a valid id but illegal payload |
Does nothing - return an HTTP error |
If the payload was JSON - 422, for example if the name if missing. If the payload was not JSON or empty 415 |
DELETE /api/fruits/:id with a valid id |
Delete the fruits |
204 - No Content |
DELETE /api/fruits/:id with an invalid id |
Does nothing - return an HTTP error |
404 - Not Found |
All other requests on /api/* are rejected (Bad Request 400, or Not Found 404).
Optional: Response containing error (not 2xx) should also contain a JSON document:
{
“error”: “some description for human”,
“code”: “an optional code for robot”
}
Coordination Owner |
☑ |
|
PM |
☑ |
|
Vert.x |
☑ |
|
WildFly Swarm |
☑ |
|
Spring Boot |
☑ |
|
QE |
☑ |
|
Docs |
☑ |
|
DevExp |
☑ |
|
Architect |
☑ |