This demonstration shows how to wrap Senzing with Spring-boot to create an HTTP API.
The resulting HTTP API is documented in OpenAPI.json and can be viewed in the Swagger editor.
These instructions will install and run the web service.
- Debian-based installation - For Ubuntu and others
- RPM-based installation - For Red Hat, CentOS, openSuse and others.
The following tests assume that the service is running. To start and run the service, see either Debian-based "Run Service" or RPM-based "Run Service".
Normally the service runs on port 8080. To verify this, the end of the service log sent to standard out (STDOUT) will have the port information.
YYYY-MM-DD HH:MM:SS.sss INFO 8032 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
YYYY-MM-DD HH:MM:SS.sss INFO 8032 --- [ main] c.s.senzingdemo.SenzingDemoApplication : Started SenzingDemoApplication in 11.077 seconds (JVM running for 12.172)To test the service, open a web-browser (e.g. FireFox, Chrome, Safari, MS Explorer, Opera) to
http://localhost:8080/stats, replacing localhost if needed.
-
Set environment variables.
export GIT_ACCOUNT_DIR=~/docktermj.git export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/hello-senzing-springboot-java" export SENZING_DEMO_DATASOURCE="TEST" export SENZING_DEMO_URL="http://localhost:8080" export SENZING_DIR=/opt/senzing
-
Get the Senzing workload statistics.
curl -X GET \ ${SENZING_DEMO_URL}/stats
-
If you would like the JSON HTTP response formatted, you can pipe the output to
jq. Example:curl -X GET \ ${SENZING_DEMO_URL}/stats | jq
-
Exercise a number of APIs via
curlcommand in curl-command.sh.cd ${GIT_REPOSITORY_DIR}/doc ./curl-commands.sh > curl-commands.out 2>&1
View results in
${GIT_REPOSITORY_DIR}/doc/curl-commands.out
The following is incomplete work. Disregard. Do not copy to final GitHub site.
-
Create a new datasource.
export JSON_BEFORE='\"CFG_DSRC\": \[' export JSON_AFTER='\"CFG_DSRC\": \[{\"DSRC_ID\": 9999,\"DSRC_CODE\": \"'${SENZING_DEMO_DATASOURCE}'\",\"DSRC_DESC\": \"'${SENZING_DEMO_DATASOURCE}'\",\"DSRC_RELY\": 1,\"RETENTION_LEVEL\": \"Remember\",\"CONVERSATIONAL\": 0},' sudo sed -i.$(date +%s) \ -e "s|${JSON_BEFORE}|${JSON_AFTER}|" \ ${SENZING_DIR}/g2/data/g2config.json